enhance(frontend): improve theme apply handling
This commit is contained in:
parent
130d065d0c
commit
f0380f2d1c
|
|
@ -69,9 +69,6 @@ export async function common(createVue: () => Promise<App<Element>>) {
|
|||
if (lastVersion !== version) {
|
||||
miLocalStorage.setItem('lastVersion', version);
|
||||
|
||||
// テーマリビルドするため
|
||||
miLocalStorage.removeItem('theme');
|
||||
|
||||
try { // 変なバージョン文字列来るとcompareVersionsでエラーになるため
|
||||
if (lastVersion != null && compareVersions(version, lastVersion) === 1) {
|
||||
isClientUpdated = true;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export type Keys = (
|
|||
'bootloaderLocales' |
|
||||
'theme' |
|
||||
'themeId' |
|
||||
'themeCachedVersion' |
|
||||
'customCss' |
|
||||
'chatMessageDrafts' |
|
||||
'scratchpad' |
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import tinycolor from 'tinycolor2';
|
|||
import lightTheme from '@@/themes/_light.json5';
|
||||
import darkTheme from '@@/themes/_dark.json5';
|
||||
import JSON5 from 'json5';
|
||||
import { version } from '@@/js/config.js';
|
||||
import type { Ref } from 'vue';
|
||||
import type { BundledTheme } from 'shiki/themes';
|
||||
import { deepClone } from '@/utility/clone.js';
|
||||
|
|
@ -123,6 +124,7 @@ function applyThemeInternal(theme: Theme, persist: boolean) {
|
|||
if (persist) {
|
||||
miLocalStorage.setItem('theme', JSON.stringify(props));
|
||||
miLocalStorage.setItem('themeId', theme.id);
|
||||
miLocalStorage.setItem('themeCachedVersion', version);
|
||||
miLocalStorage.setItem('colorScheme', colorScheme);
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +141,7 @@ export function applyTheme(theme: Theme, persist = true) {
|
|||
timeout = null;
|
||||
}
|
||||
|
||||
if (theme.id === currentThemeId) return;
|
||||
if (theme.id === currentThemeId && miLocalStorage.getItem('themeCachedVersion') === version) return;
|
||||
currentThemeId = theme.id;
|
||||
|
||||
if (window.document.startViewTransition != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue