refactor(.gitignore): 添加 dist.zip 文件到忽略列表
- 在 .gitignore 文件中添加 dist.zip,避免打包文件被版本控制 fix(styles): 优化 setTheme 函数的参数处理 - 在 setTheme 函数中增加了对 themeName 类型的检查 - 确保只有在 themeName 是字符串时才使用它,否则使用默认主题 - 这样可以防止非字符串类型的 themeName 导致的错误
This commit is contained in:
parent
d6b06b5242
commit
0203d8513c
|
@ -10,6 +10,7 @@ lerna-debug.log*
|
|||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
dist.zip
|
||||
release
|
||||
*.local
|
||||
|
||||
|
|
|
@ -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}`);
|
||||
}
|
Loading…
Reference in New Issue