File tree Expand file tree Collapse file tree 6 files changed +63
-51
lines changed
Expand file tree Collapse file tree 6 files changed +63
-51
lines changed Original file line number Diff line number Diff line change 33 <!-- <el-button @click="test">测试</el-button> -->
44</template >
55<script lang="ts" setup>
6- import { useStore } from ' vuex'
76import { computed } from ' vue'
7+
8+ import { useStore } from ' vuex'
89const store = useStore ()
9- const menuBg = computed (() => store .state .theme .styles .menuBg )
10- // const test = () => {
11- // store.commit('SET_TEST')
12- // console.log(menuBg.value)
13- // }
10+
11+ const sidebarBg = computed (() => store .state .theme .styles .sidebarBg )
12+ const headerBg = computed (() => store .state .theme .styles .headerBg )
13+ const mainBg = computed (() => store .state .theme .styles .mainBg )
14+ const subMenuBg = computed (() => store .state .theme .styles .subMenuBg )
15+ const subMenuHover = computed (() => store .state .theme .styles .subMenuHover )
16+ const test = () => {
17+ store .commit (' SET_TEST' )
18+ }
1419 </script >
1520<style lang="scss">
1621#app {
17- .app-menu-bg {
18- background : v-bind (menuBg );
22+ .app-sidebar-bg {
23+ background : v-bind (sidebarBg );
24+ }
25+ .app-header-bg {
26+ background : v-bind (headerBg );
27+ }
28+ .app-main-bg {
29+ background : v-bind (mainBg );
30+ }
31+ .el-menu {
32+ .el-sub-menu {
33+ .el-menu {
34+ background : v-bind (subMenuBg );
35+ li :hover {
36+ background : v-bind (subMenuHover );
37+ }
38+ .el-sub-menu__title {
39+ background : v-bind (subMenuBg ) !important ;
40+ & :hover {
41+ background : v-bind (subMenuHover ) !important ;
42+ }
43+ }
44+ }
45+ }
1946 }
2047}
2148 </style >
Original file line number Diff line number Diff line change @@ -35,12 +35,18 @@ export interface IPermission {
3535}
3636
3737/**
38- * 主题颜色
38+ * 主题颜色、字体
3939 */
4040export interface ITheme {
4141 styles : IThemeStyles
4242}
4343export interface IThemeStyles {
44- menuBg : string
45- test : string
44+ sidebarBg : string //侧边栏背景颜色
45+ headerBg : string //头部背景颜色
46+ mainBg : string //主体内容背景颜色
47+ menuBg : string //菜单栏背景颜色
48+ menuTextColor : string //菜单栏字体颜色
49+ menuTextActiveColor : string //菜单栏选中字体颜色
50+ subMenuBg : string //子菜单栏背景颜色
51+ subMenuHover : string //子菜单栏悬浮颜色
4652}
Original file line number Diff line number Diff line change 33 * @Author: hutu
44 * @Date: 2021-12-07 08:36:02
55 * @LastEditors: hutu
6- * @LastEditTime: 2021-12-27 17:16:06
6+ * @LastEditTime: 2021-12-28 17:05:25
77-->
88<template >
99 <div class =" layout" >
10- <div class =" layout-menu app-menu -bg" :style =" { width: menuCollapse ? '64px' : '210px' }" >
10+ <div class =" layout-menu app-sidebar -bg" :style =" { width: menuCollapse ? '64px' : '210px' }" >
1111 <Sidebar :list =" accessRoutes" :route =" route.path" :collapse =" menuCollapse" />
1212 </div >
1313 <div class =" layout-main" >
14- <div class =" layout-header" >
14+ <div class =" layout-header app-header-bg " >
1515 <Navbar />
1616 </div >
17- <div class =" layout-content" >
17+ <div class =" layout-content app-main-bg " >
1818 <AppMain />
1919 </div >
2020 </div >
@@ -47,12 +47,8 @@ const accessRoutes = computed(() => store.state.permission.accessRoutes)
4747 flex : 1 ;
4848 .layout-header {
4949 height : 50px ;
50- background : $white ;
5150 border-bottom : 1px solid #eee ;
5251 }
53- .layout-content {
54- background : $baseBg ;
55- }
5652 }
5753}
5854 </style >
Original file line number Diff line number Diff line change 99 </router-view >
1010 </div >
1111</template >
12- <script lang="ts" setup>
13- const color = ' red'
14- </script >
1512<style lang="scss" scoped>
16- .text {
17- color : v-bind (color );
18- }
1913.app-main {
2014 height : calc (100vh - 51px );
2115 width : 100% ;
22- background : #f0f2f5 ;
2316 overflow : hidden ;
2417}
2518.fade-leave-active ,
Original file line number Diff line number Diff line change 33 * @Author: hutu
44 * @Date: 2021-12-07 08:36:02
55 * @LastEditors: hutu
6- * @LastEditTime: 2021-12-16 16:01:36
6+ * @LastEditTime: 2021-12-28 17:32:33
77-->
88<template >
99 <div class =" sidebar" >
10- <el-menu :background-color =" '#304156' " :text-color =" '#bfcbd9' " :active-text-color =" '#409EFF' " :default-active =" props.route" mode =" vertical" :collapse =" props.collapse" :router =" true" >
10+ <el-menu :background-color =" styles.menuBg " :text-color =" styles.menuTextColor " :active-text-color =" styles.menuTextActiveColor " :default-active =" props.route" mode =" vertical" :collapse =" props.collapse" :router =" true" >
1111 <SidebarItem :list =" props.list" :isFirst =" true" />
1212 </el-menu >
1313 </div >
1414</template >
1515
1616<script lang="ts" setup>
17- import SidebarItem from ' ./SidebarItem.vue'
17+ import { computed } from ' vue'
18+ import { useStore } from ' vuex'
1819import { RouteRecordRaw } from ' vue-router'
20+ import SidebarItem from ' ./SidebarItem.vue'
21+ const store = useStore ()
22+ const styles = computed (() => store .state .theme .styles )
1923const props = defineProps <{
2024 list: Array <RouteRecordRaw > // 路由列表
2125 route: string // 当前路由
2226 collapse: boolean // 侧边栏是否折叠
2327}>()
2428 </script >
25- <style lang="scss">
26- .sidebar {
27- .el-menu {
28- .el-sub-menu {
29- .el-menu {
30- background : $subMenuBg ;
31- li :hover {
32- background : $subMenuHover ;
33- }
34- .el-sub-menu__title {
35- background : $subMenuBg !important ;
36- & :hover {
37- background : $subMenuHover !important ;
38- }
39- }
40- }
41- }
42- }
43- }
44- </style >
Original file line number Diff line number Diff line change @@ -2,13 +2,19 @@ import { ITheme } from '@/interface'
22
33const state : ITheme = {
44 styles : {
5+ sidebarBg : '#304156' ,
6+ headerBg : '#ffffff' ,
7+ mainBg : '#f0f2f5' ,
58 menuBg : '#304156' ,
6- test : 'eee'
9+ menuTextColor : '#bfcbd9' ,
10+ menuTextActiveColor : '#409EFF' ,
11+ subMenuBg : '#1f2d3d' ,
12+ subMenuHover : '#001528'
713 }
814}
915const mutations = {
1016 SET_TEST : ( state : ITheme , flag : boolean ) : void => {
11- state . styles . menuBg = 'red'
17+ state . styles . menuTextColor = 'red'
1218 }
1319}
1420const actions = { }
You can’t perform that action at this time.
0 commit comments