From de1d582bf2ed7062fd400459f30d463d47ef9982 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 24 Aug 2020 22:59:45 +0800 Subject: ... --- Timeline/ClientApp/src/sw/sw.ts | 56 ++++++++++++++++----------------- Timeline/ClientApp/src/sw/tsconfig.json | 24 +++++++------- 2 files changed, 40 insertions(+), 40 deletions(-) (limited to 'Timeline/ClientApp/src/sw') diff --git a/Timeline/ClientApp/src/sw/sw.ts b/Timeline/ClientApp/src/sw/sw.ts index 9d62757a..d6202f36 100644 --- a/Timeline/ClientApp/src/sw/sw.ts +++ b/Timeline/ClientApp/src/sw/sw.ts @@ -1,28 +1,28 @@ -import { precacheAndRoute, matchPrecache } from 'workbox-precaching'; -import { setDefaultHandler } from 'workbox-routing'; -import { NetworkOnly } from 'workbox-strategies'; - -declare let self: ServiceWorkerGlobalScope; - -self.addEventListener('message', (event) => { - if (event.data && (event.data as { type: string }).type === 'SKIP_WAITING') { - void self.skipWaiting(); - } -}); - -precacheAndRoute(self.__WB_MANIFEST); - -const networkOnly = new NetworkOnly(); - -setDefaultHandler((options) => { - const { request, url } = options; - if (url && url.pathname.startsWith('/api/')) { - return networkOnly.handle(options); - } - - if (request instanceof Request && request.destination === 'document') - return matchPrecache('/index.html').then((r) => - r == null ? Response.error() : r - ); - else return networkOnly.handle(options); -}); +import { precacheAndRoute, matchPrecache } from "workbox-precaching"; +import { setDefaultHandler } from "workbox-routing"; +import { NetworkOnly } from "workbox-strategies"; + +declare let self: ServiceWorkerGlobalScope; + +self.addEventListener("message", (event) => { + if (event.data && (event.data as { type: string }).type === "SKIP_WAITING") { + void self.skipWaiting(); + } +}); + +precacheAndRoute(self.__WB_MANIFEST); + +const networkOnly = new NetworkOnly(); + +setDefaultHandler((options) => { + const { request, url } = options; + if (url && url.pathname.startsWith("/api/")) { + return networkOnly.handle(options); + } + + if (request instanceof Request && request.destination === "document") + return matchPrecache("/index.html").then((r) => + r == null ? Response.error() : r + ); + else return networkOnly.handle(options); +}); diff --git a/Timeline/ClientApp/src/sw/tsconfig.json b/Timeline/ClientApp/src/sw/tsconfig.json index 71fc0bcd..aac99e59 100644 --- a/Timeline/ClientApp/src/sw/tsconfig.json +++ b/Timeline/ClientApp/src/sw/tsconfig.json @@ -1,12 +1,12 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "lib": [ - "esnext", - "webworker" - ] - }, - "include": [ - "." - ] -} +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "lib": [ + "esnext", + "webworker" + ] + }, + "include": [ + "." + ] +} -- cgit v1.2.3