mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 抽离update hook
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { computed, toRefs } from 'vue'
|
||||
import { darkTheme, GlobalThemeOverrides } from 'naive-ui'
|
||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||
import { borderRadius } from '@/settings/designSetting'
|
||||
import { toLight } from '@/utils'
|
||||
|
||||
/**
|
||||
* 设置全局主题
|
||||
*/
|
||||
export const useThemeOverridesHook = () => {
|
||||
const designStore = useDesignStore()
|
||||
const { getAppTheme } = toRefs(designStore)
|
||||
const darkTheme = computed(
|
||||
(): GlobalThemeOverrides => {
|
||||
// 通用
|
||||
const commonObj = {
|
||||
common: {
|
||||
primaryColor: getAppTheme.value,
|
||||
primaryColorHover: toLight(getAppTheme.value, 6),
|
||||
primaryColorPressed: toLight(getAppTheme.value, 6),
|
||||
primaryColorSuppl: getAppTheme.value,
|
||||
borderRadius
|
||||
}
|
||||
}
|
||||
// 亮色主题
|
||||
const lightObject = {
|
||||
common: {
|
||||
...commonObj.common
|
||||
}
|
||||
}
|
||||
// 暗色主题
|
||||
const dartObject = {
|
||||
common: {
|
||||
...commonObj.common
|
||||
},
|
||||
LoadingBar: {
|
||||
colorLoading: getAppTheme.value
|
||||
}
|
||||
}
|
||||
return designStore.getDarkTheme ? dartObject : lightObject
|
||||
}
|
||||
)
|
||||
return darkTheme
|
||||
}
|
||||
|
||||
// 返回暗黑主题
|
||||
export const useDarkThemeHook = () => {
|
||||
const designStore = useDesignStore()
|
||||
return computed(() => (designStore.getDarkTheme ? darkTheme : undefined))
|
||||
}
|
||||
Reference in New Issue
Block a user