mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { computed, toRefs } from 'vue'
|
|
import { darkTheme, GlobalThemeOverrides } from 'naive-ui'
|
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
|
import { borderRadius } from '@/settings/designSetting'
|
|
import { alpha, lighten } from '@/utils'
|
|
|
|
/**
|
|
* * 设置全局主题
|
|
*/
|
|
export const useThemeOverridesHook = () => {
|
|
const designStore = useDesignStore()
|
|
const { getAppTheme } = toRefs(designStore)
|
|
const darkTheme = computed(
|
|
(): GlobalThemeOverrides => {
|
|
// 通用
|
|
const commonObj = {
|
|
common: {
|
|
primaryColor: getAppTheme.value,
|
|
primaryColorHover: lighten(alpha(getAppTheme.value), 0.1),
|
|
primaryColorPressed: lighten(alpha(getAppTheme.value), 0.1),
|
|
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))
|
|
}
|