diff --git a/src/assets/styles/sidebar.scss b/src/assets/styles/sidebar.scss index 06bf057d..e695bc62 100644 --- a/src/assets/styles/sidebar.scss +++ b/src/assets/styles/sidebar.scss @@ -81,10 +81,16 @@ } // menu hover + .theme-dark .sub-menu-title-noDropdown, + .theme-dark .el-sub-menu__title { + &:hover { + background-color: $base-sub-menu-title-hover !important; + } + } .sub-menu-title-noDropdown, .el-sub-menu__title { &:hover { - background-color: $base-sub-menu-title-hover !important; + background-color: rgba(0, 0, 0, 0.05) !important; } } @@ -95,12 +101,12 @@ & .nest-menu .el-sub-menu > .el-sub-menu__title, & .el-sub-menu .el-menu-item { min-width: $base-sidebar-width !important; - &:hover { - background-color: rgba(0, 0, 0, 0.06) !important; + background-color: rgba(0, 0, 0, 0.1) !important; } } + & .theme-dark .nest-menu .el-sub-menu > .el-sub-menu__title, & .theme-dark .el-sub-menu .el-menu-item { background-color: $base-sub-menu-background !important; @@ -109,6 +115,21 @@ background-color: $base-sub-menu-hover !important; } } + + & .theme-dark .nest-menu .el-sub-menu > .el-sub-menu__title, + & .theme-dark .el-menu-item { + &:hover { + // you can use $sub-menuHover + background-color: $base-menu-hover !important; + } + } + & .nest-menu .el-sub-menu > .el-sub-menu__title, + & .el-menu-item { + &:hover { + // you can use $sub-menuHover + background-color: rgba(0, 0, 0, 0.04) !important; + } + } } .hideSidebar { @@ -207,14 +228,6 @@ } } - .nest-menu .el-sub-menu > .el-sub-menu__title, - .el-menu-item { - &:hover { - // you can use $sub-menuHover - background-color: $base-menu-hover !important; - } - } - // the scroll bar appears when the sub-menu is too long > .el-menu--popup { max-height: 100vh; diff --git a/src/enums/SideThemeEnum.ts b/src/enums/SideThemeEnum.ts new file mode 100644 index 00000000..f172858c --- /dev/null +++ b/src/enums/SideThemeEnum.ts @@ -0,0 +1,4 @@ +export enum SideThemeEnum { + DARK = 'theme-dark', + LIGHT = 'theme-light' +} diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 8eb7921c..d5522aec 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -3,7 +3,7 @@

主题风格设置

-
+
dark
@@ -15,7 +15,7 @@
-
+
light
@@ -95,6 +95,7 @@ import usePermissionStore from '@/store/modules/permission' import { handleThemeStyle } from '@/utils/theme' import { ComponentInternalInstance } from "vue"; import { SettingTypeEnum } from "@/enums/SettingTypeEnum"; +import { SideThemeEnum } from "@/enums/SideThemeEnum"; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const appStore = useAppStore() @@ -114,6 +115,13 @@ const isDark = useDark({ valueDark: 'dark', valueLight: 'light', }); +watch(isDark, ()=> { + if (isDark.value) { + settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: SideThemeEnum.DARK }) + } else { + settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: sideTheme.value }) + } +}) const toggleDark = () => useToggle(isDark); /** 是否需要topNav */ @@ -166,8 +174,13 @@ const themeChange = (val: string | null) => { } } const handleTheme = (val: string) => { - settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: val }) sideTheme.value = val; + if (isDark.value && val === SideThemeEnum.LIGHT) { + // 暗黑模式颜色不变 + settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: SideThemeEnum.DARK }) + return + } + settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: val }) } const saveSetting = () => { proxy?.$modal.loading("正在保存到本地,请稍候..."); diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue index 1c3dcb31..fff37366 100644 --- a/src/layout/components/Sidebar/index.vue +++ b/src/layout/components/Sidebar/index.vue @@ -27,7 +27,6 @@ import variables from '@/assets/styles/variables.module.scss' import useAppStore from '@/store/modules/app' import useSettingsStore from '@/store/modules/settings' import usePermissionStore from '@/store/modules/permission' -import { ComponentInternalInstance } from "vue"; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const route = useRoute();