Преглед изворни кода

新增暗色菜单风格主题

RuoYi пре 4 година
родитељ
комит
655249d67a

+ 10 - 10
ruoyi-ui/src/assets/styles/sidebar.scss

@@ -3,15 +3,15 @@
3 3
   .main-container {
4 4
     min-height: 100%;
5 5
     transition: margin-left .28s;
6
-    margin-left: $sideBarWidth;
6
+    margin-left: $base-sidebar-width;
7 7
     position: relative;
8 8
   }
9 9
 
10 10
   .sidebar-container {
11 11
     -webkit-transition: width .28s;
12 12
     transition: width 0.28s;
13
-    width: $sideBarWidth !important;
14
-    background-color: $menuBg;
13
+    width: $base-sidebar-width !important;
14
+    background-color: $base-menu-background;
15 15
     height: 100%;
16 16
     position: fixed;
17 17
     font-size: 0px;
@@ -81,12 +81,12 @@
81 81
     }
82 82
 
83 83
     & .theme-dark .is-active > .el-submenu__title {
84
-      color: $subMenuActiveText !important;
84
+      color: $base-menu-color-active !important;
85 85
     }
86 86
 
87 87
     & .nest-menu .el-submenu>.el-submenu__title,
88 88
     & .el-submenu .el-menu-item {
89
-      min-width: $sideBarWidth !important;
89
+      min-width: $base-sidebar-width !important;
90 90
 
91 91
       &:hover {
92 92
         background-color: rgba(0, 0, 0, 0.06) !important;
@@ -95,10 +95,10 @@
95 95
 
96 96
     & .theme-dark .nest-menu .el-submenu>.el-submenu__title,
97 97
     & .theme-dark .el-submenu .el-menu-item {
98
-      background-color: $subMenuBg !important;
98
+      background-color: $base-sub-menu-background !important;
99 99
 
100 100
       &:hover {
101
-        background-color: $subMenuHover !important;
101
+        background-color: $base-sub-menu-hover !important;
102 102
       }
103 103
     }
104 104
   }
@@ -154,7 +154,7 @@
154 154
   }
155 155
 
156 156
   .el-menu--collapse .el-menu .el-submenu {
157
-    min-width: $sideBarWidth !important;
157
+    min-width: $base-sidebar-width !important;
158 158
   }
159 159
 
160 160
   // mobile responsive
@@ -165,14 +165,14 @@
165 165
 
166 166
     .sidebar-container {
167 167
       transition: transform .28s;
168
-      width: $sideBarWidth !important;
168
+      width: $base-sidebar-width !important;
169 169
     }
170 170
 
171 171
     &.hideSidebar {
172 172
       .sidebar-container {
173 173
         pointer-events: none;
174 174
         transition-duration: 0.3s;
175
-        transform: translate3d(-$sideBarWidth, 0, 0);
175
+        transform: translate3d(-$base-sidebar-width, 0, 0);
176 176
       }
177 177
     }
178 178
   }

+ 35 - 25
ruoyi-ui/src/assets/styles/variables.scss

@@ -8,37 +8,47 @@ $tiffany: #4AB7BD;
8 8
 $yellow:#FEC171;
9 9
 $panGreen: #30B08F;
10 10
 
11
-// sidebar
12
-$menuText:#bfcbd9;
13
-$menuActiveText:#409EFF;
14
-$subMenuActiveText:#f4f4f5; // https://github.com/ElemeFE/element/issues/12951
11
+// 默认菜单主题风格
12
+$base-menu-color:#bfcbd9;
13
+$base-menu-color-active:#f4f4f5;
14
+$base-menu-background:#304156;
15
+$base-logo-title-color: #ffffff;
15 16
 
16
-$menuBg:#304156;
17
-$menuHover:#263445;
18
-$sidebarTitle: #ffffff;
17
+$base-menu-light-color:rgba(0,0,0,.70);
18
+$base-menu-light-background:#ffffff;
19
+$base-logo-light-title-color: #001529;
19 20
 
20
-$menuLightBg:#ffffff;
21
-$menuLightHover:#f0f1f5;
22
-$sidebarLightTitle: #001529;
21
+$base-sub-menu-background:#1f2d3d;
22
+$base-sub-menu-hover:#001528;
23 23
 
24
-$subMenuBg:#1f2d3d;
25
-$subMenuHover:#001528;
24
+// 自定义暗色菜单风格
25
+/**
26
+$base-menu-color:hsla(0,0%,100%,.65);
27
+$base-menu-color-active:#fff;
28
+$base-menu-background:#001529;
29
+$base-logo-title-color: #ffffff;
26 30
 
27
-$sideBarWidth: 200px;
31
+$base-menu-light-color:rgba(0,0,0,.70);
32
+$base-menu-light-background:#ffffff;
33
+$base-logo-light-title-color: #001529;
34
+
35
+$base-sub-menu-background:#000c17;
36
+$base-sub-menu-hover:#001528;
37
+*/
38
+
39
+$base-sidebar-width: 200px;
28 40
 
29 41
 // the :export directive is the magic sauce for webpack
30 42
 // https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
31 43
 :export {
32
-  menuText: $menuText;
33
-  menuActiveText: $menuActiveText;
34
-  subMenuActiveText: $subMenuActiveText;
35
-  menuBg: $menuBg;
36
-  menuHover: $menuHover;
37
-  menuLightBg: $menuLightBg;
38
-  menuLightHover: $menuLightHover;
39
-  subMenuBg: $subMenuBg;
40
-  subMenuHover: $subMenuHover;
41
-  sideBarWidth: $sideBarWidth;
42
-  sidebarTitle: $sidebarTitle;
43
-  sidebarLightTitle: $sidebarLightTitle
44
+  menuColor: $base-menu-color;
45
+  menuLightColor: $base-menu-light-color;
46
+  menuColorActive: $base-menu-color-active;
47
+  menuBackground: $base-menu-background;
48
+  menuLightBackground: $base-menu-light-background;
49
+  subMenuBackground: $base-sub-menu-background;
50
+  subMenuHover: $base-sub-menu-hover;
51
+  sideBarWidth: $base-sidebar-width;
52
+  logoTitleColor: $base-logo-title-color;
53
+  logoLightTitleColor: $base-logo-light-title-color
44 54
 }

+ 3 - 3
ruoyi-ui/src/layout/components/Sidebar/Logo.vue

@@ -1,13 +1,13 @@
1 1
 <template>
2
-  <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
2
+  <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
3 3
     <transition name="sidebarLogoFade">
4 4
       <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
5 5
         <img v-if="logo" :src="logo" class="sidebar-logo" />
6
-        <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
6
+        <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
7 7
       </router-link>
8 8
       <router-link v-else key="expand" class="sidebar-logo-link" to="/">
9 9
         <img v-if="logo" :src="logo" class="sidebar-logo" />
10
-        <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
10
+        <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
11 11
       </router-link>
12 12
     </transition>
13 13
   </div>

+ 3 - 3
ruoyi-ui/src/layout/components/Sidebar/index.vue

@@ -1,12 +1,12 @@
1 1
 <template>
2
-    <div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
2
+    <div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
3 3
         <logo v-if="showLogo" :collapse="isCollapse" />
4 4
         <el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
5 5
             <el-menu
6 6
                 :default-active="activeMenu"
7 7
                 :collapse="isCollapse"
8
-                :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
9
-                :text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
8
+                :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
9
+                :text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
10 10
                 :unique-opened="true"
11 11
                 :active-text-color="settings.theme"
12 12
                 :collapse-transition="false"

+ 2 - 2
ruoyi-ui/src/layout/index.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div :class="classObj" class="app-wrapper" :style="{'--current-color': theme}">
3 3
     <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
4
-    <sidebar class="sidebar-container" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }" />
4
+    <sidebar class="sidebar-container"/>
5 5
     <div :class="{hasTagsView:needTagsView}" class="main-container">
6 6
       <div :class="{'fixed-header':fixedHeader}">
7 7
         <navbar />
@@ -93,7 +93,7 @@ export default {
93 93
     top: 0;
94 94
     right: 0;
95 95
     z-index: 9;
96
-    width: calc(100% - #{$sideBarWidth});
96
+    width: calc(100% - #{$base-sidebar-width});
97 97
     transition: width 0.28s;
98 98
   }
99 99