From fec13a59f41bf634f95a68649441739036d5c235 Mon Sep 17 00:00:00 2001 From: andatoshiki <101481353+andatoshiki@users.noreply.github.com> Date: Thu, 2 Mar 2023 23:30:38 +0800 Subject: [PATCH] feat: add enhance application features and unregistered pwa service --- docs/.vitepress/theme/index.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 6f9fc38e..ad89f28c 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -19,6 +19,28 @@ import AsideSponsors from './components/AsideSponsors.vue' // @ts-ignore import Copyright from './components/Copyright.vue' +if (typeof window !== 'undefined') { + // unregister PWA service + if (window.navigator && navigator.serviceWorker) { + navigator.serviceWorker.getRegistrations().then(function (registrations) { + for (let registration of registrations) { + registration.unregister() + } + }) + } + + // delete the cache preserved in browser + if ('caches' in window) { + caches.keys().then(function (keyList) { + return Promise.all( + keyList.map(function (key) { + return caches.delete(key) + }) + ) + }) + } +} + export default { ...DefaultTheme, Layout: () => {