From d81f13dfda7e67afb636e6da3aad0fa64026463f Mon Sep 17 00:00:00 2001 From: Dingning Date: Sun, 9 Nov 2025 15:12:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=20PWA=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 + public/static-home.html | 3 ++- src/main.ts | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index d90b0653..e4c4bc99 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,7 @@ + diff --git a/public/static-home.html b/public/static-home.html index ae78be0e..4eaf4a10 100644 --- a/public/static-home.html +++ b/public/static-home.html @@ -1,5 +1,5 @@ - + Type Words 官网 - 词文记 | 单词跟打 · 文章跟打 @@ -35,6 +35,7 @@ + diff --git a/src/main.ts b/src/main.ts index dc5924d3..98d6d23b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,3 +23,16 @@ app.directive('opacity', (el, binding) => { app.directive('loading', loadingDirective) app.mount('#app') + +// 注册Service Worker(pwa支持) +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/service-worker.js') + .then(registration => { + console.log('ServiceWorker registration successful with scope: ', registration.scope); + }) + .catch(err => { + console.log('ServiceWorker registration failed: ', err); + }); + }); +}