Pārlūkot izejas kodu

预览组件修改

dsy 2 nedēļas atpakaļ
vecāks
revīzija
b86d55f622

+ 1 - 1
src/views/book/courseware/preview/components/article/NormalModelChs.vue

@@ -2165,7 +2165,7 @@ export default {
     // 点击播放某个句子
     handleChangeTime(time, ed, index) {
       this.sentIndex = index;
-      if (time) {
+      if (time !== null && time !== undefined) {
         this.curTime = time;
         this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
         this.ed = ed;

+ 1 - 1
src/views/book/courseware/preview/components/article/Practicechs.vue

@@ -1081,7 +1081,7 @@ export default {
       }
       _this.sentIndex = index;
       _this.ed = ed;
-      if (time) {
+      if (time !== null && time !== undefined) {
         _this.curTime = time;
         _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
       }

+ 21 - 0
src/views/book/courseware/preview/components/audio/AudioPreview.vue

@@ -91,6 +91,7 @@ import { getAudioData } from '@/views/book/courseware/data/audio';
 
 import PreviewMixin from '../common/PreviewMixin';
 import AudioPlay from '../common/AudioPlay.vue';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'AudioPreview',
@@ -216,6 +217,26 @@ export default {
         this.viewScroll = 'hidden';
       }
     },
+
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
   },
 };
 </script>

+ 1 - 1
src/views/book/courseware/preview/components/dialogue_article/Practicechs.vue

@@ -1233,7 +1233,7 @@ export default {
       }
       _this.sentIndex = index;
       _this.ed = ed;
-      if (time) {
+      if (time !== null && time !== undefined) {
         _this.curTime = time;
         _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
       }

+ 22 - 0
src/views/book/courseware/preview/components/divider/DividerPreview.vue

@@ -6,6 +6,7 @@
 <script>
 import { getDividerData } from '@/views/book/courseware/data/divider';
 import PreviewMixin from '../common/PreviewMixin';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'DividerPreview',
@@ -33,6 +34,27 @@ export default {
       };
     },
   },
+  methods: {
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
+  },
 };
 </script>
 

+ 23 - 1
src/views/book/courseware/preview/components/label/LabelPreview.vue

@@ -20,6 +20,7 @@
 <script>
 import { getLabelData } from '@/views/book/courseware/data/label';
 import PreviewMixin from '../common/PreviewMixin';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'LabelPreview',
@@ -29,7 +30,28 @@ export default {
       data: getLabelData(),
     };
   },
-  methods: {},
+  methods: {
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        dynamicTags: [],
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
+  },
 };
 </script>
 

+ 10 - 8
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -1676,8 +1676,8 @@ export default {
       handler(val) {
         if (val) {
           // 如果有宽度为0且有内容的列,则行宽最小为撑满
-          if (this.rowWidth < this.width - 48) {
-            this.rowWidth = this.width - 48;
+          if (this.rowWidth < this.width - 2) {
+            this.rowWidth = this.width - 2;
           }
         }
       },
@@ -1713,8 +1713,8 @@ export default {
       });
       this.rowWidth += 132;
       // 如果有宽度为0且有内容的列,则行宽最小为撑满
-      if (this.rowWidth < this.width - 48) {
-        this.rowWidth = this.width - 48;
+      if (this.rowWidth < this.width - 2) {
+        this.rowWidth = this.width - 2;
       }
     },
     palyAudio(url, sIndex) {
@@ -2084,7 +2084,8 @@ export default {
 
     .NPC-word-list {
       overflow: auto;
-      background: #f7f7f7;
+
+      // background: #f7f7f7;
 
       .NPC-word-tab-common,
       .collocation,
@@ -2101,8 +2102,9 @@ export default {
       }
 
       > .NPC-word-tr {
-        margin-bottom: 8px;
-        background: #fff;
+        // margin-bottom: 8px;
+
+        // background: #fff;
         border-radius: 8px;
 
         .NPC-word-row {
@@ -2147,7 +2149,7 @@ export default {
   }
 
   .NPC-word-list {
-    padding: 20px 24px;
+    padding: 10px 0;
     border: 1px solid rgba(0, 0, 0, 10%);
     border-radius: 4px;
   }

+ 21 - 0
src/views/book/courseware/preview/components/picture/PicturePreview.vue

@@ -66,6 +66,7 @@
 <script>
 import { getPictureData } from '@/views/book/courseware/data/picture';
 import PreviewMixin from '../common/PreviewMixin';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'PicturePreview',
@@ -255,6 +256,26 @@ export default {
         }
       });
     },
+
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
   },
 };
 </script>

+ 26 - 0
src/views/book/courseware/preview/components/rich_text/RichTextPreview.vue

@@ -58,6 +58,7 @@ import PreviewMixin from '../common/PreviewMixin';
 import { isEnable } from '@/views/book/courseware/data/common';
 import PinyinText from '@/components/PinyinText.vue';
 import AudioPlay from '../character_base/components/AudioPlay.vue';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'RichTextPreview',
@@ -119,6 +120,31 @@ export default {
         }, 800);
       });
     },
+
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        paragraph_list: [],
+        rich_text_list: [],
+        content: '',
+        audio_file_id: '',
+        note_list: [],
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
   },
 };
 </script>

+ 23 - 2
src/views/book/courseware/preview/components/video/VideoPreview.vue

@@ -60,6 +60,7 @@
 import { getVideoData } from '@/views/book/courseware/data/video';
 import PreviewMixin from '../common/PreviewMixin';
 import VideoPlay from '../common/VideoPlay.vue';
+import { getRandomNumber } from '@/utils';
 
 export default {
   name: 'VideoPreview',
@@ -85,7 +86,7 @@ export default {
     data: {
       handler(val) {
         this.fileLen = val.file_list.length;
-        if (this.fileLen == 0) return;
+        if (this.fileLen === 0) return;
         if (this.data.property.view_method === 'list') {
           const ele = this.$refs.videoAreaBox;
           const sn_position = this.data.property.sn_position;
@@ -161,7 +162,7 @@ export default {
       }
       this.fileLen = this.data.file_list.length;
 
-      //}
+      // }
 
       this.resizeObserver = new ResizeObserver((entries) => {
         if (!this.getDragStatus() && !this.isFirstLoad) return;
@@ -282,6 +283,26 @@ export default {
         this.translateY = newY;
       }
     },
+
+    /**
+     * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
+     */
+    getNoTextContentData() {
+      let noTextContentData = JSON.parse(JSON.stringify(this.data));
+      const resetFieldMap = {
+        analysis_list: [],
+        answer_list: [],
+      };
+
+      Object.assign(noTextContentData, resetFieldMap);
+
+      if (noTextContentData.answer) {
+        noTextContentData.answer.answer_list = [];
+        noTextContentData.answer.reference_answer = '';
+      }
+
+      return noTextContentData;
+    },
   },
 };
 </script>