From b51e370a4f471a7cc96fe1a700acd9a71c0ee21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E7=99=BD=E8=B5=B7?= <313720641@qq.com> Date: Thu, 23 Jan 2025 18:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ui):=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BE=A7=E8=BE=B9=E6=A0=8F=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E9=A2=9C=E8=89=B2,=E5=A2=9E=E5=8A=A0=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E8=89=B2=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/assets/styles/sidebar.scss | 22 ++--- src/assets/styles/variables.module.scss | 2 + src/layout/components/Settings/index.vue | 115 ++++++++--------------- src/layout/components/Sidebar/Logo.vue | 40 ++++++-- src/layout/components/Sidebar/index.vue | 35 +++++-- src/settings.ts | 15 ++- src/utils/sideTheme.ts | 60 ++++++++++++ 8 files changed, 184 insertions(+), 106 deletions(-) create mode 100644 src/utils/sideTheme.ts diff --git a/package.json b/package.json index caac7c0..f2838ae 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "vue-json-pretty": "2.4.0", "vue-router": "4.4.5", "vue-types": "5.1.3", + "vue3-colorpicker": "^2.3.0", "vxe-table": "4.5.22" }, "devDependencies": { diff --git a/src/assets/styles/sidebar.scss b/src/assets/styles/sidebar.scss index d85da55..080cda6 100644 --- a/src/assets/styles/sidebar.scss +++ b/src/assets/styles/sidebar.scss @@ -14,7 +14,7 @@ -webkit-transition: width 0.28s; transition: width 0.28s; width: $base-sidebar-width !important; - background-color: $base-menu-background; + background: $gradient-menu-background; // 将渐变色应用到侧边栏容器 height: 100%; position: fixed; font-size: 0; @@ -70,6 +70,7 @@ border: none; height: 100%; width: 100% !important; + background: transparent !important; // 让菜单背景透明,继承父容器渐变色 } .el-menu-item, @@ -77,6 +78,7 @@ overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; + background: transparent !important; // 让菜单项背景透明,继承父容器渐变色 } .el-menu-item .el-menu-tooltip__trigger { @@ -87,13 +89,13 @@ .theme-dark .sub-menu-title-noDropdown, .theme-dark .el-sub-menu__title { &:hover { - background-color: $base-sub-menu-title-hover !important; + background-color: rgba(255, 255, 255, 0.1) !important; // 使用半透明背景色 } } .sub-menu-title-noDropdown, .el-sub-menu__title { &:hover { - background-color: rgba(0, 0, 0, 0.05) !important; + background-color: rgba(0, 0, 0, 0.05) !important; // 使用半透明背景色 } } @@ -105,31 +107,29 @@ & .el-sub-menu .el-menu-item { min-width: $base-sidebar-width !important; &:hover { - background-color: rgba(0, 0, 0, 0.1) !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; + background-color: transparent !important; // 让菜单项背景透明,继承父容器渐变色 &:hover { - background-color: $base-sub-menu-hover !important; + background-color: rgba(255, 255, 255, 0.1) !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; + background-color: rgba(255, 255, 255, 0.1) !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; + background-color: rgba(0, 0, 0, 0.04) !important; // 使用半透明背景色 } } } @@ -229,4 +229,4 @@ margin-right: 16px; } } -} +} \ No newline at end of file diff --git a/src/assets/styles/variables.module.scss b/src/assets/styles/variables.module.scss index 3aa871b..4621f9f 100644 --- a/src/assets/styles/variables.module.scss +++ b/src/assets/styles/variables.module.scss @@ -113,6 +113,8 @@ $--color-danger: #f56c6c; $--color-info: #909399; $base-sidebar-width: 200px; +// 默认渐变色 +$gradient-menu-background: linear-gradient(to top, #12c2e9, #c471ed, #f64f59); // the :export directive is the magic sauce for webpack // https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 3082beb..1f85442 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -1,32 +1,17 @@