キャッシュ対策
This commit is contained in:
parent
4101d156f3
commit
469434dd9a
|
@ -99,7 +99,7 @@ router.get('/twemoji/(.*)', async ctx => {
|
|||
});
|
||||
|
||||
// ServiceWorker
|
||||
router.get('/sw.js', async ctx => {
|
||||
router.get(`/sw.${config.version}.js`, async ctx => {
|
||||
await send(ctx as any, `/sw.js`, {
|
||||
root: swAssets,
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { instance } from '@/instance';
|
||||
import { $i } from '@/account';
|
||||
import { api } from '@/os';
|
||||
import { lang } from '@/config';
|
||||
import { lang, version } from '@/config';
|
||||
|
||||
export async function initializeSw() {
|
||||
if (instance.swPublickey &&
|
||||
('serviceWorker' in navigator) &&
|
||||
('PushManager' in window) &&
|
||||
$i && $i.token) {
|
||||
navigator.serviceWorker.register(`/sw.js`, { scope: '/', type: 'classic' });
|
||||
navigator.serviceWorker.register(`/sw.${version}.js`, { scope: '/', type: 'classic' });
|
||||
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.active?.postMessage({
|
||||
|
|
Loading…
Reference in New Issue