NotesPreview.vue 12 KB

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