Enable service worker
This commit is contained in:
parent
43cb12930a
commit
dff1122bd5
@ -4,7 +4,7 @@ import { EventEmitter } from 'eventemitter3';
|
|||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
|
|
||||||
import initStore from './store';
|
import initStore from './store';
|
||||||
import { apiUrl, clientVersion as version, lang } from './config';
|
import { apiUrl, clientVersion as version } from './config';
|
||||||
import Progress from './common/scripts/loading';
|
import Progress from './common/scripts/loading';
|
||||||
|
|
||||||
import Err from './common/views/components/connect-failed.vue';
|
import Err from './common/views/components/connect-failed.vue';
|
||||||
@ -172,7 +172,7 @@ export default class MiOS extends EventEmitter {
|
|||||||
callback();
|
callback();
|
||||||
|
|
||||||
// Init service worker
|
// Init service worker
|
||||||
//if (this.shouldRegisterSw) this.registerSw();
|
if (this.shouldRegisterSw) this.registerSw();
|
||||||
};
|
};
|
||||||
|
|
||||||
// キャッシュがあったとき
|
// キャッシュがあったとき
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import composeNotification from './common/scripts/compose-notification';
|
import composeNotification from './common/scripts/compose-notification';
|
||||||
import { erase } from '../../prelude/array';
|
import { erase } from '../../prelude/array';
|
||||||
|
import { clientVersion } from './config';
|
||||||
|
|
||||||
// キャッシュするリソース
|
// キャッシュするリソース
|
||||||
const cachee = [
|
const cachee = [
|
||||||
@ -16,7 +17,7 @@ self.addEventListener('install', ev => {
|
|||||||
|
|
||||||
ev.waitUntil(Promise.all([
|
ev.waitUntil(Promise.all([
|
||||||
self.skipWaiting(), // Force activate
|
self.skipWaiting(), // Force activate
|
||||||
caches.open(_VERSION_).then(cache => cache.addAll(cachee)) // Cache
|
caches.open(clientVersion).then(cache => cache.addAll(cachee)) // Cache
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ self.addEventListener('activate', ev => {
|
|||||||
// Clean up old caches
|
// Clean up old caches
|
||||||
ev.waitUntil(
|
ev.waitUntil(
|
||||||
caches.keys().then(keys => Promise.all(
|
caches.keys().then(keys => Promise.all(
|
||||||
erase(_VERSION_, keys)
|
erase(clientVersion, keys)
|
||||||
.map(key => caches.delete(key))
|
.map(key => caches.delete(key))
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user