lsc 5 dagen geleden
bovenliggende
commit
18aeb7e224
3 gewijzigde bestanden met toevoegingen van 143 en 11 verwijderingen
  1. 7 3
      src/App.vue
  2. 4 4
      src/store/slides.ts
  3. 132 4
      src/views/Student/index.vue

+ 7 - 3
src/App.vue

@@ -1,8 +1,8 @@
 <template>
   <template v-if="slides.length">
-    <Screen v-if="screening" />
-    <Student v-else-if="viewMode === 'student'" :courseid="urlParams.courseid" :type="urlParams.type" />
-    <Editor v-else-if="_isPC" />
+    <Screen v-if="viewMode !== 'student'"  v-show="screening"/>
+    <Editor v-if="viewMode !== 'student'" v-show="_isPC && !screening" :courseid="urlParams.courseid"/>
+    <Student v-else-if="viewMode === 'student'" :courseid="urlParams.courseid" :type="urlParams.type" :userid="urlParams.userid" :oid="urlParams.oid" :org="urlParams.org" :cid="urlParams.cid" />
     <Mobile v-else />
   </template>
   <FullscreenSpin tip="数据初始化中,请稍等 ..." v-else  loading :mask="false" />
@@ -60,6 +60,10 @@ const getUrlParams = () => {
   const urlParams = new URLSearchParams(window.location.search)
   return {
     courseid: urlParams.get('courseid'),
+    userid: urlParams.get('userid'),
+    oid: urlParams.get('oid'),
+    org: urlParams.get('org'),
+    cid: urlParams.get('cid'),
     type: urlParams.get('type')
   }
 }

+ 4 - 4
src/store/slides.ts

@@ -53,10 +53,10 @@ export const useSlidesStore = defineStore('slides', {
     viewportSize: 1000, // 可视区域宽度基数
     viewportRatio: 0.5625, // 可视区域比例,默认16:9
     templates: [
-      { name: '红色通用', id: 'template_1', cover: 'https://asset.pptist.cn/img/template_1.jpg' },
-      { name: '蓝色通用', id: 'template_2', cover: 'https://asset.pptist.cn/img/template_2.jpg' },
-      { name: '紫色通用', id: 'template_3', cover: 'https://asset.pptist.cn/img/template_3.jpg' },
-      { name: '莫兰迪配色', id: 'template_4', cover: 'https://asset.pptist.cn/img/template_4.jpg' },
+      { name: '红色通用', id: 'template_1', cover: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/Snipaste_2025-08-15_14-10-111755238224052.png' },
+      // { name: '蓝色通用', id: 'template_2', cover: 'https://asset.pptist.cn/img/template_2.jpg' },
+      // { name: '紫色通用', id: 'template_3', cover: 'https://asset.pptist.cn/img/template_3.jpg' },
+      // { name: '莫兰迪配色', id: 'template_4', cover: 'https://asset.pptist.cn/img/template_4.jpg' },
     ], // 模板
   }),
 

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

@@ -142,12 +142,20 @@ import message from '@/utils/message'
 // 定义组件props
 interface Props {
   courseid?: string | null
+  userid?: string | null
+  oid?: string | null
+  org?: string | null
+  cid?: string | null
   type?: string | null
 }
 
 const props = withDefaults(defineProps<Props>(), {
   courseid: null,
-  type: null
+  userid: null,
+  oid: null,
+  org: null,
+  cid: null,
+  type: null,
 })
 
 // 图标组件通过全局注册,无需导入
@@ -329,6 +337,72 @@ const toggleLaserPen = () => {
 // 获取导入导出功能
 const { readJSON, exportJSON2 } = useImport()
 
+// 处理iframe链接,为包含workPage的iframe添加必要参数
+const processIframeLinks = () => {
+  try {
+    console.log('开始处理iframe链接')
+    console.log('当前props:', { courseid: props.courseid, userid: props.userid })
+    
+    // 获取所有iframe元素
+    const iframes = document.querySelectorAll('iframe')
+    console.log('找到iframe元素数量:', iframes.length)
+    
+    if (iframes.length === 0) {
+      return
+    }
+    
+    // 遍历所有iframe元素
+    iframes.forEach((iframe, index) => {
+      const iframeSrc = iframe.src
+      
+      if (iframeSrc && iframeSrc.includes('workPage')) {
+        console.log(`处理iframe ${index + 1}:`, iframeSrc)
+        
+        try {
+          // 解析URL,处理hash部分
+          let baseUrl = iframeSrc
+          let hashPart = ''
+          
+          // 分离base URL和hash部分
+          if (iframeSrc.includes('#')) {
+            const parts = iframeSrc.split('#')
+            baseUrl = parts[0]
+            hashPart = parts[1]
+          }
+          
+          // 构建新的hash部分,添加参数
+          // 为iframe设置固定的task值,避免每次切换都刷新
+          let newHash = hashPart
+          if (newHash.includes('?')) {
+            // 如果hash中已经有查询参数,添加&
+            newHash += `&courseid=${props.courseid || ''}&userid=${props.userid || ''}&stage=0&task=0&tool=0`
+          }
+          else {
+            // 如果hash中没有查询参数,添加?
+            newHash += `?courseid=${props.courseid || ''}&userid=${props.userid || ''}&stage=0&task=0&tool=0`
+          }
+          
+          // 构建新的URL
+          const newUrl = `${baseUrl}#${newHash}`
+          
+          // 更新iframe的src
+          iframe.src = newUrl
+          
+          console.log(`iframe ${index + 1} 链接已更新:`, iframe.src)
+        }
+        catch (error) {
+          console.error(`处理iframe ${index + 1} 链接时出错:`, error)
+        }
+      }
+    })
+    
+    console.log('iframe链接处理完成')
+  }
+  catch (error) {
+    console.error('处理iframe链接时出错:', error)
+  }
+}
+
 // 导入JSON功能
 const importJSON = (jsonData: any) => {
   try {
@@ -397,9 +471,57 @@ const backToEditor = () => {
 // 作业提交功能
 const handleHomeworkSubmit = () => {
   console.log('作业提交按钮被点击')
-  // 这里可以跳转到作业提交页面,并传递当前幻灯片的ID
-  // 例如:window.location.href = `/course/${props.courseid}/homework/${currentSlide.value?.id}`
-  message.info('作业提交功能暂未实现')
+  
+  try {
+    // 获取当前页面的所有iframe元素
+    const iframes = document.querySelectorAll('.viewer-canvas iframe')
+    console.log('找到iframe元素数量:', iframes.length)
+    
+    if (iframes.length === 0) {
+      message.warning('当前页面没有找到iframe元素')
+      return
+    }
+    
+    // 遍历所有iframe元素
+    for (let i = 0; i < iframes.length; i++) {
+      const iframe = iframes[i] as HTMLIFrameElement
+      const iframeSrc = iframe.src
+      
+      console.log(`iframe ${i + 1} 链接:`, iframeSrc)
+      
+      // 检查iframe链接是否包含workPage
+      if (iframeSrc && iframeSrc.includes('workPage')) {
+        console.log('找到包含workPage的iframe,尝试执行submitWork')
+        
+        try {
+          // 获取iframe的contentWindow
+          const iframeWindow = iframe.contentWindow as Window & { submitWork?: (...args: any[]) => void }
+          
+          if (iframeWindow && typeof iframeWindow.submitWork === 'function') {
+            // 如果存在submitWork方法,执行它,参数可变
+            console.log('执行iframe中的submitWork方法,参数可变')
+            const submitArgs = [slideIndex.value]
+            iframeWindow.submitWork(...submitArgs)
+            message.success('作业提交成功')
+            return
+          } 
+          console.log('iframe中没有找到submitWork方法')
+          
+        }
+        catch (error) {
+          console.error('访问iframe内容时出错:', error)
+        }
+      }
+    }
+    
+    // 如果没有找到包含workPage的iframe或无法执行submitWork
+    message.info('未找到可用的作业提交功能')
+    
+  }
+  catch (error) {
+    console.error('作业提交过程中出错:', error)
+    message.error('作业提交失败')
+  }
 }
 
 // 获取作业提交按钮的右侧位置
@@ -456,6 +578,9 @@ const handleSlidesDataUpdated = () => {
     setTimeout(() => {
       showSlideList.value = true
       console.log('组件重新渲染完成')
+      
+      // 重新处理iframe链接
+      processIframeLinks()
     }, 500)
 
     console.log('slidesDataUpdated 事件处理完成')
@@ -495,6 +620,9 @@ onMounted(() => {
   // 计算初始缩放比例
   nextTick(() => {
     calculateScale()
+    
+    // 处理iframe链接
+    processIframeLinks()
   })
 
   // 监听窗口大小变化