NotesPreview.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="notes-preview" :style="[getAreaStyle(), getComponentStyle()]">
  4. <SerialNumberPosition
  5. v-if="isEnable(data.property.hasOwnProperty('sn_display_mode') ? data.property.sn_display_mode : 'false')"
  6. :property="data.property"
  7. />
  8. <div class="main">
  9. <div class="NPC-zhedie">
  10. <!-- :style="{
  11. backgroundColor:
  12. data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
  13. }" -->
  14. <div v-if="data.title_con" class="topTitle-note">
  15. <div class="NPC-top-left">
  16. <span
  17. class="NPC-topTitle-text"
  18. :style="{
  19. color:
  20. data.unified_attrib && data.unified_attrib.text_color ? data.unified_attrib.text_color : '#de4444',
  21. fontSize: data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  22. }"
  23. v-html="convertText(sanitizeHTML(data.title_con))"
  24. ></span>
  25. <span v-if="showLang" class="NPC-topTitle-text">
  26. {{ titleTrans[getLang()] }}
  27. </span>
  28. </div>
  29. <!-- <div class="NPC-top-right" @click="handleChangeTab">
  30. <span class="NPC-top-right-text">{{ wordShow ? '收起' : '展开' }}</span>
  31. <img v-if="wordShow" src="@/assets/down.png" alt="" />
  32. <img v-else class="rotate" src="@/assets/down.png" alt="" />
  33. </div> -->
  34. </div>
  35. <el-collapse-transition>
  36. <div v-show="wordShow" class="NPC-notes-list">
  37. <div v-for="(item, index) in data.option" :key="'NPC-notes' + index" class="NPC-notes">
  38. <div class="NPC-notes-con">
  39. <span
  40. class="NPC-notes-con-number"
  41. :style="{
  42. color: data.unified_attrib && data.unified_attrib.text_color ? data.unified_attrib.text_color : '',
  43. fontSize: data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  44. }"
  45. v-html="convertText(sanitizeHTML(item.number))"
  46. ></span>
  47. <div class="NPC-notes-con-box">
  48. <template v-if="isEnable(data.property.view_pinyin) && !notesData">
  49. <p class="pinyin-text">
  50. <span
  51. v-if="data.property.pinyin_position === 'top'"
  52. class="pinyin"
  53. :style="{
  54. fontSize:
  55. data.unified_attrib && data.unified_attrib.pinyin_size
  56. ? data.unified_attrib.pinyin_size
  57. : '',
  58. }"
  59. v-html="item.pinyin"
  60. >
  61. </span>
  62. <span>
  63. <span
  64. v-if="data.property.pinyin_position === 'front'"
  65. class="pinyin pinyin-front"
  66. :style="{
  67. fontSize:
  68. data.unified_attrib && data.unified_attrib.pinyin_size
  69. ? data.unified_attrib.pinyin_size
  70. : '',
  71. }"
  72. v-html="item.pinyin"
  73. ></span
  74. ><span
  75. class="NPC-notes-con-text"
  76. :style="{
  77. color:
  78. data.unified_attrib && data.unified_attrib.text_color
  79. ? data.unified_attrib.text_color
  80. : '',
  81. fontSize:
  82. data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  83. }"
  84. v-html="convertText(sanitizeHTML(item.con))"
  85. ></span
  86. ><span
  87. v-if="data.property.pinyin_position === 'back'"
  88. class="pinyin pinyin-back"
  89. :style="{
  90. fontSize:
  91. data.unified_attrib && data.unified_attrib.pinyin_size
  92. ? data.unified_attrib.pinyin_size
  93. : '',
  94. }"
  95. v-html="item.pinyin"
  96. ></span>
  97. </span>
  98. <span
  99. v-if="data.property.pinyin_position === 'bottom'"
  100. class="pinyin"
  101. :style="{
  102. fontSize:
  103. data.unified_attrib && data.unified_attrib.pinyin_size
  104. ? data.unified_attrib.pinyin_size
  105. : '',
  106. }"
  107. v-html="item.pinyin"
  108. ></span>
  109. </p>
  110. </template>
  111. <span
  112. v-else
  113. class="NPC-notes-con-text NPC-notes-con-texts"
  114. :style="{
  115. color:
  116. data.unified_attrib && data.unified_attrib.text_color ? data.unified_attrib.text_color : '',
  117. fontSize:
  118. data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  119. }"
  120. v-html="convertText(sanitizeHTML(item.con))"
  121. ></span>
  122. <span v-if="showLang" class="multilingual">
  123. {{
  124. multilingualTextList[getLang()] &&
  125. multilingualTextList[getLang()][index] &&
  126. multilingualTextList[getLang()][index][0]
  127. ? multilingualTextList[getLang()][index][0]
  128. : ''
  129. }}
  130. </span>
  131. </div>
  132. </div>
  133. <div
  134. class="NPC-notes-trans"
  135. :style="{
  136. fontSize: data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  137. }"
  138. v-if="item.interpret"
  139. v-html="convertText(sanitizeHTML(item.interpret))"
  140. ></div>
  141. <div
  142. v-if="item.note"
  143. class="NPC-notes-note"
  144. :style="{
  145. fontSize: data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
  146. }"
  147. v-html="convertText(sanitizeHTML(item.note))"
  148. ></div>
  149. <div v-if="item.file_list && item.file_list[0]" class="NPC-notes-note-img">
  150. <el-image
  151. :src="item.file_list[0].file_url"
  152. :preview-src-list="[item.file_list[0].file_url]"
  153. fit="contain"
  154. />
  155. </div>
  156. <div v-if="showLang" class="NPC-notes-note">
  157. {{
  158. multilingualTextList[getLang()] &&
  159. multilingualTextList[getLang()][index] &&
  160. multilingualTextList[getLang()][index][1]
  161. ? multilingualTextList[getLang()][index][1]
  162. : ''
  163. }}
  164. </div>
  165. </div>
  166. </div>
  167. </el-collapse-transition>
  168. </div>
  169. </div>
  170. </div>
  171. </template>
  172. <script>
  173. import { getNotesData, isEnable } from '@/views/book/courseware/data/notes';
  174. import PreviewMixin from '../common/PreviewMixin';
  175. import { GetFileURLMap } from '@/api/app';
  176. export default {
  177. name: 'NotesPreview',
  178. components: {},
  179. mixins: [PreviewMixin],
  180. props: ['notesData', 'isMobile'],
  181. data() {
  182. return {
  183. data: this.notesData ? this.notesData : getNotesData(),
  184. wordShow: true,
  185. multilingualTextList: {}, // 多语言对应的切割后的翻译
  186. titleTrans: {},
  187. };
  188. },
  189. computed: {},
  190. watch: {
  191. 'data.option.length': {
  192. handler(val) {
  193. if (val) {
  194. // this.wordShow = isEnable(this.data.property.is_word_show);
  195. this.handleData();
  196. }
  197. },
  198. deep: true,
  199. immediate: true,
  200. },
  201. },
  202. created() {},
  203. methods: {
  204. handleChangeTab() {
  205. this.wordShow = !this.wordShow;
  206. },
  207. handleData() {
  208. if (this.data.multilingual) {
  209. this.data.multilingual.forEach((item) => {
  210. let trans_arr = item.translation.split('\n');
  211. this.$set(this.titleTrans, item.type, trans_arr[0] ? trans_arr[0] : '');
  212. let chunkSize = 2;
  213. let chunkedArr = trans_arr.splice(1).reduce((acc, curr, index) => {
  214. // 当索引是chunkSize的倍数时,开始一个新的子数组
  215. if (index % chunkSize === 0) {
  216. acc.push([curr]); // 开始新的子数组并添加当前元素
  217. } else {
  218. acc[acc.length - 1].push(curr); // 将当前元素添加到最后一个子数组中
  219. }
  220. return acc;
  221. }, []);
  222. this.$set(this.multilingualTextList, item.type, chunkedArr);
  223. });
  224. }
  225. // this.data.option.forEach((item) => {
  226. // if (item.file_list && item.file_list[0]) {
  227. // GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
  228. // this.$set(item, 'pic_url', url_map[item.file_list[0]]);
  229. // });
  230. // }
  231. // });
  232. },
  233. },
  234. };
  235. </script>
  236. <style lang="scss" scoped>
  237. @use '@/styles/mixin.scss' as *;
  238. .notes-preview {
  239. @include preview-base;
  240. .NPC-zhedie {
  241. // margin-bottom: 24px;
  242. .topTitle-note {
  243. display: flex;
  244. justify-content: space-between;
  245. width: 100%;
  246. height: 48px;
  247. padding-right: 16px;
  248. padding-left: 24px;
  249. overflow: hidden;
  250. // background: #e35454;
  251. // border: 1px solid rgba(0, 0, 0, 10%);
  252. // border-radius: 8px 8px 0 0;
  253. :deep p {
  254. margin: 0;
  255. }
  256. .NPC-top-left {
  257. display: flex;
  258. align-items: center;
  259. justify-content: flex-start;
  260. .NPC-topTitle-text {
  261. // margin: 0 8px 0 0;
  262. // font-family: 'sourceR';
  263. font-size: 16px;
  264. font-weight: bold;
  265. // color: #fff;
  266. }
  267. }
  268. .NPC-top-right {
  269. display: flex;
  270. align-items: center;
  271. justify-content: flex-start;
  272. cursor: pointer;
  273. &-text {
  274. font-size: 16px;
  275. font-weight: normal;
  276. line-height: 16px;
  277. color: #fff;
  278. }
  279. img {
  280. width: 20px;
  281. height: 20px;
  282. margin-left: 4px;
  283. }
  284. }
  285. .rotate {
  286. animation-name: firstrotate;
  287. animation-timing-function: linear;
  288. animation-direction: 2s;
  289. animation-fill-mode: both;
  290. }
  291. }
  292. .NPC-notes-list {
  293. padding: 24px 24px 5px;
  294. border: 1px solid rgba(0, 0, 0, 10%);
  295. border-radius: 4px;
  296. .NPC-notes {
  297. width: 100%;
  298. margin-bottom: 24px;
  299. :deep p {
  300. margin: 0;
  301. }
  302. .NPC-notes-con {
  303. display: flex;
  304. align-items: center;
  305. justify-content: flex-start;
  306. margin-bottom: 12px;
  307. .NPC-notes-con-box {
  308. flex: 1;
  309. margin-left: 5px;
  310. }
  311. .NPC-notes-con-number {
  312. font-family: 'robot';
  313. font-size: 14px;
  314. font-style: normal;
  315. font-weight: normal;
  316. line-height: 150%;
  317. color: #e35454;
  318. }
  319. .NPC-notes-con-text {
  320. width: max-content;
  321. margin: 0 5px;
  322. // font-size: 14px;
  323. font-style: normal;
  324. font-weight: normal;
  325. line-height: 1;
  326. color: #e35454;
  327. :deep p {
  328. // line-height: 150%;
  329. display: inline;
  330. }
  331. &.NPC-notes-con-texts {
  332. margin: 0;
  333. :deep p {
  334. display: inline-block;
  335. width: 100%;
  336. }
  337. }
  338. }
  339. }
  340. .pinyin {
  341. font-family: 'League';
  342. font-size: 14px;
  343. &-front,
  344. &-back {
  345. :deep p {
  346. // line-height: 150%;
  347. display: inline;
  348. }
  349. }
  350. }
  351. .NPC-notes-trans {
  352. padding-left: 27px;
  353. margin-bottom: 12px;
  354. font-size: 14px;
  355. font-style: normal;
  356. font-weight: bold;
  357. line-height: 150%;
  358. color: #000;
  359. }
  360. .NPC-notes-note {
  361. font-size: 14px;
  362. font-style: normal;
  363. font-weight: normal;
  364. line-height: 150%;
  365. color: #000;
  366. text-indent: 27px;
  367. word-break: break-word;
  368. }
  369. }
  370. }
  371. .NPC-notes-note-img {
  372. width: 100%;
  373. > div {
  374. max-width: 100%;
  375. > img {
  376. max-width: 100%;
  377. }
  378. }
  379. }
  380. }
  381. @keyframes firstrotate {
  382. 0% {
  383. transform: rotateZ(0deg);
  384. }
  385. 100% {
  386. transform: rotateZ(180deg);
  387. }
  388. }
  389. @keyframes huifuRotate {
  390. 0% {
  391. transform: rotateZ(180deg);
  392. }
  393. 100% {
  394. transform: rotateZ(0deg);
  395. }
  396. }
  397. }
  398. </style>