fix: useTheme use single ref (#21)

This commit is contained in:
a-leaf 2022-10-21 11:25:06 +08:00 committed by GitHub
parent f3fd669cad
commit 12cb7cfcc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,8 +9,6 @@ interface IThemeList {
/** 注册的主题名称, 其中 normal 是必填的 */
export type ThemeName = "normal" | "dark"
/** 主题 hook */
export function useTheme() {
/** 主题列表 */
const themeList: IThemeList[] = [
{
@ -22,6 +20,7 @@ export function useTheme() {
name: "dark"
}
]
/** 正在应用的主题名称 */
const activeThemeName = ref<ThemeName>(getActiveThemeName() || "normal")
@ -40,5 +39,7 @@ export function useTheme() {
document.documentElement.className = value
}
/** 主题 hook */
export function useTheme() {
return { themeList, activeThemeName, initTheme, setTheme }
}