소스 검색

Merge branch 'iteration-20240521' into online

lex 1 년 전
부모
커밋
374ab4c93f
5개의 변경된 파일47개의 추가작업 그리고 34개의 파일을 삭제
  1. 2 2
      dev-dist/sw.js
  2. 15 16
      src/App.tsx
  3. 16 14
      src/components/RouterError/index.tsx
  4. 3 1
      src/views/studentList/modals/comment-work/index.tsx
  5. 11 1
      vite.config.ts

+ 2 - 2
dev-dist/sw.js

@@ -67,7 +67,7 @@ if (!self.define) {
     });
   };
 }
-define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
+define(['./workbox-5199072c'], (function (workbox) { 'use strict';
 
   self.skipWaiting();
   workbox.clientsClaim();
@@ -82,7 +82,7 @@ define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
     "revision": "3ca0b8505b4bec776b69afdba2768812"
   }, {
     "url": "index.html",
-    "revision": "0.tepotf17th8"
+    "revision": "0.uure8gg14q"
   }], {});
   workbox.cleanupOutdatedCaches();
   workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

+ 15 - 16
src/App.tsx

@@ -9,11 +9,10 @@ import { useRegisterSW } from 'virtual:pwa-register/vue';
 import { useUserStore } from './store/modules/users';
 export function unregister() {
   if ('serviceWorker' in navigator) {
-    console.log('unregister - pwa');
-    navigator.serviceWorker.ready.then(registration => {
-      registration.unregister();
-    });
-
+    // console.log('unregister - pwa');
+    // navigator.serviceWorker.ready.then(registration => {
+    //   registration.unregister();
+    // });
     // navigator.serviceWorker
     //   .getRegistrations()
     //   .then(registrations => {
@@ -193,18 +192,18 @@ export default defineComponent({
       // const intervalMS = 60 * 60 * 1000;
 
       // console.log(useRegisterSW, '1');
-      // const updateServiceWorker =
-      // useRegisterSW({
-      //   onRegistered(r: any) {
-      //     console.log(r, 'registered');
+      const updateServiceWorker = useRegisterSW({
+        onRegistered(r: any) {
+          console.log(r, 'registered');
 
-      //     r &&
-      //       setInterval(() => {
-      //         console.log('registered interval:', r);
-      //         r.update();
-      //       }, 30000);
-      //   }
-      // });
+          r &&
+            setInterval(() => {
+              // console.log('registered interval:', r);
+              r.update();
+            }, 30000);
+        }
+      });
+      // console.log('app - onounted - test interval');
     });
     onUnmounted(() => {
       window.removeEventListener('message', handleOpen);

+ 16 - 14
src/components/RouterError/index.tsx

@@ -46,19 +46,21 @@ export default defineComponent({
     const showModalMask = ref(false);
     const route = useRoute();
 
-    // router.onError((error, to, form) => {
-    //   const str = error.message + '';
-    //   const isChunkLoadFailed = str.indexOf('imported');
-    //   console.log(error, to)
-    //   // const targetPath = router.history.pending.fullPath
-    //   if (isChunkLoadFailed != -1 && !refreshing) {
-    //     refreshing = true;
-    //     console.log('onError刷新');
-    //     sessionStorage.setItem('isRouter','true')
-    //       // showModalMask.value = true;
-    //       // router.push(to.path)
-    //   }
-    // });
+    router.onError((error, to) => {
+      const str = error.message + '';
+      const isChunkLoadFailed = str.indexOf('imported');
+      console.log(error, to);
+      const targetPath = router.currentRoute.value.fullPath;
+      if (isChunkLoadFailed != -1 && !refreshing) {
+        refreshing = true;
+        // console.log('onError刷新');
+        // sessionStorage.setItem('isRouter', 'true');
+        // showModalMask.value = true;
+        // router.push(to.path)
+        location.hash = targetPath;
+        window.location.reload();
+      }
+    });
     router.beforeEach(async (to, from, next) => {
       const flag = await versionCheck();
       console.log('路由之前弹窗', `refreshing${refreshing},flag:${flag}`);
@@ -116,7 +118,7 @@ export default defineComponent({
             const isRouter = sessionStorage.getItem('isRouter');
             if (!isRouter) {
               // showModalMask.value = true
-              reloadPage();
+              // reloadPage();
             }
             refreshing = true;
           }

+ 3 - 1
src/views/studentList/modals/comment-work/index.tsx

@@ -98,7 +98,9 @@ export default defineComponent({
             <h3>{props.workInfo.studentName}</h3>
             <p>
               提交时间:
-              {dayjs(props.workInfo.submitTime).format('YYYY-MM-DD HH:mm')}
+              {props.workInfo.submitTime
+                ? dayjs(props.workInfo.submitTime).format('YYYY-MM-DD HH:mm')
+                : '--'}
             </p>
           </div>
         </div>

+ 11 - 1
vite.config.ts

@@ -68,7 +68,17 @@ export default defineConfig(() => {
         includeAssets: ['./logo.png'],
         workbox: {
           skipWaiting: true,
-          clientsClaim: true
+          clientsClaim: true,
+          runtimeCaching: [
+            {
+              urlPattern: ({ url }) =>
+                url.origin === 'https://dev.kt.colexiu.com',
+              handler: 'NetworkFirst',
+              options: {
+                cacheName: 'api-cache'
+              }
+            }
+          ]
           // runtimeCaching: [
           //   {
           //     urlPattern: /(.*?)\.(js|css|ts|tsx|html)/, // js /css /ts静态资源缓存