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); + }); + }); +}