瀏覽代碼

Merge branch 'beta' of https://git.cocorobo.cn/jack/PPT into beta

lsc 1 天之前
父節點
當前提交
b582435757

+ 23 - 6
src/assets/styles/prosemirror.scss

@@ -15,6 +15,11 @@
   p {
     margin: 0;
   }
+  .empty {
+    margin: 0;
+    font-size: 0;
+    padding: 0;
+  }
   p:first-child {
     margin-top: 0;
     // font-size: 0;
@@ -25,14 +30,21 @@
   }
   ul {
     
-    list-style-type: disc;
-    padding-inline-start: 0;
+    list-style-type: none;
+    padding-left: 1.5em;       /* 为伪元素留出空间 */
 
-    li {
-      list-style-type: inherit;
-      padding: 0;
+    li::before {
+      content: "•";
+      list-style-type: none;
+      padding: 0.125em 0;
+      float: left;
+      margin-right: 0.4em;
+    }
+
+    li.empty-li::before {
+      font-size: 0;
+      content: none !important;
     }
-    
   }
 
   ol {
@@ -42,6 +54,11 @@
     li {
       list-style-type: inherit;
       padding: 0.125em 0;
+      float: left;
+      margin-right: 0.4em;
+    }
+    li.empty-li::before {
+      content: none !important;
     }
   }
 

+ 11 - 7
src/hooks/useImport.ts

@@ -1694,11 +1694,15 @@ export default () => {
 
       // 收集当前幻灯片内所有上传任务
       const uploadTasks: Promise<void>[] = []
-
+      
       // 遍历每一张幻灯片
       for (const item of json.slides) {
-        // ----- 解析背景 -----
-        const { type, value } = item.fill
+        let type = "", value = "";
+        if (item.fill) {
+          // ----- 解析背景 -----
+          type = item.fill.type
+          value = item.fill.value
+        }
         let background: SlideBackground
         if (type === 'image') {
           // 背景图片也可能需要上传(但 PPTX 背景图通常是内嵌 base64)
@@ -1706,7 +1710,7 @@ export default () => {
           background = {
             type: 'image',
             image: {
-              src: value.picBase64,
+              src: value?.picBase64,
               size: 'cover',
             },
           }
@@ -1715,12 +1719,12 @@ export default () => {
           background = {
             type: 'gradient',
             gradient: {
-              type: value.path === 'line' ? 'linear' : 'radial',
-              colors: value.colors.map(item => ({
+              type: value?.path === 'line' ? 'linear' : 'radial',
+              colors: value?.colors.map(item => ({
                 ...item,
                 pos: parseInt(item.pos),
               })),
-              rotate: value.rot + 90,
+              rotate: value?.rot + 90,
             },
           }
         }

+ 90 - 8
src/utils/prosemirror/schema/nodes.ts

@@ -24,8 +24,8 @@ const orderedList: NodeSpec = {
   content: 'list_item+',
   group: 'block',
   parseDOM: [
-    { 
-      tag: 'ol', 
+    {
+      tag: 'ol',
       getAttrs: dom => {
         const order = ((dom as HTMLElement).hasAttribute('start') ? (dom as HTMLElement).getAttribute('start') : 1) || 1
         const attr: Attr = { order: +order }
@@ -188,9 +188,33 @@ const listItem: NodeSpec = {
     }
     if (marginTop) style += `margin-top: ${marginTop};`;
     if (marginBottom) style += `margin-bottom: ${marginBottom};`;
-    if (marginLeft) style += `margin-left: ${marginLeft};`;
+    if (marginLeft) {
+      // 解析数值和单位
+      const str = String(marginLeft).trim();
+      const match = str.match(/^([+-]?\d*\.?\d+)(px|pt|em|rem|%|vw|vh)?$/i);
+      if (match) {
+        let num = parseFloat(match[1]);
+        const unit = match[2] || 'px';
+        const absNum = Math.abs(num); // 负数转正
+        const val = absNum + unit;
+        style += `margin-left: max(min(0px, 100% - ${val}), 0px);`;
+      } else {
+        style += `margin-left: ${marginLeft};`;
+      }
+    }
     if (marginRight) style += `margin-right: ${marginRight};`;
-    if (lineHeight) style += `line-height: ${lineHeight * 1.2};`;
+    if (lineHeight) {
+      let finalValue;
+      const str = String(lineHeight).trim();
+      // 匹配纯数字(整数或小数,可带负号)
+      if (/^-?\d+(\.\d+)?$/.test(str)) {
+        finalValue = parseFloat(str) * 1.2;
+      } else {
+        // 带单位或其他非纯数字内容,直接使用原值
+        finalValue = lineHeight;
+      }
+      style += `line-height: ${finalValue};`;
+    }
     if (paddingTop) style += `padding-top: ${paddingTop};`;
     if (paddingRight) style += `padding-right: ${paddingRight};`;
     if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
@@ -199,8 +223,23 @@ const listItem: NodeSpec = {
       style += `white-space: ${whiteSpace};`; // 添加 white-space
     }
 
-    const attrs: { style?: string } = {};
+    //const attrs: { style?: string } = {};
+    //if (style) attrs.style = style;
+
+    let isEmpty = false;
+    const firstChild = node.content.firstChild;
+    if (firstChild && firstChild.type.name === 'paragraph') {
+      // 段落无任何子节点(包括 text 和 inline 节点)
+      if (firstChild.content.size === 0) {
+        isEmpty = true;
+      }
+    }
+    // 如果整个 li 的内容长度为 0 也可以作为判断
+    if (node.content.size === 0) isEmpty = true;
+
+    const attrs: { style?: string; class?: string } = {};
     if (style) attrs.style = style;
+    if (isEmpty) attrs.class = 'empty-li';
 
     return ['li', attrs, 0];
   },
@@ -303,9 +342,36 @@ const paragraph: NodeSpec = {
     }
     if (marginTop) style += `margin-top: ${marginTop};`;
     if (marginBottom) style += `margin-bottom: ${marginBottom};`;
+    /*
+    if (marginLeft) {
+      // 解析数值和单位
+      const str = String(marginLeft).trim();
+      const match = str.match(/^([+-]?\d*\.?\d+)(px|pt|em|rem|%|vw|vh)?$/i);
+      if (match) {
+        let num = parseFloat(match[1]);
+        const unit = match[2] || 'px';
+        const absNum = Math.abs(num); // 负数转正
+        const val = absNum + unit;
+        style += `margin-left: max(min(0px, 100% - ${val}), 0px);`;
+      } else {
+        style += `margin-left: ${marginLeft};`;
+      }
+    }
+    */
     if (marginLeft) style += `margin-left: ${marginLeft};`;
     if (marginRight) style += `margin-right: ${marginRight};`;
-    if (lineHeight) style += `line-height: ${lineHeight * 1.2};`;
+    if (lineHeight) {
+      let finalValue;
+      const str = String(lineHeight).trim();
+      // 匹配纯数字(整数或小数,可带负号)
+      if (/^-?\d+(\.\d+)?$/.test(str)) {
+        finalValue = parseFloat(str) * 1.2;
+      } else {
+        // 带单位或其他非纯数字内容,直接使用原值
+        finalValue = lineHeight;
+      }
+      style += `line-height: ${finalValue};`;
+    }
     if (paddingTop) style += `padding-top: ${paddingTop};`;
     if (paddingRight) style += `padding-right: ${paddingRight};`;
     if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
@@ -314,8 +380,24 @@ const paragraph: NodeSpec = {
       style += `white-space: ${whiteSpace};`; // 添加 white-space
     }
 
-    const attr: Attr = { style };
-    return ['p', attr, 0];
+    const attrs: { style?: string; class?: string } = {};
+/*
+    let isEmpty = false;
+    const firstChild = node.content.firstChild;
+    if (firstChild) {
+      // 段落无任何子节点(包括 text 和 inline 节点)
+      if (firstChild.content.size === 0) {
+        isEmpty = true;
+      }
+    }
+    
+    // 如果整个 li 的内容长度为 0 也可以作为判断
+    if (node.content.size === 0) isEmpty = true;
+    if (style) attrs.style = style;
+    //if (isEmpty) attrs.class = 'empty';
+*/
+    if (style) attrs.style = style;
+    return ['p', attrs, 0];
   },
 };
 

+ 31 - 31
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -17,10 +17,10 @@
           }}</div>
           <div class="c_t45_msg">
             <div>{{ lang.ssAnswerCount }} {{ props.showData.workArray.length }}<span
-                v-if="props.showData.unsubmittedStudents.length > 0">/{{ props.showData.unsubmittedStudents.length
+                v-if="props.showData.unsubmittedStudents.length > 0">/{{ props.showData.workArray.length + props.showData.unsubmittedStudents.length
                 }}</span></div>
             <span v-if="props.showData.unsubmittedStudents.length > 0" @click="viewUnsubmittedStudents()">{{
-              lang.ssViewUnsubmittedStudents }}</span>
+              lang.ssViewSubmitStatus2 }}</span>
           </div>
           <!--<span class="c_t45_t_btn" :class="{'c_t45_t_btn_noActive': props.showData.workIndex <= 0}" @click="changeWorkIndex(0)">{{ lang.ssPrevQ }}</span>-->
           <!--<span class="c_t45_t_btn" :class="{'c_t45_t_btn_noActive': props.showData.workIndex >= props.showData.choiceQuestionListData.length - 1}" @click="changeWorkIndex(1)">{{ lang.ssNextQ }}</span>-->
@@ -869,7 +869,7 @@ watch(
 
 // 查看未提交学生
 const viewUnsubmittedStudents = () => {
-  selectUserDialogRef.value.open(lang.ssUnsubmittedStudents, { user: props.showData.unsubmittedStudents.map((item: any) => item.name) })
+  selectUserDialogRef.value.open(lang.ssSubmitStatus, { user: props.showData.unsubmittedStudents.map((item: any) => item.name),notFiledUser:props.showData.unsubmittedStudents.map((item: any) => item.name),isSubmitUser: props.workArray.map((item: any) => item.name)})
   // if (props.unsubmittedStudents.length > 0) {
   // unsubmittedStudentsDialogRef.value.open(props.unsubmittedStudents)
   // }
@@ -910,7 +910,7 @@ const aiAnalysisRefresh45 = () => {
 
   if (!currentAnalysis.value) {
     aiAnalysisData.value.push({
-      pid: props.workId,
+      pid: props.workId+(props.cid?','+props.cid:''),
       index: props.showData.workIndex,
       loading: true,
       generatingContent: true,
@@ -922,32 +922,32 @@ const aiAnalysisRefresh45 = () => {
   }
   else {
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).loading = true
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).json = { text: '', echartsData: '' }
   }
 
   chat_stream(msg, 'a7741704-ba56-40b7-a6b8-62a423ef9376', props.userId, lang.lang, (event) => {
     if (event.type === 'message') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
 
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).loading = false
     }
     else if (event.type === 'messageEnd') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).noEnd = false
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).update_at = new Date().toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).replace(/\//g, '-')
       saveAnalysis()
     }
@@ -989,7 +989,7 @@ const aiAnalysisRefresh15 = () => {
 30人中15人提交问答题(参与率50%),核心概念“同理心地图”掌握薄弱。发现学生13在智能体对话中6次答“不知道”,需单独辅导设计思维基础概念。建议课程增加POV框架实例演练,强化痛点识别能力训练。`
   if (!currentAnalysis.value) {
     aiAnalysisData.value.push({
-      pid: props.workId,
+      pid: props.workId+(props.cid?','+props.cid:''),
       index: props.showData.workIndex,
       loading: true,
       generatingContent: true,
@@ -1001,19 +1001,19 @@ const aiAnalysisRefresh15 = () => {
   }
   else {
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).loading = true
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).json = { text: '', echartsData: '' }
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).generatingContent = true
   }
   getWordCloud15().then((res) => {
     flag += 1
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).generatingContent = false
     if (flag == 2) {
       saveAnalysis()
@@ -1023,22 +1023,22 @@ const aiAnalysisRefresh15 = () => {
     console.log(event)
     if (event.type === 'message') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
 
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).loading = false
     }
     else if (event.type === 'messageEnd') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).noEnd = false
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).update_at = new Date().toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).replace(/\//g, '-')
       flag += 1
       if (flag == 2) {
@@ -1090,7 +1090,7 @@ const getWordCloud15 = () => {
 
     chat_no_stream(msg, 'a7741704-ba56-40b7-a6b8-62a423ef9376', props.userId, lang.lang).promise.then((res) => {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.echartsData = JSON.parse(res)
       resolve(1)
     }).catch(err => {
@@ -1151,7 +1151,7 @@ ${a.content}\n`
   console.log("cs", msg)
   if (!currentAnalysis.value) {
     aiAnalysisData.value.push({
-      pid: props.workId,
+      pid: props.workId+(props.cid?','+props.cid:''),
       index: props.showData.workIndex,
       loading: true,
       json: { text: '', echartsData: '' },
@@ -1162,32 +1162,32 @@ ${a.content}\n`
   }
   else {
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).loading = true
     aiAnalysisData.value.find((item: any) => {
-      return item.pid === props.workId && item.index === props.showData.workIndex
+      return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
     }).json = { text: '', echartsData: '' }
   }
 
   chat_stream(msg, 'a7741704-ba56-40b7-a6b8-62a423ef9376', props.userId, lang.lang, (event) => {
     if (event.type === 'message') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
 
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).loading = false
     }
     else if (event.type === 'messageEnd') {
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).json.text = event.data
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).noEnd = false
       aiAnalysisData.value.find((item: any) => {
-        return item.pid === props.workId && item.index === props.showData.workIndex
+        return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
       }).update_at = new Date().toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).replace(/\//g, '-')
       saveAnalysis()
     }
@@ -1200,7 +1200,7 @@ ${a.content}\n`
 // 当前分析
 const currentAnalysis = computed(() => {
   let _result = aiAnalysisData.value.find((item: any) => {
-    return item.pid === props.workId && item.index === props.showData.workIndex
+    return item.pid === props.workId+(props.cid?','+props.cid:'') && item.index === props.showData.workIndex
   })
 
   if (_result?.json?.echartsData) {

+ 24 - 1
src/views/Student/components/selectUserDialog.vue

@@ -5,7 +5,16 @@
       <div class="close" @click="close()"><svg  viewBox="0 0 1024 1024" width="200" height="200"><path d="M999.819275 905.894092c26.805506 27.003004 26.78811 70.77902-0.051166 97.756441-13.398148 13.484106-30.970362 20.234857-48.534389 20.234857-17.58961 0-35.171034-6.758937-48.577369-20.277836L511.657192 609.698113 120.30704 1003.263723c-13.407358 13.475919-30.970362 20.217461-48.53439 20.217461-17.58961 0-35.17922-6.758937-48.585555-20.269649-26.813692-27.003004-26.78811-70.77902 0.042979-97.764628l391.33378-393.557424L23.572882 117.989251c-26.813692-27.012214-26.796296-70.780043 0.034792-97.764627 26.839275-26.985608 70.332858-26.960025 97.137341 0.042979l390.989949 393.909441L903.07693 20.61962c26.831089-26.977421 70.315462-26.960025 97.129154 0.042979 26.813692 27.01119 26.78811 70.770833-0.042979 97.764627L608.812953 511.98465l391.006322 393.909442z"></path></svg></div>
     </div>
     <div class="content">
-      <div v-for="(item, index) in data.user" :key="index">
+      <div v-for="(item, index) in data.user" :key="index" v-if="!(data.notFiledUser && data.notFiledUser)">
+        {{ item }}
+      </div>
+      <span v-if="data.isSubmitUser">{{ lang.ssSubStu2 }}:</span>
+      <div v-for="(item, index) in data.isSubmitUser" :key="index" v-if="data.isSubmitUser">
+        {{ item }}
+      </div>
+      <div class="line" v-if="data.isSubmitUser && data.isSubmitUser"></div>
+      <span v-if="data.notFiledUser">{{ lang.ssUnsubStu2 }}:</span>
+      <div v-for="(item, index) in data.notFiledUser" :key="index" v-if="data.notFiledUser">
         {{ item }}
       </div>
     </div>
@@ -15,7 +24,9 @@
 <script setup>
 import { ref } from 'vue'
 import Modal from '@/components/Modal.vue'
+import { lang } from '@/main'
 const show = ref(false)
+
 const data = ref({})
 const title = ref("")
 
@@ -95,5 +106,17 @@ defineExpose({
     font-weight: 500;
     font-size: 1rem;
   }
+  &>span{
+    width: 100%;
+    display: block;
+    font-weight: 600;
+    font-size: 1rem;
+  }
+  &>.line{
+    padding: 0;
+    width: 100%;
+    height: 2px;
+    background: #FDF6DE;
+  }
 }
 </style>

+ 1 - 1
src/views/components/ThumbnailSlide/index.vue

@@ -3,7 +3,7 @@
     class="thumbnail-slide"
     :style="{
       width: size + 'px',
-      height: size * 0.5625 + 'px',
+      height: size * viewportRatio + 'px',
     }"
   >
       <!-- viewportRatio -->

+ 5 - 1
src/views/lang/cn.json

@@ -752,5 +752,9 @@
   "ssViewKeywordCloud":"点击查看词云",
   "ssKeyword":"关键词",
   "ssKeywordCloud":"词云",
-  "ssGeneratingContent":"生成中"
+  "ssGeneratingContent":"生成中",
+  "ssSubmitStatus":"提交情况",
+  "ssSubStu2":"已提交学生",
+  "ssUnsubStu2":"未提交学生",
+  "ssViewSubmitStatus2":"点击查看提交情况"
 }

+ 5 - 1
src/views/lang/en.json

@@ -752,5 +752,9 @@
   "ssViewKeywordCloud": "Click to view keyword cloud",
   "ssKeyword": "Keyword",
   "ssKeywordCloud": "Word Cloud",
-  "ssGeneratingContent": "Generating Content"
+  "ssGeneratingContent": "Generating Content",
+  "ssSubmitStatus":"Submission Status",
+  "ssSubStu2":"Submitted Students",
+  "ssUnsubStu2":"Unsubmitted Students",
+  "ssViewSubmitStatus2":"Click to view submission status"
 }

+ 5 - 1
src/views/lang/hk.json

@@ -752,5 +752,9 @@
   "ssViewKeywordCloud":"點擊查看詞雲",
   "ssKeyword":"關鍵詞",
   "ssKeywordCloud":"詞雲",
-  "ssGeneratingContent":"生成中"
+  "ssGeneratingContent":"生成中",
+  "ssSubmitStatus":"提交狀態",
+  "ssSubStu2":"已提交學生",
+  "ssUnsubStu2":"未提交學生",
+  "ssViewSubmitStatus2":"點擊查看提交狀態"
 }