fix locales versioning in service worker
This commit is contained in:
parent
b5a1c54d65
commit
45ac7e50bc
4 changed files with 6 additions and 2 deletions
1
packages/sw/src/@types/global.d.ts
vendored
1
packages/sw/src/@types/global.d.ts
vendored
|
|
@ -7,6 +7,7 @@
|
|||
type FIXME = any;
|
||||
|
||||
declare const _LANGS_: string[][];
|
||||
declare const _LANGS_VERSION_: string;
|
||||
declare const _VERSION_: string;
|
||||
declare const _ENV_: string;
|
||||
declare const _DEV_: boolean;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { I18n } from '@@/js/i18n.js';
|
|||
import type { Locale } from '../../../../locales/index.js';
|
||||
|
||||
class SwLang {
|
||||
public cacheName = `mk-cache-${_VERSION_}`;
|
||||
public cacheName = `mk-cache-${_LANGS_VERSION_}`;
|
||||
|
||||
public lang: Promise<string> = get('lang').then(async prelang => {
|
||||
if (!prelang) return 'en-US';
|
||||
|
|
@ -32,7 +32,7 @@ class SwLang {
|
|||
|
||||
private async _fetch(): Promise<I18n<Locale>> {
|
||||
// Service Workerは何度も起動しそのたびにlocaleを読み込むので、CacheStorageを使う
|
||||
const localeUrl = `/assets/locales/${await this.lang}.${_VERSION_}.json`;
|
||||
const localeUrl = `/assets/locales/${await this.lang}.${_LANGS_VERSION_}.json`;
|
||||
let localeRes = await caches.match(localeUrl);
|
||||
|
||||
// _DEV_がtrueの場合は常に最新化
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue