mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 10:57:26 +08:00
直播功能菜单调整
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
<el-menu
|
||||
:key="currNav"
|
||||
:key="`${currNav}-${activeMenuName}`"
|
||||
class="sub-menu"
|
||||
:default-active="$route.name"
|
||||
:default-active="activeMenuName"
|
||||
@select="changeMenu"
|
||||
>
|
||||
<template v-for="item in menuList" :key="item.id">
|
||||
@@ -45,6 +45,19 @@ export default {
|
||||
currNav() {
|
||||
return this.$store.state.app.currNav;
|
||||
},
|
||||
activeMenuName() {
|
||||
const route = this.$route;
|
||||
const routePath = util.normalizeRoutePath(route.path);
|
||||
for (const item of this.menuList) {
|
||||
for (const menu of item.children || []) {
|
||||
const menuPath = util.normalizeRoutePath(menu.path);
|
||||
if (menu.name === route.name || (menuPath && menuPath === routePath)) {
|
||||
return menu.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return route.name;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
$route(val) {
|
||||
@@ -63,6 +76,12 @@ export default {
|
||||
this.$router.push({ name });
|
||||
return;
|
||||
}
|
||||
const menu = this.findMenuByName(name);
|
||||
if (menu?.path) {
|
||||
const path = menu.path.startsWith("/") ? menu.path : `/${menu.path}`;
|
||||
this.$router.push({ path });
|
||||
return;
|
||||
}
|
||||
util.initRouter(this);
|
||||
this.$nextTick(() => {
|
||||
if (this.$router.hasRoute(name)) {
|
||||
@@ -72,6 +91,16 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
findMenuByName(name) {
|
||||
for (const item of this.menuList) {
|
||||
for (const menu of item.children || []) {
|
||||
if (menu.name === name) {
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
selectNav(name) {
|
||||
this.$store.commit("setCurrNav", name);
|
||||
this.setStore("currNav", name);
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import util from "@/libs/util.js";
|
||||
|
||||
export default {
|
||||
name: "tagsPageOpened",
|
||||
props: {
|
||||
@@ -66,9 +68,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
isActive(item) {
|
||||
return item.children
|
||||
? item.children[0].name === this.currentPageName
|
||||
: item.name === this.currentPageName;
|
||||
const target = item.children ? item.children[0] : item;
|
||||
return util.isSameRoutePage(target, {
|
||||
name: this.currentPageName,
|
||||
path: this.$route.path,
|
||||
});
|
||||
},
|
||||
tagType(item) {
|
||||
return this.isActive(item) ? "primary" : "info";
|
||||
@@ -104,12 +108,25 @@ export default {
|
||||
}
|
||||
},
|
||||
linkTo(item) {
|
||||
if (this.$route.name === item.name) return;
|
||||
const target = item.children ? item.children[0] : item;
|
||||
if (util.isSameRoutePage(target, this.$route)) return;
|
||||
if (!this.beforePush(item)) return;
|
||||
|
||||
const routerObj = { name: item.name };
|
||||
if (item.argu) routerObj.params = item.argu;
|
||||
if (item.query) routerObj.query = item.query;
|
||||
if (this.beforePush(item)) {
|
||||
|
||||
if (item.name && this.$router.hasRoute(item.name)) {
|
||||
this.$router.push(routerObj);
|
||||
return;
|
||||
}
|
||||
|
||||
const path = target.path || item.path;
|
||||
if (path) {
|
||||
this.$router.push({
|
||||
path: path.startsWith("/") ? path : `/${path}`,
|
||||
query: item.query,
|
||||
});
|
||||
}
|
||||
},
|
||||
handlescroll(e) {
|
||||
|
||||
Reference in New Issue
Block a user