Skip to content

Commit 4d440c4

Browse files
committed
多级菜单字体颜色修复
1 parent 5f3075e commit 4d440c4

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/layouts/components/Menu/MenuItem.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</span>
1919
</template>
2020
</el-menu-item>
21-
<el-sub-menu :index="item.path" v-else>
21+
<el-sub-menu :class="{ 'is-black': isBlack }" :index="item.path" v-else>
2222
<template #title>
2323
<component
2424
class="menu-icon"
@@ -56,7 +56,14 @@
5656
</script>
5757

5858
<script setup>
59-
import { defineProps } from 'vue';
59+
import { defineProps, computed } from 'vue';
60+
import { useStore } from 'vuex';
61+
62+
import { themeConfig } from '@/config/theme';
63+
const { themeOptions } = themeConfig;
64+
65+
const whiteColors = ['#fff', '#ffffff', '#FFF', '#FFF', 'rgb(255, 255, 255)'];
66+
6067
defineProps({
6168
item: {
6269
type: Object,
@@ -65,6 +72,20 @@
6572
},
6673
},
6774
});
75+
76+
const store = useStore();
77+
78+
const theme = computed(() => {
79+
return store.getters['setting/theme'];
80+
});
81+
82+
const menuBgColor = computed(() => {
83+
return themeOptions[theme.value].menuBgColor;
84+
});
85+
86+
const isBlack = computed(() => {
87+
return whiteColors.indexOf(menuBgColor.value) === -1;
88+
});
6889
</script>
6990
<style lang="scss" scoped>
7091
.menu-icon,

src/layouts/components/Menu/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<Logo v-if="isLogo" />
1919
<template v-for="item in routes">
2020
<template v-if="!item.hidden">
21-
<MenuItem :item="item" :key="item.path" />
21+
<MenuItem :item="{ ...item, isBlack }" :key="item.path" />
2222
</template>
2323
</template>
2424
</el-menu>

src/styles/element-reset.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,21 @@
5252
background-color: $base-color-primary !important;
5353
}
5454
}
55+
.el-sub-menu__title{
56+
color: $base-color-3 !important;
57+
}
58+
5559
}
5660
.el-menu--horizontal.is-black{
5761
.el-sub-menu__title{
5862
color: $base-color-white !important;
5963
}
6064
}
65+
.el-sub-menu.is-black{
66+
.el-sub-menu__title{
67+
color: $base-color-white !important;
68+
}
69+
}
6170
.el-menu--collapse .el-menu-item{
6271
text-align: center;
6372
}

0 commit comments

Comments
 (0)