fix fonts error

This commit is contained in:
pa
2025-11-25 22:47:16 +09:00
committed by Natsumi
parent 5090cedf38
commit fa6eb2a3e1
5 changed files with 44 additions and 18 deletions

View File

@@ -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 {