diff --git a/packages/hooks/src/config/useAppConfig.ts b/packages/hooks/src/config/useAppConfig.ts index a93d5000..0f7901e1 100644 --- a/packages/hooks/src/config/useAppConfig.ts +++ b/packages/hooks/src/config/useAppConfig.ts @@ -111,14 +111,14 @@ function handlerResults( }, sidebar: { collapsed: false }, } - + //todo remove it case HandlerSettingEnum.CHANGE_THEME_COLOR: if (unref(themeColor) === value) { return {} } // changeTheme(value); return { themeColor: value } - + //todo remove it case HandlerSettingEnum.CHANGE_THEME: return { theme: value } diff --git a/packages/hooks/src/web/useTheme.ts b/packages/hooks/src/web/useTheme.ts index 7994d92f..340b5217 100644 --- a/packages/hooks/src/web/useTheme.ts +++ b/packages/hooks/src/web/useTheme.ts @@ -16,7 +16,7 @@ export function createMediaPrefersColorSchemeListen() { ) } -interface ThemeColors { +export interface ThemeColors { primaryColor?: string primaryColorHover?: string primaryColorPressed?: string @@ -42,6 +42,7 @@ interface ThemeColors { export const useAppTheme = () => { const themeStore = useThemeStore() //todo theme从themeStore里取 + const { setThemeConfig } = themeStore const { getTheme, getThemeConfig } = storeToRefs(themeStore) const { theme, baseHandler } = useAppConfig() @@ -61,6 +62,10 @@ export const useAppTheme = () => { return '' }) + const primaryColor = computed(() => { + return getThemeConfig.value.primaryColor + }) + const themeColors = computed(() => { let colors: ThemeColors = {} const themeConfig = getThemeConfig.value @@ -143,5 +148,12 @@ export const useAppTheme = () => { { deep: true }, ) - return { isDark, toggleTheme, themeColor, themeColors } + return { + isDark, + toggleTheme, + themeColor, + primaryColor, + themeColors, + setThemeConfig, + } } diff --git a/packages/layouts/src/components/setting/components/SettingDrawer.vue b/packages/layouts/src/components/setting/components/SettingDrawer.vue index fd8e31de..042ec785 100644 --- a/packages/layouts/src/components/setting/components/SettingDrawer.vue +++ b/packages/layouts/src/components/setting/components/SettingDrawer.vue @@ -15,15 +15,18 @@ import { import { context } from '../../../../bridge' import { navigationBarTypeList } from '../constant' import { useI18n } from '@vben/locale' +import { useAppTheme } from '@vben/hooks' const { useAppConfig } = context const { baseHandler } = useAppConfig() +const { primaryColor } = useAppTheme() + const { t } = useI18n() const { useMenuSetting, useHeaderSetting, useRootSetting } = context -const { getShowDarkModeToggle, getThemeColor } = useRootSetting() +const { getShowDarkModeToggle } = useRootSetting() const { getIsHorizontal, getMenuType, getMenuBgColor } = useMenuSetting() const { getHeaderBgColor } = useHeaderSetting() @@ -67,7 +70,7 @@ const onVisible = (show: boolean) => { t('layout.setting.sysTheme') }} diff --git a/packages/layouts/src/components/setting/components/ThemeColorPicker.vue b/packages/layouts/src/components/setting/components/ThemeColorPicker.vue index 6ebe5ed7..0ed73742 100644 --- a/packages/layouts/src/components/setting/components/ThemeColorPicker.vue +++ b/packages/layouts/src/components/setting/components/ThemeColorPicker.vue @@ -1,9 +1,8 @@