fix:抽离首页主题设置成hooks

This commit is contained in:
MTrun
2021-12-20 16:13:26 +08:00
parent d388bea7bd
commit 45884a2918
5 changed files with 52 additions and 40 deletions
+1
View File
@@ -0,0 +1 @@
export * from '@/hooks/themeHook'
+42
View File
@@ -0,0 +1,42 @@
import { computed } from 'vue'
import { darkTheme, GlobalThemeOverrides } from 'naive-ui'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { borderRadius } from '@/settings/designSetting'
/**
* 设置全局主题
*/
export const getThemeOverridesHook = () => {
const designStore = useDesignStore()
const getDarkTheme = computed(
(): GlobalThemeOverrides => {
const commonObj = {
common: {
borderRadius
}
}
const lightObject = {
common: {
...commonObj.common
}
}
const dartObject = {
common: {
primaryColor: designStore.appTheme,
...commonObj.common
},
LoadingBar: {
colorLoading: designStore.appTheme
}
}
return designStore.getDarkTheme ? dartObject : lightObject
}
)
return getDarkTheme
}
// 返回暗黑主题
export const getDarkThemeHook = () => {
const designStore = useDesignStore()
return computed(() => (designStore.getDarkTheme ? darkTheme : undefined))
}