已开启
优化 themeChange 函数减少重复的 getTheme 调用 #1
f -创建于 2025年10月31日
优化 themeChange 函数减少重复的 getTheme 调用 #1
已开启
共 1 个文件变更+4-3
| @@ -21,9 +21,10 @@ const getTheme = (theme: string) => { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | const themeChange = (theme: string) => { | 23 | const themeChange = (theme: string) => { |
| 24 | - themeState.theme = getTheme(theme).type | 24 | + const themeObj = getTheme(theme) |
| 25 | - themeState.themeLabel = getTheme(themeState.theme).text | 25 | + themeState.theme = themeObj.type |
| 26 | - themeState.themeIcon = getTheme(themeState.theme).icon | 26 | + themeState.themeLabel = themeObj.text |
| 27 | + themeState.themeIcon = themeObj.icon | ||
| 27 | document.documentElement.setAttribute('data-theme', themeState.theme) | 28 | document.documentElement.setAttribute('data-theme', themeState.theme) |
| 28 | 29 | ||
| 29 | const appId = getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id | 30 | const appId = getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id |