diff --git a/.gitignore b/.gitignore index 8cdddb7..ea3fc3d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ lerna-debug.log* node_modules dist dist-ssr +dist.zip release *.local diff --git a/src/styles/theme.js b/src/styles/theme.js index 155a5d2..263b943 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -79,9 +79,11 @@ export function applyDisplayMode(mode) { // --- Modified setTheme Function --- export function setTheme(themeName) { - const theme = themes[themeName] || themes.default // Fallback to default + // 确保 themeName 是字符串类型 + const themeKey = typeof themeName === 'string' ? themeName : 'default'; + const theme = themes[themeKey] || themes.default // Fallback to default if (!theme) { - console.error(`Theme "${themeName}" not found.`); + console.error(`Theme "${themeKey}" not found.`); return; } @@ -145,5 +147,5 @@ export function setTheme(themeName) { if (currentThemeClass) { document.body.classList.remove(currentThemeClass); } - document.body.classList.add(`theme-${themeName}`); + document.body.classList.add(`theme-${themeKey}`); } \ No newline at end of file