mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-13 16:06:10 +08:00
add pwa restart
This commit is contained in:
28
view/sw.js
Normal file
28
view/sw.js
Normal file
@@ -0,0 +1,28 @@
|
||||
//缓存空间名称
|
||||
var CACHE_VERSION = 'sw_v1';
|
||||
|
||||
var CACHE_FILES = [
|
||||
'/',
|
||||
];
|
||||
|
||||
self.addEventListener('install', function (event) {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_VERSION)
|
||||
.then(cache => cache.addAll(CACHE_FILES)
|
||||
.then(() => self.skipWaiting())
|
||||
));
|
||||
});
|
||||
|
||||
self.addEventListener('activate', function (event) {
|
||||
event.waitUntil(
|
||||
caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.map(function (key, i) {
|
||||
if (key !== CACHE_VERSION) {
|
||||
return caches.delete(keys[i]);
|
||||
}
|
||||
}));
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function(event) {});
|
||||
Reference in New Issue
Block a user