From 6615b440d5b17a86aba9f557627e3bdbc4b8c85e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 09 七月 2023 16:54:03 +0800
Subject: [PATCH] 2023-07-09

---
 public/index.html |   52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/public/index.html b/public/index.html
index 2e1c8b4..3da241a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -3,12 +3,62 @@
   <head>
     <meta charset="utf-8" />
     <meta name="renderer" content="webkit">
-    <!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> -->
     <meta name="viewport" content="width=device-width, initial-scale=1" />
     <meta name="theme-color" content="#000000" />
     <link rel="shortcut icon" href="#">
     <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
     <title></title>
+    <script>
+      let _href = window.location.href.split('#')[0]
+      let l_version = localStorage.getItem(_href + 'version')
+      let _ctime = parseInt(new Date().getTime() / 1000)
+      let _time = ''
+
+      if (l_version) {
+        let vers = l_version.split('-')
+        l_version = vers[0]
+        _time = +vers[1]
+      }
+
+      if (_time && _ctime - _time < 180) {
+        let meta1 = document.createElement('meta')
+        let meta2 = document.createElement('meta')
+        let meta3 = document.createElement('meta')
+        let meta4 = document.createElement('meta')
+        meta1.content = '0'
+        meta1.httpEquiv = 'Expires'
+        meta2.content = 'no-cache'
+        meta2.httpEquiv = 'Pragma'
+        meta3.content = 'no-cache'
+        meta3.httpEquiv = 'Cache-Control'
+        meta4.content = 'no-cache'
+        meta4.httpEquiv = 'Cache'
+        document.getElementsByTagName('head')[0].appendChild(meta1)
+        document.getElementsByTagName('head')[0].appendChild(meta2)
+        document.getElementsByTagName('head')[0].appendChild(meta3)
+        document.getElementsByTagName('head')[0].appendChild(meta4)
+      } else {
+        fetch('./manifest.json', { cache: 'no-cache'})
+          .then(response => response.json())
+          .then(res => {
+            if (res && res.mk_version) {
+              let version = res.mk_version
+              let nocache = false
+
+              if (l_version && version !== l_version) {
+                nocache = true
+                localStorage.setItem(_href + 'version', version + '-' + _ctime)
+              } else if (!l_version) {
+                localStorage.setItem(_href + 'version', version + '-' + (_ctime - 360))
+              }
+
+              if (nocache) {
+                window.location.reload()
+              }
+            }
+          })
+      }
+    </script>
   </head>
   <body>
     <noscript>You need to enable JavaScript to run this app.</noscript>

--
Gitblit v1.8.0