king
8 天以前 a1e9b18a4dbfd21e1bf4d5cb60974ac2f0115efd
public/index.html
@@ -2,42 +2,81 @@
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="shortcut icon" href="#">
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
    <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 = ''
      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
      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()
              }
            }
          })
      }
      window.mkInfo = function(value, color = '') {
        if (color) {
          console.info(value, color)
        } else {
          console.info(value)
        }
      }
    </script>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.
      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.
      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
    <script>
      if ('ActiveXObject' in window) {
        window.onload = function() {
          document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">您的浏览器<span style="color: #ff4d4f">不受支持</span></div>'
        }
      }
    </script>
  </body>
</html>