lex 1 рік тому
батько
коміт
bf47dfd3ad
6 змінених файлів з 55 додано та 21 видалено
  1. 11 0
      package-lock.json
  2. 1 0
      package.json
  3. 22 20
      src/components/o-sticky/index.tsx
  4. 8 1
      src/school/main.ts
  5. 6 0
      src/student/main.ts
  6. 7 0
      src/teacher/main.ts

+ 11 - 0
package-lock.json

@@ -32,6 +32,7 @@
         "qrcode": "^1.5.1",
         "qrcode.vue": "^3.3.3",
         "query-string": "^7.1.1",
+        "resize-observer-polyfill": "^1.5.1",
         "sortablejs": "^1.15.0",
         "swiper": "^9.0.5",
         "tcplayer.js": "^4.8.0",
@@ -8342,6 +8343,11 @@
       "integrity": "sha512-R/tCuvuOHQ8o2boRP6vgx8hXCCy87H1eY9V5imBYeVNyNVpuL9ciReSccLj2gDcax9+2weXy3bc8Vv+NRXeEvQ==",
       "license": "MIT"
     },
+    "node_modules/resize-observer-polyfill": {
+      "version": "1.5.1",
+      "resolved": "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
+      "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
+    },
     "node_modules/resolve": {
       "version": "1.22.1",
       "resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.1.tgz",
@@ -15881,6 +15887,11 @@
       "resolved": "https://registry.npmmirror.com/resize-detector/-/resize-detector-0.3.0.tgz",
       "integrity": "sha512-R/tCuvuOHQ8o2boRP6vgx8hXCCy87H1eY9V5imBYeVNyNVpuL9ciReSccLj2gDcax9+2weXy3bc8Vv+NRXeEvQ=="
     },
+    "resize-observer-polyfill": {
+      "version": "1.5.1",
+      "resolved": "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
+      "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
+    },
     "resolve": {
       "version": "1.22.1",
       "resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.1.tgz",

+ 1 - 0
package.json

@@ -45,6 +45,7 @@
     "qrcode": "^1.5.1",
     "qrcode.vue": "^3.3.3",
     "query-string": "^7.1.1",
+    "resize-observer-polyfill": "^1.5.1",
     "sortablejs": "^1.15.0",
     "swiper": "^9.0.5",
     "tcplayer.js": "^4.8.0",

+ 22 - 20
src/components/o-sticky/index.tsx

@@ -1,4 +1,3 @@
-import { useRect } from '@vant/use'
 import { defineComponent, nextTick, PropType } from 'vue'
 import styles from './index.module.less'
 import { useResizeObserver } from '@vueuse/core'
@@ -39,6 +38,10 @@ export default defineComponent({
     }
   },
   mounted() {
+    // 增加判断如果不支持当前依赖再设置即可
+    if (window.ResizeObserver === undefined) {
+      window.ResizeObserver = ResizeObserver
+    }
     if (this.position === 'top') {
       this.divStyle.top = this.offsetTop || '0px'
     } else {
@@ -56,28 +59,27 @@ export default defineComponent({
           }, 10)
         }
       })
-    } catch {
+    } catch (e) {
       //
+      console.log(e, 'error useResizeObserver')
     }
 
-    // nextTick(() => {
-    //   // 为了处理刚开始头部高度为0的情况
-    //   const { height } = useRect((this as any).$refs.div)
-    //   this.__initHeight(height)
-
-    //   setTimeout(() => {
-    //     const { height } = useRect((this as any).$refs.div)
-    //     this.__initHeight(height)
-    //   }, 200)
-
-    //   // 为了处理头部第一次获取高度不对的问题
-    //   setTimeout(() => {
-    //     const { height } = useRect((this as any).$refs.div2)
-    //     if (height !== this.heightV && this.position === 'top') {
-    //       this.__initHeight(height)
-    //     }
-    //   }, 1000)
-    // })
+    nextTick(() => {
+      //   // 为了处理刚开始头部高度为0的情况
+      //   const { height } = useRect((this as any).$refs.div)
+      //   this.__initHeight(height)
+      //   setTimeout(() => {
+      //     const { height } = useRect((this as any).$refs.div)
+      //     this.__initHeight(height)
+      //   }, 200)
+      //   // 为了处理头部第一次获取高度不对的问题
+      //   setTimeout(() => {
+      //     const { height } = useRect((this as any).$refs.div2)
+      //     if (height !== this.heightV && this.position === 'top') {
+      //       this.__initHeight(height)
+      //     }
+      //   }, 1000)
+    })
   },
   methods: {
     __initHeight(height: any) {

+ 8 - 1
src/school/main.ts

@@ -2,7 +2,7 @@ import { createApp } from 'vue'
 import App from './App'
 import router from '../router/index'
 import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
-
+// 先引入到入口文件
 import 'normalize.css'
 import 'vant/lib/index.css'
 
@@ -11,6 +11,12 @@ import { state } from '@/state'
 import { browser, setAuth } from '@/helpers/utils'
 import Vue3Lottie from 'vue3-lottie'
 import 'vue3-lottie/dist/style.css'
+import ResizeObserver from 'resize-observer-polyfill'
+
+// 增加判断如果不支持当前依赖再设置即可
+if (window.ResizeObserver === undefined) {
+  window.ResizeObserver = ResizeObserver;
+}
 
 const app = createApp(App).use(Vue3Lottie)
 
@@ -67,6 +73,7 @@ if (state.platformType === 'STUDENT') {
   state.platformApi = '/api-school'
 }
 
+
 app.use(router)
 
 app.mount('#app')

+ 6 - 0
src/student/main.ts

@@ -11,6 +11,12 @@ import { promisefiyPostMessage, postMessage } from '@/helpers/native-message'
 import { setAuth } from './music-group/layout/utils'
 import { browser } from '@/helpers/utils'
 import { state } from '@/state'
+import ResizeObserver from 'resize-observer-polyfill'
+
+// 增加判断如果不支持当前依赖再设置即可
+if (window.ResizeObserver === undefined) {
+  window.ResizeObserver = ResizeObserver;
+}
 
 // 获取token
 promisefiyPostMessage({ api: 'getToken' }).then((res: any) => {

+ 7 - 0
src/teacher/main.ts

@@ -10,6 +10,13 @@ import '../styles/index.less'
 import { state } from '@/state'
 import { browser, setAuth } from '@/helpers/utils'
 
+import ResizeObserver from 'resize-observer-polyfill'
+
+// 增加判断如果不支持当前依赖再设置即可
+if (window.ResizeObserver === undefined) {
+  window.ResizeObserver = ResizeObserver;
+}
+
 const app = createApp(App).use(Vue3Lottie)
 
 // 将selects全局混入当前vue实例中