소스 검색

更新优化

lex 3 년 전
부모
커밋
f68dd277f0
4개의 변경된 파일52개의 추가작업 그리고 10개의 파일을 삭제
  1. 21 0
      src/router/index-student.ts
  2. 28 7
      src/router/index-teacher.ts
  3. 2 2
      src/teacher/live-class/create-components/course-start.tsx
  4. 1 1
      src/teacher/open-live/index.tsx

+ 21 - 0
src/router/index-student.ts

@@ -1,3 +1,4 @@
+import { Dialog } from 'vant'
 import { createRouter, createWebHashHistory, Router } from 'vue-router'
 import routes from './routes-student'
 const router: Router = createRouter({
@@ -11,4 +12,24 @@ router.beforeEach((to, from, next) => {
   next()
 })
 
+let isOpen = false
+router.onError(error => {
+  if (error instanceof Error) {
+    const isChunkLoadFailed = error.name.indexOf('chunk')
+    const targetPath = router.currentRoute.value.fullPath
+    if (isChunkLoadFailed && !isOpen) {
+      isOpen = true
+      Dialog.alert({
+        title: '更新提示',
+        message: 'APP有更新请点击确定刷新页面?',
+        confirmButtonColor: 'var(--van-primary)'
+      }).then(() => {
+        // on close
+        location.hash = targetPath
+        window.location.reload()
+      })
+    }
+  }
+})
+
 export default router

+ 28 - 7
src/router/index-teacher.ts

@@ -1,13 +1,34 @@
-import { createRouter, createWebHashHistory, Router } from 'vue-router';
-import routes from './routes-teacher';
+import { Dialog } from 'vant'
+import { createRouter, createWebHashHistory, Router } from 'vue-router'
+import routes from './routes-teacher'
 const router: Router = createRouter({
   history: createWebHashHistory(),
   routes
-});
+})
 
 router.beforeEach((to, from, next) => {
-  document.title = (to.meta.title || '酷乐秀') as any;
-  next();
-});
+  document.title = (to.meta.title || '酷乐秀') as any
+  next()
+})
 
-export default router;
+let isOpen = false
+router.onError(error => {
+  if (error instanceof Error) {
+    const isChunkLoadFailed = error.name.indexOf('chunk')
+    const targetPath = router.currentRoute.value.fullPath
+    if (isChunkLoadFailed && !isOpen) {
+      isOpen = true
+      Dialog.alert({
+        title: '更新提示',
+        message: 'APP有更新请点击确定刷新页面?',
+        confirmButtonColor: 'var(--van-primary)'
+      }).then(() => {
+        // on close
+        location.hash = targetPath
+        window.location.reload()
+      })
+    }
+  }
+})
+
+export default router

+ 2 - 2
src/teacher/live-class/create-components/course-start.tsx

@@ -95,7 +95,7 @@ export default defineComponent({
               name="salesStartDate"
               readonly
               isLink
-              placeholder="请选择售日期"
+              placeholder="请选择售日期"
               onClick={() => {
                 this.minDate = dayjs().toDate()
                 this.currentDate = dayjs(
@@ -104,7 +104,7 @@ export default defineComponent({
                 this.typeDateTime = 'start'
                 this.dateStatus = true
               }}
-              rules={[{ required: true, message: '请选择售日期' }]}
+              rules={[{ required: true, message: '请选择售日期' }]}
             />
           </ColField>
           <ColField title="停售日期" required>

+ 1 - 1
src/teacher/open-live/index.tsx

@@ -136,7 +136,7 @@ export default defineComponent({
                   )}
                 </div>
                 <div class={styles.level}>
-                  {this.users?.starGrade || !this.users?.entryFlag ? (
+                  {this.users?.starGrade ? (
                     <Rate
                       modelValue={this.users?.starGrade}
                       iconPrefix="iconfont"