瀏覽代碼

播放1.3

skyblued 2 年之前
父節點
當前提交
7352b34e9d
共有 1 個文件被更改,包括 20 次插入19 次删除
  1. 20 19
      src/views/coursewarePlay/index.tsx

+ 20 - 19
src/views/coursewarePlay/index.tsx

@@ -48,7 +48,27 @@ import playLoadData from './datas/data.json'
 export default defineComponent({
   name: 'CoursewarePlay',
   setup() {
+    /** 设置播放容器 16:9 */
+    const parentContainer = reactive({
+      width: '100vw'
+    })
+    const setContainer = () => {
+      let min = Math.min(screen.width, screen.height)
+      let max = Math.max(screen.width, screen.height)
+      let width = min * (16 / 9)
+      console.log('计算的屏幕宽度', width, max)
+      if (width > max) {
+        parentContainer.width = '100vw'
+        return
+      } else {
+        parentContainer.width = width + 'px'
+      }
+
+      console.log('设置宽度', parentContainer.width)
+    }
     const handleInit = (type = 0) => {
+      //设置容器16:9
+      setContainer()
       // 横屏
       postMessage({
         api: 'setRequestedOrientation',
@@ -76,24 +96,6 @@ export default defineComponent({
       handleInit(1)
       window.removeEventListener('message', iframeHandle)
     })
-    /** 设置播放容器 16:9 */
-    const parentContainer = reactive({
-      width: '100vw'
-    })
-    const setContainer = () => {
-      let min = Math.min(screen.width, screen.height)
-      let max = Math.max(screen.width, screen.height)
-      let width = min * (16 / 9)
-      console.log('计算的屏幕宽度', width, max)
-      if (width > max){
-        parentContainer.width = '100vw'
-        return
-      } else {
-        parentContainer.width = width + 'px'
-      }
-      
-      console.log('设置宽度', parentContainer.width)
-    }
 
     const route = useRoute()
     const headeRef = ref()
@@ -241,7 +243,6 @@ export default defineComponent({
       }
     }
     onMounted(() => {
-      setContainer()
       getDetail()
       getCourseSchedule()
       window.addEventListener('message', iframeHandle)