Explorar o código

refactor(student): 优化代码格式与逻辑,修复部分细节问题

1.  调整getWorkId函数逻辑,新增toolType为72时的workId赋值逻辑
2.  统一多个模板元素的换行格式与代码缩进
3.  修复formatter函数的空格格式问题
4.  新增aiAnalysisRefresh72的调试日志,优化遍历逻辑,增加类型判断
5.  调整watch监听器的判断逻辑,简化代码
6.  统一css类名的空格格式规范
SanHQin hai 5 días
pai
achega
235cd746dd

+ 36 - 30
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -211,7 +211,8 @@
         </div>
 
         <div class="aiAnalysis" style="margin-top:1rem ;"
-          v-if="processedWorkArray.length > 0 && lookWorkData === null && workDetail.type === '15'" @click.stop="clickContent(false)">
+          v-if="processedWorkArray.length > 0 && lookWorkData === null && workDetail.type === '15'"
+          @click.stop="clickContent(false)">
           <div class="ai_header">
             <div class="ai_title">
               <svg viewBox="0 0 1024 1024" width="200" height="200">
@@ -270,7 +271,8 @@
         <div class="c_t15_title">{{ workDetail.json.answerQ }}</div>
         <span class="c_t15_type">{{ lang.ssPhoto }}</span>
         <div class="c_t15_content" v-show="!lookWorkData">
-          <div class="c_t15_c_item" v-for="item in processedWorkArray" :key="item.id" @click.stop="item.content && item.content.fileList.length > 0 ? lookWork(item.id) : ''">
+          <div class="c_t15_c_item" v-for="item in processedWorkArray" :key="item.id"
+            @click.stop="item.content && item.content.fileList.length > 0 ? lookWork(item.id) : ''">
             <div class="c_t15_c_i_top">
               <span>S</span>
               <div>{{ item.name }}</div>
@@ -291,7 +293,8 @@
             <div>{{ lookWorkData.name }}</div>
           </div>
           <div class="c_t79_wd_content">
-            <img :src="lookWorkData.content.fileList[lookWorkIndex].url" @click.stop="lookImage(lookWorkData.content.fileList[lookWorkIndex].url)" />
+            <img :src="lookWorkData.content.fileList[lookWorkIndex].url"
+              @click.stop="lookImage(lookWorkData.content.fileList[lookWorkIndex].url)" />
           </div>
           <!-- <div class="nextAndUpBtn" v-if="lookWorkData.content.fileList.length>1">
             <span :class="{no_active:lookWorkIndex==0}" @click="changelookWorkIndex(0)">{{ lang.ssPrevP }}</span>
@@ -332,7 +335,8 @@
         </div>
 
         <div class="aiAnalysis" style="margin-top:1rem ;"
-          v-if="processedWorkArray.length > 0 && lookWorkData === null && props.showData.toolType === 72" @click.stop="clickContent(false)">
+          v-if="processedWorkArray.length > 0 && lookWorkData === null && props.showData.toolType === 72"
+          @click.stop="clickContent(false)">
           <div class="ai_header">
             <div class="ai_title">
               <svg viewBox="0 0 1024 1024" width="200" height="200">
@@ -397,7 +401,8 @@
                           {{ item.type }}
                         </div>
                         <div class="na_m_i_content">
-                          <img @click.stop="lookImage(item3)" style="height: 100px;width: auto;cursor: pointer;" :src="item3" />
+                          <img @click.stop="lookImage(item3)" style="height: 100px;width: auto;cursor: pointer;"
+                            :src="item3" />
                         </div>
                       </div>
                     </template>
@@ -739,7 +744,7 @@ const setEchartsArea1 = () => {
           fontSize: 17,
           lineHeight: 20,
           interval: 0,
-          formatter: function(value: any, idx: number) {
+          formatter: function (value: any, idx: number) {
             // 如果是字符串且格式为JSON(图片),则解析处理
             if (typeof value === 'string') {
               try {
@@ -1348,27 +1353,27 @@ const getWordCloud15 = () => {
 const aiAnalysisRefresh72 = async () => {
 
   let chatMsg = ``
-
+  console.log('processedWorkArray.value', processedWorkArray.value)
   processedWorkArray.value.forEach((i) => {
-    i.content.forEach(j => {
-      if (j.messages) {
-        j.messages.forEach((a) => {
-          chatMsg += `\n${a.sender}:
+    if (typeof i.content === 'object') {
+      i.content.forEach(j => {
+        if (j.messages) {
+          j.messages.forEach((a) => {
+            chatMsg += `\n${a.sender}:
 ${a.content}\n`
-        })
-      }
-      if (j.imageUrls) {
-        j.imageUrls.forEach((a) => {
-          chatMsg += `\n${a}\n`
-        })
-      }
-
-    })
+          })
+        }
+        if (j.imageUrls) {
+          j.imageUrls.forEach((a) => {
+            chatMsg += `\n${a}\n`
+          })
+        }
 
+      })
+    }
   })
 
 
-
   // - 未提交学生:${JSON.stringify(props.showData.unsubmittedStudents.map((item: any) => item.name))}
   const msg = `# CONTEXT #
 你是K-12阶段的AI教育课堂分析助手,基于上传的课件、逐字稿,以及当页的学生答题数据(选择题/问答题/智能体对话)进行智能分析。
@@ -1461,9 +1466,9 @@ const currentAnalysis = computed(() => {
   if (_result) {
     return _result
   }
-  
+
   return null
-  
+
 })
 
 // 保存分析
@@ -1489,8 +1494,8 @@ const saveAnalysis = () => {
 
 
 // 点击边框
-const clickContent = (flag: boolean) =>{
-  if(flag && lookWorkDetail.value && workDetail.value?.type !== '45' && workDetail.value?.type !== '78'){
+const clickContent = (flag: boolean) => {
+  if (flag && lookWorkDetail.value && workDetail.value?.type !== '45' && workDetail.value?.type !== '78') {
     lookWork('')
   }
 }
@@ -1499,9 +1504,7 @@ const clickContent = (flag: boolean) =>{
 watch(
   () => props.showData?.workDetail,
   (newId, oldId) => {
-    if (newId && newId !== oldId) {
       getAnalysis()
-    }
   },
   { immediate: true }
 )
@@ -1868,6 +1871,7 @@ onUnmounted(() => {
           }
         }
       }
+
       .c_t79_workDetail {
         width: 100%;
         height: auto;
@@ -2440,14 +2444,15 @@ onUnmounted(() => {
   }
 }
 
-.nextAndUpBtn{
+.nextAndUpBtn {
   width: 100%;
   height: auto;
   display: grid;
   grid-template-columns: 1fr 1fr;
   margin-top: 20px;
   gap: 15px;
-  &>span{
+
+  &>span {
     display: flex;
     justify-content: center;
     align-items: center;
@@ -2460,7 +2465,8 @@ onUnmounted(() => {
     background: #f6c82b;
     cursor: pointer;
   }
-  &>.no_active{
+
+  &>.no_active {
     background: #cccccc !important;
     color: #999999 !important;
     cursor: not-allowed !important;

+ 4 - 2
src/views/Student/index.vue

@@ -1235,8 +1235,10 @@ const getWorkId = () => {
         id = match[1]
       }
       workId.value = id
-    }
-    else {
+      if((element as any).toolType === 72){
+        workId.value = (element as any).id
+      }
+    }else{
       workId.value = ''
     }
   }