Lind пре 4 година
родитељ
комит
039a23b66f
2 измењених фајлова са 28 додато и 20 уклоњено
  1. 18 10
      src/global.tsx
  2. 10 10
      src/pages/system/User/index.tsx

+ 18 - 10
src/global.tsx

@@ -5,6 +5,20 @@ import defaultSettings from '../config/defaultSettings';
 const { pwa } = defaultSettings;
 const isHttps = document.location.protocol === 'https:';
 
+const clearCache = () => {
+  // remove all caches
+  if (window.caches) {
+    caches
+      .keys()
+      .then((keys) => {
+        keys.forEach((key) => {
+          caches.delete(key);
+        });
+      })
+      .catch((e) => console.log(e));
+  }
+};
+
 // if pwa is true
 if (pwa) {
   // Notify user if offline now
@@ -34,8 +48,9 @@ if (pwa) {
         };
         worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);
       });
-      // Refresh current page to use the updated HTML and other assets after SW has skiped waiting
-      window.location.reload(true);
+
+      clearCache();
+      window.location.reload();
       return true;
     };
     const key = `open${Date.now()}`;
@@ -72,12 +87,5 @@ if (pwa) {
     if (sw) sw.unregister();
   });
 
-  // remove all caches
-  if (window.caches && window.caches.keys()) {
-    caches.keys().then((keys) => {
-      keys.forEach((key) => {
-        caches.delete(key);
-      });
-    });
-  }
+  clearCache();
 }

+ 10 - 10
src/pages/system/User/index.tsx

@@ -99,25 +99,25 @@ const User = observer(() => {
       onFilter: true,
       valueType: 'select',
       valueEnum: {
-        all: { 
+        all: {
           text: intl.formatMessage({
-            id:'pages.searchTable.titleStatus.all',
+            id: 'pages.searchTable.titleStatus.all',
             defaultMessage: '全部',
-          }), 
-          status: 'Default' 
+          }),
+          status: 'Default',
         },
         1: {
-          text:intl.formatMessage({
-            id:'pages.searchTable.titleStatus.normal',
+          text: intl.formatMessage({
+            id: 'pages.searchTable.titleStatus.normal',
             defaultMessage: '正常',
-          }), 
+          }),
           status: 1,
         },
         0: {
-          text:intl.formatMessage({
-            id:'pages.searchTable.titleStatus.disable',
+          text: intl.formatMessage({
+            id: 'pages.searchTable.titleStatus.disable',
             defaultMessage: '禁用',
-          }), 
+          }),
           status: 0,
         },
       },