Browse Source

修改问题

dsy 1 week ago
parent
commit
06c0d8fa1d

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2025.9.26'
+VUE_APP_VERSION = '2025.9.30'

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "eep_page",
-  "version": "2025.9.26",
+  "version": "2025.9.30",
   "private": true,
   "main": "main.js",
   "description": "智慧梧桐数字教材编辑器",

+ 31 - 26
src/views/book/courseware/create/components/CreateCanvas.vue

@@ -40,7 +40,7 @@
               <template v-for="(grid, k) in col.grid_list">
                 <span
                   v-if="k === 0"
-                  :key="`start-${i}-${j}-${k}`"
+                  :key="`start-${i}-${j}-${grid.id}`"
                   class="drag-line grid-line drag-row"
                   :style="{ gridArea: 'grid-top' }"
                   :data-row="i"
@@ -50,7 +50,7 @@
                 ></span>
                 <span
                   v-if="grid.row > 1 && grid.row !== col.grid_list[k - 1].row"
-                  :key="`middle-${i}-${j}-${k}`"
+                  :key="`middle-${i}-${j}-${grid.id}`"
                   :style="{ gridArea: `middle-${grid.grid_area}` }"
                   :data-row="i"
                   :data-col="j"
@@ -59,7 +59,7 @@
                   class="drag-line grid-line"
                 ></span>
                 <span
-                  :key="`left-${i}-${j}-${k}`"
+                  :key="`left-${i}-${j}-${grid.id}`"
                   :style="{ gridArea: `left-${grid.grid_area}` }"
                   :data-row="i"
                   :data-col="j"
@@ -84,7 +84,7 @@
                   @changeData="changeData"
                 />
                 <span
-                  :key="`right-${i}-${j}-${k}`"
+                  :key="`right-${i}-${j}-${grid.id}`"
                   :style="{ gridArea: `right-${grid.grid_area}` }"
                   :data-row="i"
                   :data-col="j"
@@ -94,7 +94,7 @@
                 ></span>
                 <span
                   v-if="k === col.grid_list.length - 1"
-                  :key="`end-${i}-${j}-${k}`"
+                  :key="`end-${i}-${j}-${grid.id}`"
                   class="drag-line grid-line drag-row"
                   :style="{ gridArea: `grid-bottom` }"
                   :data-row="i"
@@ -557,28 +557,29 @@ export default {
      * @param {string} id 组件 id
      * @param {number} min_height 最小高度
      */
-    handleVerticalMove(col, grid, offsetY, id, min_height) {
+    handleVerticalMove(col, grid, offsetY, id, min_height = 0) {
+      let height = 0;
+      const _h = this.isEdit ? grid?.edit_height : grid.height;
+
       // 高度为 auto 时
-      if (grid.height === 'auto') {
+      if (_h === 'auto' || _h === undefined) {
         const gridHeight = document.querySelector(`.${id}`).offsetHeight;
-        let height = gridHeight + offsetY;
-        // 当高度小于最小高度时,设置为最小高度
-        if (height < min_height) {
-          height = min_height;
-        }
-        grid.height = `${height}px`;
-        col.grid_template_rows = `0 ${col.grid_list.map(({ height }) => height).join(' 6px ')} 0`;
-        return;
-      }
-      // 高度为数字时
-      const height = Number(grid.height.replace('px', ''));
-      let _h = height + offsetY;
-      if (_h < min_height) {
-        _h = min_height;
+
+        height = gridHeight + offsetY;
+      } else {
+        // 高度为数字时
+        const h = this.isEdit ? grid?.edit_height : grid.height;
+
+        const gridHeight = Number(h?.replace('px', ''));
+        height = gridHeight + offsetY;
       }
-      if (_h >= 50) {
-        grid.height = `${_h}px`;
-        col.grid_template_rows = `0 ${col.grid_list.map(({ height }) => height).join(' 6px ')} 0`;
+      // 当高度小于最小高度时,设置为最小高度
+      height = Math.max(height, min_height, 50);
+
+      if (this.isEdit) {
+        grid.edit_height = `${height}px`;
+      } else {
+        grid.height = `${height}px`;
       }
     },
 
@@ -842,7 +843,7 @@ export default {
         if (!gridMap.has(item.row)) {
           gridMap.set(item.row, []);
         }
-        gridMap.get(item.row).push(item.height);
+        gridMap.get(item.row).push(item?.edit_height || item.height);
       });
       gridMap.forEach((value, i) => {
         if (i > 1) {
@@ -1020,6 +1021,7 @@ export default {
           grid_area: letter,
           width: '100fr',
           height: 'auto',
+          edit_height: 'auto',
           row: rowNum,
           type: this.curType,
         });
@@ -1038,6 +1040,7 @@ export default {
           grid_area: letter,
           width: '100fr',
           height: 'auto',
+          edit_height: 'auto',
           row: rowNum,
           type: this.curType,
         });
@@ -1084,6 +1087,7 @@ export default {
             row: 1,
             width: '100fr',
             height: 'auto',
+            edit_height: 'auto',
             type: this.curType,
           },
         ],
@@ -1110,6 +1114,7 @@ export default {
                 grid_area: letter,
                 width: '100fr',
                 height: 'auto',
+                edit_height: 'auto',
                 row: 1,
                 type: this.curType,
               },
@@ -1192,7 +1197,7 @@ export default {
 
       return {
         gridArea: grid.grid_area,
-        height: grid.height,
+        height: grid?.edit_height || grid.height,
         marginTop,
       };
     },

+ 1 - 37
src/views/book/courseware/create/components/question/table/Table.vue

@@ -287,7 +287,7 @@ export default {
                       write_base64: '',
                       audio_answer_list: [],
                     });
-                    inputIndex++;
+                    inputIndex += 1;
                   }
                 });
                 // // 去除所有的 font-size 样式
@@ -303,42 +303,6 @@ export default {
         this.createParsedTextInfoPinyin(text);
       }
     },
-    // 分割富文本
-    splitRichText(str) {
-      let _str = str;
-      let start = 0;
-      let index = 0;
-      let arr = [];
-      let matchNum = 0;
-      while (index !== -1) {
-        index = _str.indexOf('###', start);
-        if (index === -1) break;
-        matchNum += 1;
-        arr.push({ content: _str.slice(start, index), type: 'text' });
-        if (matchNum % 2 === 0 && arr.length > 0) {
-          arr[arr.length - 1].type = 'input';
-          let mark = getRandomNumber();
-          arr[arr.length - 1].mark = mark;
-          let content = arr[arr.length - 1].content;
-          // 设置答案数组
-          let isUnderline = /^_{3,}$/.test(content);
-          this.data.answer.answer_list.push({
-            value: isUnderline ? '' : content,
-            mark,
-            type: isUnderline ? 'any_one' : 'only_one',
-          });
-
-          // 将 content 设置为空,为预览准备
-          arr[arr.length - 1].content = '';
-        }
-        start = index + 3;
-      }
-      let last = _str.slice(start);
-      if (last) {
-        arr.push({ content: last, type: 'text' });
-      }
-      return arr;
-    },
     // 获取拼音解析文本
     createParsedTextInfoPinyin(text) {
       if (text === '') {

+ 13 - 12
src/views/book/courseware/data/table.js

@@ -30,7 +30,6 @@ export const fillTypeList = [
   { value: 'voice', label: '语音' },
 ];
 
-
 export function getTableProperty() {
   return {
     serial_number: 1,
@@ -59,14 +58,14 @@ export function getOption() {
   return {
     content: '',
     mark: getRandomNumber(),
-    model_essay:[]
+    model_essay: [],
   };
 }
 
-export function getAnswerOption () {
+export function getAnswerOption() {
   return {
     answer: '',
-    answer_list:[]
+    answer_list: [],
   };
 }
 
@@ -76,7 +75,7 @@ export function getTableData() {
     title: '表格',
     option_list: Array.from({ length: 2 }, () => Array.from({ length: 3 }, getOption)),
     record_list: [],
-    answer_list:Array.from({ length: 2 }, () => Array.from({ length: 3 }, getAnswerOption)),
+    answer_list: Array.from({ length: 2 }, () => Array.from({ length: 3 }, getAnswerOption)),
     mode: tableTypeList[0].value,
     vocabulary: '', // 用于选词的词汇
     word_list: [], // 选词列表
@@ -89,16 +88,18 @@ export function getTableData() {
       isBold: false,
       isItalic: false,
       isStrikethrough: false,
-      textAlign: ''
+      textAlign: '',
     },
     col_width: [
       {
-        value:100
-      },{
-        value:100
-      },{
-        value:100
-      }
+        value: 100,
+      },
+      {
+        value: 100,
+      },
+      {
+        value: 100,
+      },
     ], // 列宽
     property: getTableProperty(),
     has_identify: 'false', // 是否已识别

+ 0 - 1
src/views/book/courseware/preview/components/3d_model/3DModelPreview.vue

@@ -303,7 +303,6 @@ export default {
           this.addModelToScene(obj);
         },
         (progress) => {
-          console.log('加载进度:', `${(progress.loaded / progress.total) * 100}%`);
           if (progress.loaded >= progress.total) {
             this.loaded = true;
           }

+ 22 - 5
src/views/book/courseware/preview/components/table/TablePreview.vue

@@ -50,7 +50,7 @@
                   backgroundColor: data.mode === 'short' ? data.styles.bgColor : '',
                 }"
               >
-                <div :style="[tdStyle]" class="cell-wrap">
+                <div :style="[tdStyle, computedRichStyle(col.content)]" class="cell-wrap">
                   <template v-if="isEnable(data.property.view_pinyin)">
                     <p
                       v-for="(item, index) in col.model_pinyin"
@@ -130,7 +130,7 @@
                     </p>
                   </template>
                   <template v-else>
-                    <p :style="[tdStyle]" v-for="(item, index) in col.model_essay" :key="index">
+                    <p v-for="(item, index) in col.model_essay" :key="index" :style="[tdStyle]">
                       <span v-if="item.type === 'text'" :key="index" v-html="sanitizeHTML(item.value)"></span>
                       <template v-if="item.type === 'input'">
                         <template v-if="data.property.fill_type === fillTypeList[0].value">
@@ -199,7 +199,7 @@
                     </p>
                   </template>
                 </div>
-                <span class="multilingual" v-if="showLang">
+                <span v-if="showLang" class="multilingual">
                   {{
                     multilingualTextList[getLang()] &&
                     multilingualTextList[getLang()][i] &&
@@ -282,8 +282,6 @@ export default {
   created() {
     this.handleData();
   },
-  mounted() {},
-  beforeDestroy() {},
   methods: {
     handleData() {
       this.table_width = 0;
@@ -379,6 +377,25 @@ export default {
       this.writeVisible = true;
       this.writeMark = mark;
     },
+    computedRichStyle(content) {
+      if (this.data.mode === 'short') return {};
+      if (!content) return {};
+      // 提取首个标签的 style 样式属性
+      let styleMatch = content.match(/<\w+\s+[^>]*style=["']([^"']*)["'][^>]*>/i);
+      if (styleMatch && styleMatch[1]) {
+        let styleString = styleMatch[1];
+        let styleArray = styleString.split(';').filter((s) => s.trim() !== '');
+        let styleObject = {};
+        styleArray.forEach((style) => {
+          let [key, value] = style.split(':');
+          if (key && value) {
+            styleObject[key.trim()] = value.trim();
+          }
+        });
+        return styleObject;
+      }
+      return {};
+    },
   },
 };
 </script>