11wqe1 1 неделя назад
Родитель
Сommit
49f6b797c1

+ 15 - 0
src/App.vue

@@ -1,5 +1,6 @@
 <script setup>
 import { onMounted, ref, inject } from 'vue'
+import { courseUrl, registerSetCourseUrl } from '@/composables/useCourseIframe'
 import { RouterLink, RouterView, useRoute } from 'vue-router'
 import Header from './views/header.vue';
 import axios from 'axios';
@@ -20,6 +21,7 @@ const setTimeState = ref(null)
 const topUserInfo = ref({})
 
 onMounted(() => {
+  registerSetCourseUrl()
   // 通过 code 获取登录信息
   let isGrantCode = getUrlParam(window.parent.location.href, 'grant_code')
   let ticket = getUrlParam(window.parent.location.href, 'ticket')
@@ -346,7 +348,20 @@ const getUrlParam = (urlStr, urlKey) => {
   <div v-loading="isShow" style="height: 100vh;">
     <router-view></router-view>
   </div>
+  <iframe :src="courseUrl" class="courseIframe" v-if="courseUrl"></iframe>
   <!-- </keep-alive> -->
 </template>
 
 <style scoped></style>
+
+<style>
+.courseIframe {
+  width: 100vw;
+  height: 100vh;
+  position: fixed;
+  z-index: 99999;
+  top: 0;
+  left: 0;
+  border: none;
+}
+</style>

+ 3 - 20
src/components/main/courseSelect.vue

@@ -274,7 +274,6 @@
   <selectTeachingClassDialog 
   ref="DialogRef"
   @openCourse="openCourseIframe" />
-  <iframe :src="courseUrl" class="courseIframe" v-if="courseUrl"></iframe>
 
 </template>
 <script setup>
@@ -291,6 +290,7 @@ import selectTeachingClassDialog from '../dialog/selectTeachingClassDialog.vue'
 // import { Value } from 'sass';
 // import { dataType } from 'element-plus/es/components/table-v2/src/common';
 import axios from 'axios';
+import { openCourseIframe } from '@/composables/useCourseIframe'
 
 const lang = inject('lang')
 
@@ -360,17 +360,9 @@ const AI6TwoData = ref(courseDataJson.AI6Two)
 const activegrade = ref(lang.lang != 'hk' ? '3' : '4')
 const activeterm = ref('1')
 const activeCurrentData = ref([])
-const courseUrl = ref('')
-
-const openCourseIframe = (url) => {
-  courseUrl.value = url
-}
 
 onMounted(() => {
   currentData.value = courseData.value["三年级"]
-  window.setCourseUrl = function () {
-    courseUrl.value = ''
-  }
   getTimeCourse(1, 1)
   getCourseList() // 获取课程列表
 })
@@ -557,7 +549,7 @@ const getCourseUrl = (item) => {
       }
       let url2 = `${url}/pbl-student-table/dist/#/courseDetail?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&courseId=${item.courseId}&tType=1&cid=&screenType=2`
 
-      courseUrl.value = url2
+      openCourseIframe(url2)
     }
 const getTimeCourse = (id, item) => {
   if (setIntervalNum.value) {
@@ -649,7 +641,7 @@ const updateCourseId = (id, type) => {
         
         let url2 = `${url}/pbl-student-table/dist/#/courseDetail?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&courseId=${res.data[0][0].courseId}&tType=1&cid=&screenType=2`
         // top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 2, user.user.type);
-        courseUrl.value = url2
+        openCourseIframe(url2)
         // top.U.MD.D.I.openInApplication('setUrl',{url:url2,title:'课程详情',id:new Date().getTime()})
         // top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 3, user.user.type);
       }
@@ -1057,13 +1049,4 @@ watchEffect(() => {
 .grandTitle3{
   margin-top: 0;
 }
-.courseIframe{
-  width: 100vw;
-  height: 100vh;
-  position: fixed;
-  z-index: 99999;
-  top: 0;
-  left: 0;
-  border: none;
-}
 </style>

+ 5 - 6
src/components/main/opendetail.vue

@@ -133,6 +133,7 @@
 
 <script setup>
 import { ref, inject } from "vue";
+import { openCourseIframe } from '@/composables/useCourseIframe'
 import "../../common/aws-sdk-2.235.1.min.js";
 import axios from "axios";
 
@@ -153,9 +154,6 @@ const imgPreview = ref({
 	img: "",
 	show: false,
 });
-// onMounted(() => {
-//     requestUser()
-// })
 const showPreviewImg = (e) => {
 
 	if (e.target.nodeName === "IMG") {
@@ -244,7 +242,6 @@ defineExpose({
 const openDra = () => {
 	drawer.value = true;
 };
-
 const openCourseDetail = () => {
 	let id = cid.value;
 	console.log(user.user);
@@ -275,7 +272,8 @@ const openCourseDetail = () => {
 				}
 				let url2 = `${url}/pbl-student-table/dist/#/courseDetail?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&courseId=${res.data[0][0].courseId}&tType=1&cid=&screenType=2`
 				// top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 2, user.user.type);
-				top.U.MD.D.I.openInApplication('setUrl',{url:url2,title:'课程详情',id:new Date().getTime()})
+				// top.U.MD.D.I.openInApplication('setUrl',{url:url2,title:'课程详情',id:new Date().getTime()})
+				openCourseIframe(url2)
 				
 				// top.U.MD.D.I.openInApplication(
 				// 	"studyDetail",
@@ -320,7 +318,8 @@ const updateCourseId = (id, type) => {
 					}
 					let url2 = `${url}/pbl-student-table/dist/#/courseDetail?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&courseId=${res.data[0][0].courseId}&tType=${user.user.type}&cid=&screenType=2`
 					// top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 2, user.user.type);
-					top.U.MD.D.I.openInApplication('setUrl',{url:url2,title:'课程详情',id:new Date().getTime()})
+					// top.U.MD.D.I.openInApplication('setUrl',{url:url2,title:'课程详情',id:new Date().getTime()})
+					openCourseIframe(url2)
 
 					// top.U.MD.D.I.openInApplication(
 					// 	"studyDetail",

+ 15 - 0
src/composables/useCourseIframe.js

@@ -0,0 +1,15 @@
+import { ref } from 'vue'
+
+export const courseUrl = ref('')
+
+export function openCourseIframe(url) {
+  courseUrl.value = url
+}
+
+export function closeCourseIframe() {
+  courseUrl.value = ''
+}
+
+export function registerSetCourseUrl() {
+  window.setCourseUrl = closeCourseIframe
+}