update TopNav切换

This commit is contained in:
不做码农 2022-05-21 13:29:58 +08:00
parent 945f764249
commit 8e2cebc402
2 changed files with 12 additions and 10 deletions

View File

@ -1,5 +1,11 @@
<template>
<el-menu :default-active="activeMenu" :active-text-color="theme" mode="horizontal" background-color="transparent" @select="handleSelect" :ellipsis="false">
<el-menu
:default-active="activeMenu"
:active-text-color="theme"
mode="horizontal"
background-color="transparent"
@select="handleSelect"
:ellipsis="false">
<template v-for="(item, index) in topMenus">
<el-menu-item :style="{ '--theme': theme }" :index="item.path" :key="index" v-if="index < visibleNumber">
<svg-icon :name="item.meta.icon" />
@ -24,6 +30,7 @@
import { constantRoutes } from '@/router'
import { isHttp } from '@/utils/validate'
import { useRouter } from 'vue-router'
import { getNormalPath } from '@/utils/ruoyi'
//
const visibleNumber = ref(5)
@ -64,10 +71,10 @@ const childrenMenus = computed(() => {
for (let item in router.children) {
if (router.children[item].parentPath === undefined) {
if (router.path === '/') {
router.children[item].path = '/redirect/' + router.children[item].path
router.children[item].path = getNormalPath('/redirect/' + router.children[item].path)
} else {
if (!isHttp(router.children[item].path)) {
router.children[item].path = router.path + '/' + router.children[item].path
router.children[item].path = getNormalPath(router.path + '/' + router.children[item].path)
}
}
router.children[item].parentPath = router.path
@ -96,7 +103,6 @@ const activeMenu = computed(() => {
if (routes.length === 0) {
activePath = currentIndex.value || defaultRouter.value
console.log('activePath', activePath)
activeRoutes(activePath)
}
return activePath
@ -170,12 +176,6 @@ onMounted(() => {
.el-menu--horizontal > .el-menu-item .svg-icon {
margin-right: 5px;
}
// .topmenu-container.el-menu--horizontal > .el-menu-item.is-active,
// .el-menu--horizontal > .el-sub-menu.is-active .el-submenu__title {
// border-bottom: 0px solid #{"var(--theme)"} !important;
// color: #303133;
// }
/* sub-menu item */
.topmenu-container.el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
height: 50px !important;

View File

@ -124,6 +124,8 @@ const topNav = computed({
if (!val) {
store.dispatch('app/toggleSideBarHide', false)
store.commit('SET_SIDEBAR_ROUTERS', store.state.permission.defaultRoutes)
// TODO topnav
setTimeout('window.location.reload()', 100)
}
},
})