diff --git a/packages/frontend/src/_dev_boot_.ts b/packages/frontend/src/_dev_boot_.ts index 2ee738190..a35069bc3 100644 --- a/packages/frontend/src/_dev_boot_.ts +++ b/packages/frontend/src/_dev_boot_.ts @@ -62,7 +62,7 @@ async function main() { } //#endregion - const fontSize = localStorage.getItem('fontSize') || 1; + const fontSize = localStorage.getItem('fontSize') ?? 2; if (fontSize) { document.documentElement.classList.add('f-' + fontSize); } diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 7c4359abf..8bdc1e0b7 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -231,6 +231,19 @@ export async function common(createVue: () => App) { } //#endregion + //#region Load default font + const def_arr = miLocalStorage.getItem('defaultFontFace')?.split('_'); + const fontId = def_arr?.[0]; + if (fontId && fontId !== 'system-ui') { + try { + await import(`@/styles-font/${fontId}.scss`); + document.documentElement.classList.add(`default-font-${def_arr.join('_')}`); + } catch (e) { + console.warn(`Failed to load font style: ${fontId}`, e); + } + } + //#endregion + try { await fetchCustomEmojis(); } catch (err) { /* empty */ } @@ -294,19 +307,6 @@ export async function common(createVue: () => App) { console.log(i18n.tsx._selfXssPrevention.description3({ link: 'https://misskey-hub.net/docs/for-users/resources/self-xss/' })); //#endregion - //#region Load default font - const def_arr = miLocalStorage.getItem('defaultFontFace')?.split('_'); - const fontId = def_arr?.[0]; - if (fontId && fontId !== 'system-ui') { - try { - await import(`@/styles-font/${fontId}.scss`); - document.documentElement.classList.add(`default-font-${def_arr.join('_')}`); - } catch (e) { - console.warn(`Failed to load font style: ${fontId}`, e); - } - } - //#endregion - return { isClientUpdated, app, diff --git a/packages/frontend/src/scripts/font-settings.ts b/packages/frontend/src/scripts/font-settings.ts index 771d7e3c8..ece98bb7a 100644 --- a/packages/frontend/src/scripts/font-settings.ts +++ b/packages/frontend/src/scripts/font-settings.ts @@ -62,11 +62,11 @@ async function loadFontStyle(fontId: string) { export function getDefaultFontSettings() { const def_arr = miLocalStorage.getItem('defaultFontFace')?.split('_'); - const fontFace = ref(def_arr?.[0] ?? 'maokentangyuan'); + const fontFace = ref(def_arr?.[0] ?? 'system-ui'); const fontFaceType = ref(def_arr?.[1] ?? ''); const availableTypes = computed(() => getFontOptionsList(fontFace.value)); - async function setDafaultFont() { + async function setDefaultFont() { for (const klass of [...document.documentElement.classList.values()]) { if (klass.startsWith('default-font-')) { document.documentElement.classList.remove(klass); @@ -87,11 +87,11 @@ export function getDefaultFontSettings() { if (optionsList.length !== 0) { fontFaceType.value = optionsList.find((v) => v.default)?.id ?? ''; } else { - setDafaultFont(); + setDefaultFont(); } }); watch(fontFaceType, () => { - setDafaultFont(); + setDefaultFont(); }); return ref({