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