mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-27 02:33:48 +02:00
refactor: custom fonts
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { initDayjs } from './dayjs';
|
||||
import { initInteropApi } from './interopApi';
|
||||
import { initNoty } from './noty';
|
||||
import { initUi } from './ui';
|
||||
import { initUi, initUiForVrOverlay } from './ui';
|
||||
|
||||
/**
|
||||
* @param {boolean} isVrOverlay
|
||||
@@ -11,6 +11,8 @@ export async function initPlugins(isVrOverlay = false) {
|
||||
await initInteropApi(isVrOverlay);
|
||||
if (!isVrOverlay) {
|
||||
await initUi();
|
||||
} else {
|
||||
await initUiForVrOverlay();
|
||||
}
|
||||
initDayjs();
|
||||
if (isVrOverlay) {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import {
|
||||
// changeAppDarkStyle,
|
||||
applyAppCjkFontPack,
|
||||
applyAppFontFamily,
|
||||
changeAppThemeStyle,
|
||||
changeHtmlLangAttribute,
|
||||
getThemeMode,
|
||||
initThemeColor,
|
||||
refreshCustomCss
|
||||
// setLoginContainerStyle
|
||||
} from '../shared/utils/base/ui';
|
||||
import {
|
||||
APP_CJK_FONT_PACK_DEFAULT_KEY,
|
||||
APP_FONT_DEFAULT_KEY
|
||||
} from '../shared/constants';
|
||||
import { i18n, loadLocalizedStrings } from './i18n';
|
||||
|
||||
import configRepository from '../services/config';
|
||||
@@ -22,9 +26,7 @@ export async function initUi() {
|
||||
await loadLocalizedStrings(language);
|
||||
changeHtmlLangAttribute(language);
|
||||
|
||||
const { initThemeMode, isDarkMode } =
|
||||
await getThemeMode(configRepository);
|
||||
// setLoginContainerStyle(isDarkMode);
|
||||
const { initThemeMode } = await getThemeMode(configRepository);
|
||||
changeAppThemeStyle(initThemeMode);
|
||||
await initThemeColor();
|
||||
} catch (error) {
|
||||
@@ -33,3 +35,30 @@ export async function initUi() {
|
||||
|
||||
refreshCustomCss();
|
||||
}
|
||||
|
||||
export async function initUiForVrOverlay() {
|
||||
try {
|
||||
const [language, fontFamily, customFontFamily, cjkFontPack] =
|
||||
await Promise.all([
|
||||
configRepository.getString('VRCX_appLanguage', 'en'),
|
||||
configRepository.getString(
|
||||
'VRCX_fontFamily',
|
||||
APP_FONT_DEFAULT_KEY
|
||||
),
|
||||
configRepository.getString('VRCX_customFontFamily', ''),
|
||||
configRepository.getString(
|
||||
'VRCX_cjkFontPack',
|
||||
APP_CJK_FONT_PACK_DEFAULT_KEY
|
||||
)
|
||||
]);
|
||||
|
||||
// @ts-ignore
|
||||
i18n.locale = language;
|
||||
await loadLocalizedStrings(language);
|
||||
changeHtmlLangAttribute(language);
|
||||
applyAppFontFamily(fontFamily, customFontFamily);
|
||||
applyAppCjkFontPack(cjkFontPack);
|
||||
} catch (error) {
|
||||
console.error('Error initializing VR locale and fonts:', error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user