skyblued 2 år sedan
förälder
incheckning
519e1369e3
1 ändrade filer med 6 tillägg och 4 borttagningar
  1. 6 4
      src/views/coursewarePlay/index.tsx

+ 6 - 4
src/views/coursewarePlay/index.tsx

@@ -49,8 +49,6 @@ export default defineComponent({
   name: 'CoursewarePlay',
   setup() {
     const handleInit = (type = 0) => {
-      // 计算容器 16:9
-      setContainer()
       // 横屏
       postMessage({
         api: 'setRequestedOrientation',
@@ -86,11 +84,14 @@ export default defineComponent({
       let min = Math.min(screen.width, screen.height)
       let max = Math.max(screen.width, screen.height)
       let width = min * (16 / 9)
-      console.log('计算的屏幕宽度', width, screen.width)
+      console.log('计算的屏幕宽度', width, max)
       if (width > max){
+        parentContainer.width = '100vw'
         return
+      } else {
+        parentContainer.width = width + 'px'
       }
-      parentContainer.width = width + 'px'
+      
       console.log('设置宽度', parentContainer.width)
     }
 
@@ -240,6 +241,7 @@ export default defineComponent({
       }
     }
     onMounted(() => {
+      setContainer()
       getDetail()
       getCourseSchedule()
       window.addEventListener('message', iframeHandle)