refactor: 将多主题功能从 pinia 抽离为 hook

This commit is contained in:
pany
2022-10-17 15:04:27 +08:00
parent e41d1f21a5
commit 281a7bebbf
6 changed files with 54 additions and 53 deletions

View File

@@ -1,17 +1,12 @@
<script lang="ts" setup>
import { computed } from "vue"
import { useAppStore } from "@/store/modules/app"
import themeList from "@/config/theme"
import type { ThemeName } from "@/config/theme"
import { useTheme } from "@/hooks/useTheme"
import type { ThemeName } from "@/hooks/useTheme"
import { MagicStick } from "@element-plus/icons-vue"
const appStore = useAppStore()
const { themeList, activeThemeName, setTheme } = useTheme()
const activeThemeName = computed(() => {
return appStore.activeThemeName
})
const handleSetTheme = (name: ThemeName) => {
appStore.setTheme(name)
setTheme(name)
}
</script>