From fb6e4a0041575dfacc4da9f8fc66d9a3d1f8a6b8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 19 五月 2026 15:50:40 +0800
Subject: [PATCH] feat(multiple): 为构建过程添加环境变量管理功能
---
src/layout/components/Sidebar/index.vue | 218 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 164 insertions(+), 54 deletions(-)
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 646bb63..da2a7fa 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -1,54 +1,164 @@
-<template>
- <div :class="{ 'has-logo': showLogo }" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
- <logo v-if="showLogo" :collapse="isCollapse" />
- <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper">
- <el-menu
- :default-active="activeMenu"
- :collapse="isCollapse"
- :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
- :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
- :unique-opened="true"
- :active-text-color="theme"
- :collapse-transition="false"
- mode="vertical"
- >
- <sidebar-item
- v-for="(route, index) in sidebarRouters"
- :key="route.path + index"
- :item="route"
- :base-path="route.path"
- />
- </el-menu>
- </el-scrollbar>
- </div>
-</template>
-
-<script setup>
-import Logo from './Logo'
-import SidebarItem from './SidebarItem'
-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'
-
-const route = useRoute();
-const appStore = useAppStore()
-const settingsStore = useSettingsStore()
-const permissionStore = usePermissionStore()
-
-const sidebarRouters = computed(() => permissionStore.sidebarRouters);
-const showLogo = computed(() => settingsStore.sidebarLogo);
-const sideTheme = computed(() => settingsStore.sideTheme);
-const theme = computed(() => settingsStore.theme);
-const isCollapse = computed(() => !appStore.sidebar.opened);
-
-const activeMenu = computed(() => {
- const { meta, path } = route;
- // if set path, the sidebar will highlight the path you set
- if (meta.activeMenu) {
- return meta.activeMenu;
- }
- return path;
-})
-
-</script>
+<template>
+ <div :class="{ 'has-logo': showLogo }" class="sidebar-container">
+ <logo v-if="showLogo" :collapse="isCollapse" />
+ <el-scrollbar wrap-class="scrollbar-wrapper">
+ <el-menu
+ :default-active="activeMenu"
+ :collapse="isCollapse"
+ :background-color="getMenuBackground"
+ :text-color="getMenuTextColor"
+ :unique-opened="true"
+ :active-text-color="theme"
+ :collapse-transition="false"
+ mode="vertical"
+ :class="sideTheme"
+ >
+ <sidebar-item
+ v-for="(route, index) in sidebarRouters"
+ :key="route.path + index"
+ :item="route"
+ :base-path="route.path"
+ />
+ </el-menu>
+ </el-scrollbar>
+ </div>
+</template>
+
+<script setup>
+import Logo from "./Logo";
+import SidebarItem from "./SidebarItem";
+import useAppStore from "@/store/modules/app";
+import useSettingsStore from "@/store/modules/settings";
+import usePermissionStore from "@/store/modules/permission";
+
+const route = useRoute();
+const appStore = useAppStore();
+const settingsStore = useSettingsStore();
+const permissionStore = usePermissionStore();
+
+const sidebarRouters = computed(() => permissionStore.sidebarRouters);
+const showLogo = computed(() => settingsStore.sidebarLogo);
+const sideTheme = computed(() => settingsStore.sideTheme);
+const theme = computed(() => settingsStore.theme);
+const isCollapse = computed(() => !appStore.sidebar.opened);
+
+const getMenuBackground = computed(() => "var(--sidebar-bg)");
+
+const getMenuTextColor = computed(() => "var(--sidebar-text)");
+
+const activeMenu = computed(() => {
+ const { meta, path } = route;
+ if (meta.activeMenu) return meta.activeMenu;
+ return path;
+});
+</script>
+
+<style lang="scss" scoped>
+.sidebar-container {
+ background: transparent;
+ border-radius: 0;
+ overflow: hidden;
+
+ .scrollbar-wrapper {
+ background: transparent;
+ }
+
+ .el-menu {
+ border: none !important;
+ height: 100%;
+ width: 100% !important;
+ border-radius: 0;
+ background: transparent !important;
+
+ .el-menu-item,
+ .el-sub-menu__title {
+ margin-bottom: 8px;
+ border-radius: 14px;
+ color: v-bind(getMenuTextColor);
+ font-size: 14px;
+ letter-spacing: 0;
+ transition: all 0.28s ease;
+ border: none !important;
+ display: flex;
+ align-items: center;
+
+ &:hover {
+ background: linear-gradient(128deg, rgba(var(--el-color-primary-rgb, 37, 99, 235), 0.28), rgba(var(--el-color-primary-rgb, 37, 99, 235), 0.08)) !important;
+ transform: translateX(3px);
+ }
+ }
+
+ .el-menu-item {
+ color: var(--sidebar-text);
+
+ &.is-active {
+ background: var(--menu-active-bg, linear-gradient(135deg, var(--el-color-primary), var(--el-color-primary-light-3))) !important;
+ background-size: 180% 180%;
+ color: var(--menu-active-text) !important;
+ font-weight: 500;
+ border-radius: 14px;
+ box-shadow: var(--menu-active-glow, 0 10px 24px rgba(var(--el-color-primary-rgb, 37, 99, 235), 0.34));
+ animation: sidebarActiveFlow 4.6s ease infinite;
+
+ .svg-icon {
+ color: var(--menu-active-text) !important;
+ }
+ }
+ }
+
+ .el-sub-menu__title {
+ color: v-bind(getMenuTextColor);
+ }
+
+ :deep(.el-sub-menu__icon-arrow) {
+ display: inline-flex !important;
+ align-items: center;
+ justify-content: center;
+ width: 14px;
+ height: 14px;
+ margin-top: -7px;
+ right: 14px;
+ font-size: 14px !important;
+ color: currentColor !important;
+ opacity: 0.7;
+ transition: all 0.25s ease;
+ }
+
+ :deep(.el-sub-menu.is-opened .el-sub-menu__icon-arrow) {
+ transform: rotate(180deg);
+ }
+
+ :deep(.el-sub-menu.is-active > .el-sub-menu__title) {
+ color: var(--menu-active-text) !important;
+ font-weight: 500;
+ border-radius: 12px;
+ margin: 0 12px 6px !important;
+ padding-left: 14px !important;
+ padding-right: 34px !important;
+ box-sizing: border-box;
+ overflow: hidden;
+ background-clip: padding-box;
+ background: var(--menu-active-bg) !important;
+ box-shadow: var(--menu-active-glow);
+ border: none !important;
+ }
+
+ :deep(.el-menu-item.is-active) {
+ margin: 0 12px 6px !important;
+ width: calc(100% - 24px) !important;
+ padding-left: 14px !important;
+ padding-right: 34px !important;
+ box-sizing: border-box;
+ overflow: hidden;
+ background-clip: padding-box;
+ border-radius: 12px;
+ }
+
+ :deep(.el-sub-menu.is-active > .el-sub-menu__title .menu-title),
+ :deep(.el-sub-menu.is-active > .el-sub-menu__title .svg-icon),
+ :deep(.el-menu-item.is-active .menu-title) {
+ color: var(--menu-active-text) !important;
+ }
+ }
+}
+</style>
--
Gitblit v1.9.3