Browse Source

CDN test

dev
thuhole 5 years ago
parent
commit
503ef761a9
  1. 8
      public/index.html
  2. 14
      src/registerServiceWorker.js

8
public/index.html

@ -18,10 +18,10 @@
<link rel="apple-touch-icon" sizes="512x512" href="%PUBLIC_URL%/static/favicon/512.png" />
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="树洞">
<link rel="apple-touch-startup-image" href="https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/splash/750x1334.png" media="(device-width: 375px) and (-webkit-device-pixel-ratio: 2)"/>
<link rel="apple-touch-startup-image" href="https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/splash/1242x2208.png" media="(device-width: 414px) and (-webkit-device-pixel-ratio: 3)"/>
<link rel="apple-touch-startup-image" href="https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/splash/1668x2388.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"/>
<link rel="apple-touch-startup-image" href="https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/splash/2388x1668.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"/>
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/static/splash/750x1334.png" media="(device-width: 375px) and (-webkit-device-pixel-ratio: 2)"/>
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/splash/1242x2208.png" media="(device-width: 414px) and (-webkit-device-pixel-ratio: 3)"/>
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/splash/1668x2388.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"/>
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/static/splash/2388x1668.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"/>
<title>T大树洞</title>
</head>

14
src/registerServiceWorker.js

@ -21,13 +21,13 @@ const isLocalhost = Boolean(
export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return;
}
// const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
// if (publicUrl.origin !== window.location.origin) {
// // Our service worker won't work if PUBLIC_URL is on a different origin
// // from what our page is served on. This might happen if a CDN is used to
// // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
// return;
// }
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;

Loading…
Cancel
Save