fix(client): ローカリゼーション更新時にリロードが繰り返されることがあるのを修正
This commit is contained in:
parent
26ae2dfc0f
commit
9dacf11702
3 changed files with 16 additions and 5 deletions
|
@ -25,10 +25,10 @@ import JSON5 from 'json5';
|
|||
import widgets from '@/widgets';
|
||||
import directives from '@/directives';
|
||||
import components from '@/components';
|
||||
import { version, ui, lang, host } from '@/config';
|
||||
import { version, ui, lang, host, updateLocale } from '@/config';
|
||||
import { applyTheme } from '@/scripts/theme';
|
||||
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode';
|
||||
import { i18n } from '@/i18n';
|
||||
import { i18n, updateI18n } from '@/i18n';
|
||||
import { confirm, alert, post, popup, toast } from '@/os';
|
||||
import { stream } from '@/stream';
|
||||
import * as sound from '@/scripts/sound';
|
||||
|
@ -87,9 +87,12 @@ import { fetchCustomEmojis } from './custom-emojis';
|
|||
if (localeOutdated) {
|
||||
const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
|
||||
if (res.status === 200) {
|
||||
miLocalStorage.setItem('locale', await res.text());
|
||||
const newLocale = await res.text();
|
||||
const parsedNewLocale = JSON.parse(newLocale);
|
||||
miLocalStorage.setItem('locale', newLocale);
|
||||
miLocalStorage.setItem('localeVersion', version);
|
||||
location.reload();
|
||||
updateLocale(parsedNewLocale);
|
||||
updateI18n(parsedNewLocale);
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue