From 5656760940ab8c8722642f063a83b49617720e6d Mon Sep 17 00:00:00 2001 From: lostelk Date: Sat, 8 Feb 2025 16:38:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(Menu):=20:recycle:=20=E6=B5=85?= =?UTF-8?q?=E8=89=B2=E4=B8=BB=E9=A2=98Menu=E8=89=B2=E7=B3=BB=E6=90=AD?= =?UTF-8?q?=E9=85=8D=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.浅色主题下以白色背景为核心默认使用el-element浅色系配色。 2.浅色主题下支持悬浮、选中状态颜色根据主题色变化。3.修改浅色主题的侧边栏logo文字颜色。 # #182 --- .../components/NavBar/components/NavbarRight.vue | 5 ----- .../Sidebar/components/SidebarLogo.vue | 2 +- .../Sidebar/components/SidebarMenu.vue | 10 +++++++--- .../Sidebar/components/SidebarMenuItem.vue | 6 ++++-- .../Sidebar/components/SidebarMixTopMenu.vue | 12 ++++++++---- src/styles/variables.scss | 16 +++++++++++----- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/layout/components/NavBar/components/NavbarRight.vue b/src/layout/components/NavBar/components/NavbarRight.vue index c4ad28ac..b53bd0d7 100644 --- a/src/layout/components/NavBar/components/NavbarRight.vue +++ b/src/layout/components/NavBar/components/NavbarRight.vue @@ -70,9 +70,4 @@ const isMobile = computed(() => appStore.device === DeviceEnum.MOBILE); .dark .navbar__right > *:hover { background: rgb(255 255 255 / 20%); } - -.layout-top .navbar__right > *, -.layout-mix .navbar__right > * { - color: #fff; -} diff --git a/src/layout/components/Sidebar/components/SidebarLogo.vue b/src/layout/components/Sidebar/components/SidebarLogo.vue index 2c72e50d..420afc1e 100644 --- a/src/layout/components/Sidebar/components/SidebarLogo.vue +++ b/src/layout/components/Sidebar/components/SidebarLogo.vue @@ -34,7 +34,7 @@ defineProps({ margin-left: 10px; font-size: 14px; font-weight: bold; - color: white; + color: $sidebar-logo-text-color; } } diff --git a/src/layout/components/Sidebar/components/SidebarMenu.vue b/src/layout/components/Sidebar/components/SidebarMenu.vue index 828e7bb2..0701ef65 100644 --- a/src/layout/components/Sidebar/components/SidebarMenu.vue +++ b/src/layout/components/Sidebar/components/SidebarMenu.vue @@ -4,9 +4,10 @@ ref="menuRef" :default-active="currentRoute.path" :collapse="!appStore.sidebar.opened" - :background-color="variables['menu-background']" - :text-color="variables['menu-text']" - :active-text-color="variables['menu-active-text']" + :background-color="theme === 'dark' ? variables['menu-background'] : undefined" + :text-color="theme === 'dark' ? variables['menu-text'] : undefined" + :active-text-color="theme === 'dark' ? variables['menu-active-text'] : undefined" + :popper-effect="theme" :unique-opened="false" :collapse-transition="false" :mode="menuMode" @@ -59,6 +60,9 @@ const menuMode = computed(() => { return settingsStore.layout === LayoutEnum.TOP ? "horizontal" : "vertical"; }); +// 获取主题 +const theme = computed(() => settingsStore.theme); + /** * 获取完整路径 * diff --git a/src/layout/components/Sidebar/components/SidebarMenuItem.vue b/src/layout/components/Sidebar/components/SidebarMenuItem.vue index 329a9b8f..35579937 100644 --- a/src/layout/components/Sidebar/components/SidebarMenuItem.vue +++ b/src/layout/components/Sidebar/components/SidebarMenuItem.vue @@ -187,7 +187,9 @@ function resolvePath(routePath: string) { } } -.el-menu-item:hover { - background-color: $menu-hover; +html.dark { + .el-menu-item:hover { + background-color: $menu-hover; + } } diff --git a/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue b/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue index be2097ca..613ed94a 100644 --- a/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue +++ b/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue @@ -4,9 +4,9 @@ @@ -32,7 +32,7 @@ * 导入模块:先外部库,再内部模块,最后导入样式和工具类 */ import { LocationQueryRaw, RouteRecordRaw } from "vue-router"; -import { usePermissionStore, useAppStore } from "@/store"; +import { usePermissionStore, useAppStore, useSettingsStore } from "@/store"; import { translateRouteTitle } from "@/utils/i18n"; import variables from "@/styles/variables.module.scss"; @@ -42,10 +42,14 @@ import variables from "@/styles/variables.module.scss"; const router = useRouter(); const appStore = useAppStore(); const permissionStore = usePermissionStore(); +const settingsStore = useSettingsStore(); // 当前激活的顶部菜单路径 const activePath = computed(() => appStore.activeTopMenuPath); +// 获取主题 +const theme = computed(() => settingsStore.theme); + // 顶部菜单列表 const topMenus = ref([]); diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 7948a7c6..96c09235 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -25,11 +25,15 @@ /** 全局SCSS变量 */ :root { - --menu-background: #304156; - --menu-text: #bfcbd9; - --menu-active-text: var(--el-menu-active-color); - --menu-hover: #263445; - --sidebar-logo-background: #2d3748; + --menu-background: #fff; + --menu-text: #212121; // 菜单文字颜色 浅色模式下仅占位,实际颜色由 el-menu-item 组件决定 + --menu-active-text: var( + --el-menu-active-color + ); // 菜单激活文字颜色 浅色模式下仅占位,实际颜色由 el-menu-item 组件决定 + + --menu-hover: #e6f4ff; // 菜单悬停背景色 浅色模式下仅占位,实际颜色由 el-menu-item 组件决定 + --sidebar-logo-background: #f5f5f5; + --sidebar-logo-text-color: #333; // 修复表格 fixed 列被选中后由于透明色导致叠字的 bug .el-table { @@ -44,6 +48,7 @@ html.dark { --menu-active-text: var(--el-menu-active-color); --menu-hover: rgb(0 0 0 / 20%); --sidebar-logo-background: rgb(0 0 0 / 20%); + --sidebar-logo-text-color: #fff; } $menu-background: var(--menu-background); // 菜单背景色 @@ -51,6 +56,7 @@ $menu-text: var(--menu-text); // 菜单文字颜色 $menu-active-text: var(--menu-active-text); // 菜单激活文字颜色 $menu-hover: var(--menu-hover); // 菜单悬停背景色 $sidebar-logo-background: var(--sidebar-logo-background); // 侧边栏 Logo 背景色 +$sidebar-logo-text-color: var(--sidebar-logo-text-color); // 侧边栏 Logo 文字颜色 $sidebar-width: 210px; // 侧边栏宽度 $sidebar-width-collapsed: 54px; // 侧边栏收缩宽度 From d6de05a4b7c5636a46307cca8130e95e7962d8c8 Mon Sep 17 00:00:00 2001 From: lostelk Date: Wed, 19 Feb 2025 12:45:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B5=85=E8=89=B2=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84=E4=BE=A7?= =?UTF-8?q?=E8=BE=B9=E6=A0=8F=E9=85=8D=E8=89=B2=E5=88=87=E6=8D=A2=EF=BC=9A?= =?UTF-8?q?=E6=B7=B1=E8=93=9D=E8=89=B2=E3=80=81=E7=99=BD=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/enums/ThemeEnum.ts | 14 +++++++++ src/lang/package/en.ts | 3 ++ src/lang/package/zh-cn.ts | 3 ++ .../NavBar/components/NavbarRight.vue | 20 ++++++++++++- src/layout/components/Settings/index.vue | 19 +++++++++++- .../Sidebar/components/SidebarMenu.vue | 22 ++++++++++++-- .../Sidebar/components/SidebarMenuItem.vue | 6 ++++ .../Sidebar/components/SidebarMixTopMenu.vue | 22 ++++++++++++-- src/settings.ts | 2 ++ src/store/modules/settings.ts | 30 +++++++++++++++++-- src/styles/variables.scss | 23 +++++++++----- src/types/global.d.ts | 2 ++ src/utils/theme.ts | 20 +++++++++++++ 13 files changed, 169 insertions(+), 17 deletions(-) diff --git a/src/enums/ThemeEnum.ts b/src/enums/ThemeEnum.ts index 91458e16..6d2ad192 100644 --- a/src/enums/ThemeEnum.ts +++ b/src/enums/ThemeEnum.ts @@ -16,3 +16,17 @@ export const enum ThemeEnum { */ AUTO = "auto", } + +/** + * 浅色主题下的侧边栏配色方案枚举 + */ +export const enum SidebarLightThemeEnum { + /** + * 深蓝色 + */ + DARKBLUE = "light-darkBlue", + /** + * 白色 + */ + WHITE = "light-white", +} diff --git a/src/lang/package/en.ts b/src/lang/package/en.ts index 3b062127..446e4c75 100644 --- a/src/lang/package/en.ts +++ b/src/lang/package/en.ts @@ -57,6 +57,9 @@ export default { themeColor: "Theme Color", tagsView: "Tags View", sidebarLogo: "Sidebar Logo", + sidebarColorScheme: "Sidebar Color Scheme", watermark: "Watermark", + white: "white", + darkBlue: "darkBlue", }, }; diff --git a/src/lang/package/zh-cn.ts b/src/lang/package/zh-cn.ts index 0b48e4a3..4ad0f150 100644 --- a/src/lang/package/zh-cn.ts +++ b/src/lang/package/zh-cn.ts @@ -57,6 +57,9 @@ export default { themeColor: "主题颜色", tagsView: "开启 Tags-View", sidebarLogo: "侧边栏 Logo", + sidebarColorScheme: "侧边栏配色方案", watermark: "开启水印", + white: "白色", + darkBlue: "深蓝色", }, }; diff --git a/src/layout/components/NavBar/components/NavbarRight.vue b/src/layout/components/NavBar/components/NavbarRight.vue index b53bd0d7..959573f4 100644 --- a/src/layout/components/NavBar/components/NavbarRight.vue +++ b/src/layout/components/NavBar/components/NavbarRight.vue @@ -1,5 +1,5 @@