Pārlūkot izejas kodu

更新弹窗显示

lex 1 gadu atpakaļ
vecāks
revīzija
d2928d609a
3 mainītis faili ar 70 papildinājumiem un 66 dzēšanām
  1. 37 55
      dev-dist/sw.js
  2. 1 1
      public/version.json
  3. 32 10
      src/views/login/index.tsx

+ 37 - 55
dev-dist/sw.js

@@ -13,29 +13,31 @@
 
 // If the loader is already loaded, just stop.
 if (!self.define) {
-  const registry = {};
+  let registry = {};
 
   // Used for `eval` and `importScripts` where we can't get script URL by other means.
   // In both cases, it's safe to use a global var because those functions are synchronous.
   let nextDefineUri;
 
   const singleRequire = (uri, parentUri) => {
-    uri = new URL(uri + '.js', parentUri).href;
-    return (
-      registry[uri] ||
-      new Promise(resolve => {
-        if ('document' in self) {
-          const script = document.createElement('script');
-          script.src = uri;
-          script.onload = resolve;
-          document.head.appendChild(script);
-        } else {
-          nextDefineUri = uri;
-          importScripts(uri);
-          resolve();
-        }
-      }).then(() => {
-        const promise = registry[uri];
+    uri = new URL(uri + ".js", parentUri).href;
+    return registry[uri] || (
+      
+        new Promise(resolve => {
+          if ("document" in self) {
+            const script = document.createElement("script");
+            script.src = uri;
+            script.onload = resolve;
+            document.head.appendChild(script);
+          } else {
+            nextDefineUri = uri;
+            importScripts(uri);
+            resolve();
+          }
+        })
+      
+      .then(() => {
+        let promise = registry[uri];
         if (!promise) {
           throw new Error(`Module ${uri} didn’t register its module`);
         }
@@ -45,31 +47,27 @@ if (!self.define) {
   };
 
   self.define = (depsNames, factory) => {
-    const uri =
-      nextDefineUri ||
-      ('document' in self ? document.currentScript.src : '') ||
-      location.href;
+    const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
     if (registry[uri]) {
       // Module is already loading or loaded.
       return;
     }
-    const exports = {};
+    let exports = {};
     const require = depUri => singleRequire(depUri, uri);
     const specialDeps = {
       module: { uri },
       exports,
       require
     };
-    registry[uri] = Promise.all(
-      depsNames.map(depName => specialDeps[depName] || require(depName))
-    ).then(deps => {
+    registry[uri] = Promise.all(depsNames.map(
+      depName => specialDeps[depName] || require(depName)
+    )).then(deps => {
       factory(...deps);
       return exports;
     });
   };
 }
-define(['./workbox-5357ef54'], function (workbox) {
-  ('use strict');
+define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
 
   self.skipWaiting();
   workbox.clientsClaim();
@@ -79,32 +77,16 @@ define(['./workbox-5357ef54'], function (workbox) {
    * requests for URLs in the manifest.
    * See https://goo.gl/S9QRab
    */
-  workbox.precacheAndRoute(
-    [
-      {
-        url: 'registerSW.js',
-        revision: '3ca0b8505b4bec776b69afdba2768812'
-      },
-      {
-        url: 'index.html',
-        revision: '0.p9rb3ikv53'
-      }
-    ],
-    {}
-  );
-  /**
-   * https://juejin.cn/post/6844903881189621767
-   * 缓存策略 有5种
-   */
+  workbox.precacheAndRoute([{
+    "url": "registerSW.js",
+    "revision": "3ca0b8505b4bec776b69afdba2768812"
+  }, {
+    "url": "index.html",
+    "revision": "0.jattu9jipc"
+  }], {});
   workbox.cleanupOutdatedCaches();
-  workbox.registerRoute(
-    new workbox.NavigationRoute(workbox.createHandlerBoundToURL('index.html'), {
-      allowlist: [/^\/$/]
-    }),
-    workbox.strategies.NetworkFirst()
-  );
-  workbox.routing.registerRoute(
-    new RegExp('.*.html|css|js'),
-    workbox.strategies.NetworkFirst()
-  );
-});
+  workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
+    allowlist: [/^\/$/]
+  }));
+
+}));

+ 1 - 1
public/version.json

@@ -1 +1 @@
-{"version":1708672917092}
+{"version":1708685225009}

+ 32 - 10
src/views/login/index.tsx

@@ -41,6 +41,7 @@ export default defineComponent({
     const dialog = useDialog();
     const userPhone = ref(); // 用户手机号
     const showModalMask = ref(false);
+    const showAuthStatus = ref(false);
     const showAuthMask = ref(false);
     const checkInstall = async (event: any) => {
       event.preventDefault();
@@ -69,7 +70,7 @@ export default defineComponent({
           showModalMask.value = true;
           setTimeout(() => {
             const btn = document.querySelector('#submitBtn');
-            console.log(btn);
+            // console.log(btn);
             if (btn) {
               btn.addEventListener('click', () => {
                 showModalMask.value = false;
@@ -81,9 +82,11 @@ export default defineComponent({
                   if (choiceResult.outcome === 'accepted') {
                     console.log('用户已同意添加到桌面');
                     showModalMask.value = false;
+                    checkAuthShow();
                   } else {
                     console.log('用户已取消添加到桌面');
                     showModalMask.value = false;
+                    checkAuthShow();
                   }
                 });
               });
@@ -91,6 +94,16 @@ export default defineComponent({
           }, 500);
         }
       }
+
+      // 是否显示桌面安装,是否安装了证书
+      await checkAuthError();
+      if (!showModalMask.value && showAuthStatus.value) {
+        showAuthMask.value = true;
+      }
+    };
+
+    const checkAuthShow = () => {
+      if (showAuthStatus.value) showAuthMask.value = true;
     };
 
     window.addEventListener('beforeinstallprompt', checkInstall, {
@@ -101,20 +114,21 @@ export default defineComponent({
       window.removeEventListener('beforeinstallprompt', checkInstall);
     });
 
-    onMounted(async () => {
-      // 删除打谱里面上传记录
-      sessionStorage.removeItem('task-upload-music');
-      // const relatedApps = await navigator?.getInstalledRelatedApps();
-      //
-
+    const checkAuthError = async () => {
       try {
         await mutualTLSQuery({});
       } catch (err: any) {
-        console.log(err);
         if (err.message.indexOf('511')) {
-          showAuthMask.value = true;
+          // showAuthMask.value = true;
+          showAuthStatus.value = true;
         }
       }
+    };
+
+    onMounted(async () => {
+      // 删除打谱里面上传记录
+      sessionStorage.removeItem('task-upload-music');
+      // const relatedApps = await navigator?.getInstalledRelatedApps();
     });
     const downChrome = () => {
       const agent = navigator.userAgent.toLowerCase();
@@ -198,7 +212,14 @@ export default defineComponent({
             </div>
           </div>
         </div>
-        <NModal v-model:show={showModalMask.value}>
+        <NModal
+          v-model:show={showModalMask.value}
+          onMaskClick={() => {
+            checkAuthShow();
+          }}
+          onClose={() => {
+            checkAuthShow();
+          }}>
           <div class={styles.downMove}>
             <img src={dingPng} class={styles.dingPng} alt="" />
             <img src={moveTop} class={styles.downMoveBg} alt="" />
@@ -207,6 +228,7 @@ export default defineComponent({
               class={styles.closeAble}
               onClick={() => {
                 showModalMask.value = false;
+                checkAuthShow();
               }}
               alt=""
             />