Преглед на файлове

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

jack преди 12 часа
родител
ревизия
b7c97b7793
променени са 4 файла, в които са добавени 41 реда и са изтрити 4 реда
  1. 29 0
      src/views/Editor/Canvas/index.vue
  2. 2 2
      src/views/Editor/CanvasTool/WebpageInput.vue
  3. 1 1
      src/views/Editor/CanvasTool/index.vue
  4. 9 1
      src/views/Student/index.vue

+ 29 - 0
src/views/Editor/Canvas/index.vue

@@ -246,9 +246,16 @@ onMounted(() => {
   if (activeElementIdList.value.length) {
     nextTick(() => mainStore.setActiveElementIdList([]))
   }
+  // 优化:避免重复代码,统一设置 window.pptLoading
+  if (typeof window !== 'undefined') {
+    (window as any).pptLoading = 1
+  }
   if (props.courseid) {
     getCourseDetail()
   }
+  else {
+    (window as any).pptLoading = 2
+  }
 })
 
 const getCourseDetail = async () => {
@@ -273,10 +280,24 @@ const getCourseDetail = async () => {
         try {
           const jsonObj = JSON.parse(jsonStr)
           readJSON(jsonObj, true)
+          if (typeof window !== 'undefined') {
+            const win = window as any
+            win.pptLoading = 2
+          }
         }
         catch (e) {
           console.error('解析pptdata.data失败:', e)
           message.error('解析PPT数据失败')
+          if (typeof window !== 'undefined') {
+            const win = window as any
+            win.pptLoading = 2
+          }
+        }
+      }
+      else {
+        if (typeof window !== 'undefined') {
+          const win = window as any
+          win.pptLoading = 2
         }
       }
     }
@@ -285,10 +306,18 @@ const getCourseDetail = async () => {
     console.error('获取课程详情失败:', error)
     message.error('获取课程详情失败')
     isCourseLoading.value = false
+    if (typeof window !== 'undefined') {
+      const win = window as any
+      win.pptLoading = 2
+    }
   }
   finally {
     // 隐藏loading
     isCourseLoading.value = false
+    if (typeof window !== 'undefined') {
+      const win = window as any
+      win.pptLoading = 2
+    }
   }
 }
 

+ 2 - 2
src/views/Editor/CanvasTool/WebpageInput.vue

@@ -66,7 +66,7 @@ const props = withDefaults(defineProps<Props>(), {
 })
 
 const emit = defineEmits<{
-  (event: 'insertWebpage', url: string, type: number): void
+  (event: 'insertWebpage', payload: { url: string, type: number }): void
   (event: 'close'): void
 }>()
 
@@ -91,7 +91,7 @@ const insertWebpage = () => {
   // 根据选中的index获取对应的链接
   const selectedWebpage = props.webpageList[selectedIndex.value]
   if (selectedWebpage) {
-    emit('insertWebpage', selectedWebpage.url, selectedWebpage.type)
+    emit('insertWebpage', { url: selectedWebpage.url, type: selectedWebpage.type })
   }
 }
 

+ 1 - 1
src/views/Editor/CanvasTool/index.vue

@@ -76,7 +76,7 @@
           <WebpageInput 
             :webpageList="webpageList"
             @close="webpageInputVisible = false"
-            @insertWebpage="url => { createFrameElement(url, type); webpageInputVisible = false }"
+            @insertWebpage="({ url, type }) => { createFrameElement(url, type); webpageInputVisible = false }"
           />
         </template>
         <IconLinkOne class="handler-item" v-tooltip="'插入学习内容'" @click="handleInsertLearningContent" />

+ 9 - 1
src/views/Student/index.vue

@@ -192,6 +192,9 @@ const slideHeight = ref(0)
 // 添加loading状态
 const isLoading = ref(false)
 
+// 作业数组
+const workArray = ref([])
+
 // 计算幻灯片尺寸的函数
 const calculateSlideSize = () => {
   const slideWrapRef = isFullscreen.value ? document.body : viewerCanvasRef.value
@@ -950,7 +953,12 @@ const getWork = async () => {
     
     const res = await api.selectSWorks(props.courseid, '0', slideIndex.value.toString())
     console.log('getWork 执行成功,结果:', res)
-    return res
+    workArray.value = props.cid
+      ? res[0].filter((work: any) => {
+        return work.type === 1 || (work.type === 2 && work.classid.includes(props.cid))
+      })
+      : res[0]
+    console.log('getWork 执行成功,结果:', workArray.value)
   }
   catch (error) {
     console.error('getWork 执行失败:', error)