PWA: service worker

This commit is contained in:
cutls 2020-02-08 01:21:31 +09:00
parent 0f81740562
commit 1d5f73e2ab
2 changed files with 3 additions and 1 deletions

2
app/sw.pwa.js Normal file
View File

@ -0,0 +1,2 @@
//PWA用
self.addEventListener('fetch', function(e) {})

View File

@ -139,7 +139,7 @@ function main(ver, basefile, pwa) {
source = source.replace(/@@lang@@/g, lang)
source = source.replace(/@@langlist@@/g, langstr)
if(pwa) {
source = source.replace(/@@pwa@@/g, '<script>var pwa = true;</script>')
source = source.replace(/@@pwa@@/g, `<script>var pwa = true;"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.pwa.js").then(e=>{});</script>`)
source = source.replace(/@@node_base@@/g, 'dependencies')
} else {
source = source.replace(/@@pwa@@/g, '<script>var pwa = false;</script>')