Explorar o código

fix(student view): 修复重复更新作业结果数组的问题

1.  添加日志方便排查问题
2.  对比新旧结果数组,值未变化时跳过更新逻辑
3.  移除冗余的v-show绑定
lsc hai 1 día
pai
achega
060c94b944
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      src/views/Student/index.vue

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

@@ -78,7 +78,7 @@
           left: isFullscreen ? '0' : `${(containerWidth - slideWidth * canvasScale) / 2}px`,
           left: isFullscreen ? '0' : `${(containerWidth - slideWidth * canvasScale) / 2}px`,
           top: isFullscreen ? '0' : `${(containerHeight - slideHeight * canvasScale) / 2}px`
           top: isFullscreen ? '0' : `${(containerHeight - slideHeight * canvasScale) / 2}px`
         }" @mousemove="handleLaserMove">
         }" @mousemove="handleLaserMove">
-          <div class="homework-check-box" :class="{ 'fullscreen-mode': isFullscreen, 'fs-expanded': hwBoxExpanded }" v-if="currentSlideHasIframe && !currentSlideHasBilibiliVideo && (props.type == '1' || (props.type == '2' && currentIsResultArray.can && !is_cast_screen))"  v-show="currentSlideHasIframe" :style="{
+          <div class="homework-check-box" :class="{ 'fullscreen-mode': isFullscreen, 'fs-expanded': hwBoxExpanded }" v-if="currentSlideHasIframe && !currentSlideHasBilibiliVideo && (props.type == '1' || (props.type == '2' && currentIsResultArray.can && !is_cast_screen))" :style="{
             top: isFullscreen ? '0' : `0`
             top: isFullscreen ? '0' : `0`
           }" @click="isFullscreen && (hwBoxExpanded = !hwBoxExpanded)">
           }" @click="isFullscreen && (hwBoxExpanded = !hwBoxExpanded)">
             <div class="homework-check-box-item" @click.stop="openChoiceQuestionDetail2(slideIndex); hwBoxExpanded = false" :class="{'active': !choiceQuestionDetailDialogOpenList.includes(slideIndex)}">
             <div class="homework-check-box-item" @click.stop="openChoiceQuestionDetail2(slideIndex); hwBoxExpanded = false" :class="{'active': !choiceQuestionDetailDialogOpenList.includes(slideIndex)}">
@@ -1110,6 +1110,7 @@ const currentSlideHasEnglishSpeaking = computed(() => {
 
 
 // 检查当前的结果状态
 // 检查当前的结果状态
 const currentIsResultArray = computed(() => {
 const currentIsResultArray = computed(() => {
+  console.log('isResultArray.value[slideIndex.value]', isResultArray.value[slideIndex.value])
   return isResultArray.value[slideIndex.value] || {}
   return isResultArray.value[slideIndex.value] || {}
 })
 })
 
 
@@ -3765,7 +3766,11 @@ const getMessages = (msgObj: any) => {
   // 获取是否展开结果数组
   // 获取是否展开结果数组
   if (props.type == '2' && msgObj.type === 'isResultArray' && msgObj.courseid === props.courseid) {
   if (props.type == '2' && msgObj.type === 'isResultArray' && msgObj.courseid === props.courseid) {
     try {
     try {
-      isResultArray.value = JSON.parse(msgObj.isResultArray || '[]')
+      console.error('是否展开结果数组:', msgObj.isResultArray || '[]')
+      const newResultArray = JSON.parse(msgObj.isResultArray || '[]')
+      // 值未变化时跳过下游逻辑
+      if (JSON.stringify(newResultArray) === JSON.stringify(isResultArray.value)) return
+      isResultArray.value = newResultArray
     }
     }
     catch (error) {
     catch (error) {
       console.error('解析是否展开结果数组失败:', error)
       console.error('解析是否展开结果数组失败:', error)