mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-26 02:03:49 +02:00
fix fonts error
This commit is contained in:
@@ -43,6 +43,10 @@ export const THEME_CONFIG = {
|
||||
material3: {
|
||||
cssFile: material3,
|
||||
isDark: true,
|
||||
name: 'Material 3'
|
||||
name: 'Material 3',
|
||||
fontLinks: [
|
||||
'https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;600&family=Noto+Sans+TC:wght@300;400;500&family=Noto+Sans+SC:wght@300;400;500&family=Noto+Sans+JP:wght@300;400;500&family=Roboto&display=swap',
|
||||
'https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,6 +26,28 @@ function changeAppDarkStyle(isDark) {
|
||||
}
|
||||
}
|
||||
|
||||
function applyThemeFonts(themeKey, fontLinks = []) {
|
||||
document
|
||||
.querySelectorAll('link[data-theme-font]')
|
||||
.forEach((linkEl) => linkEl.remove());
|
||||
|
||||
if (!fontLinks?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const head = document.head;
|
||||
fontLinks.forEach((href) => {
|
||||
if (!href) {
|
||||
return;
|
||||
}
|
||||
const fontLink = document.createElement('link');
|
||||
fontLink.rel = 'stylesheet';
|
||||
fontLink.href = href;
|
||||
fontLink.dataset.themeFont = themeKey;
|
||||
head.appendChild(fontLink);
|
||||
});
|
||||
}
|
||||
|
||||
function changeAppThemeStyle(themeMode) {
|
||||
if (themeMode === 'system') {
|
||||
themeMode = systemIsDarkMode() ? 'dark' : 'light';
|
||||
@@ -57,6 +79,8 @@ function changeAppThemeStyle(themeMode) {
|
||||
}
|
||||
$appThemeStyle.href = themeConfig.cssFile ? themeConfig.cssFile : '';
|
||||
|
||||
applyThemeFonts(themeMode, themeConfig.fontLinks);
|
||||
|
||||
if (themeConfig.isDark) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user