Refactor theme font handling and preview logic

Moved font configuration to be managed via theme.css, eliminating the need for separate font initialization and caching. Updated backend to generate @font-face rules and font variables in theme.css. Frontend now uses a dedicated style tag for real-time font preview in the theme config page, and removes legacy font cache logic for improved consistency.
This commit is contained in:
手瓜一十雪
2026-01-04 18:48:16 +08:00
parent 0389418c57
commit 874c270093
3 changed files with 72 additions and 49 deletions

View File

@@ -268,15 +268,17 @@ const ThemeConfigCard = () => {
// 找到已保存的主题名称
const savedThemeName = useMemo(() => {
if (!originalDataRef.current) return null;
return themes.find(t => isThemeColorsEqual(t.theme, originalDataRef.current!))?.name || '自定义';
}, [dataLoaded, hasUnsavedChanges]);
const savedData = originalDataRef.current || data;
if (!savedData) return null;
return themes.find(t => isThemeColorsEqual(t.theme, savedData))?.name || '自定义';
}, [data, dataLoaded, hasUnsavedChanges]);
// 已保存的字体模式显示名称
const savedFontModeDisplayName = useMemo(() => {
const mode = originalDataRef.current?.fontMode || 'aacute';
const savedData = originalDataRef.current || data;
const mode = savedData?.fontMode || 'aacute';
return fontModeNames[mode] || mode;
}, [dataLoaded, hasUnsavedChanges]);
}, [data, dataLoaded, hasUnsavedChanges]);
if (loading) return <PageLoading loading />;