Browse Source

fix: 修改默认打开一张图

sy-water-data-board-ui
panyuyi 1 month ago
parent
commit
dc95fb3b1f
  1. 10
      src/layout/components/Navbar.vue
  2. 36
      src/store/modules/permission.js
  3. 4
      vue.config.js

10
src/layout/components/Navbar.vue

@ -146,9 +146,16 @@ export default {
}
}
},
mounted() {
if (!this.selectTab) {
let res = this.newTopMenus.find((v) => v.label === "一张图");
if (res) {
this.handleSelectTab(res);
}
}
},
methods: {
handleSelectTab(e) {
console.log("handleSelectTab >>> ", e);
sessionStorage.setItem("topTab", e.value);
this.$store.dispatch("changeTopTab", e.value);
if (e.value === "sluice") {
@ -166,7 +173,6 @@ export default {
},
});
} else if (e.label === "一张图") {
console.log("e >>> ", e);
if (
typeof e.component === "string" &&
e.component.toLowerCase() === "iframe"

36
src/store/modules/permission.js

@ -19,7 +19,7 @@ const permission = {
routes: [],
addRoutes: [],
originRoutes: [],
selectTab: sessionStorage.getItem("topTab") || "dike",
selectTab: sessionStorage.getItem("topTab") || "",
namesJumpMenu: [], // 跳转菜单
},
mutations: {
@ -164,6 +164,7 @@ const permission = {
// 切换tab
changeTopTab({ commit, dispatch }, payload) {
console.log("payload >>>>> ", payload);
commit("SET_SELECT_TAB", payload);
dispatch("changeRoutes");
},
@ -199,30 +200,37 @@ function filterAsyncRouter(asyncRouterMap) {
function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) {
if (!routes?.length) return;
let pickRoutePath = `/${pickRoute}`;
let tempRoutesArr = [];
let tempRoutesNameArr = [];
let newChildrenRoutes = [];
if (!pickRoutes.includes(pickRoutePath)) {
// TODO
}
let pathPickRoutesArr = [];
let namePickRoutesArr = [];
// 去掉掉不需要的菜单
let newRoutes = routes.filter((v) => {
// 提取需要拾取的路由菜单
if (pickRoutes.includes(v.path)) {
tempRoutesArr.push(v);
pathPickRoutesArr.push(v);
}
// 只要是名称叫“一张图”的都不展示在菜单上
if (v.meta?.title && pickRouteNames.includes(v.meta.title)) {
if (!v.hidden)
tempRoutesNameArr.push({
if (!v.hidden) {
namePickRoutesArr.push({
...v,
label: v.meta.title,
value: v.path,
});
}
}
return !pickRoutes.includes(v.path) && v.meta?.title !== "一张图";
});
if (tempRoutesArr.length) {
let parentRoute = tempRoutesArr.filter(
// 提取三大模块菜单的子路由
let pickChildrenRoutes = [];
if (pathPickRoutesArr.length) {
let parentRoute = pathPickRoutesArr.filter(
(v) => v.path === pickRoutePath
)?.[0];
if (parentRoute) {
newChildrenRoutes =
pickChildrenRoutes =
parentRoute.children
?.map((v) => {
return {
@ -252,18 +260,18 @@ function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) {
}
}
// tempRoutesNameArr 赋值给 namesJumpMenu
permission.state.namesJumpMenu = tempRoutesNameArr;
// namePickRoutesArr 赋值给 namesJumpMenu
permission.state.namesJumpMenu = namePickRoutesArr;
return {
topTabList: tempRoutesArr.map((v) => {
topTabList: pathPickRoutesArr.map((v) => {
return {
orderNum: v.orderNum,
label: v.meta.title,
value: v.path.slice(1),
};
}),
newRoutes: [...newChildrenRoutes, ...newRoutes],
newRoutes: [...pickChildrenRoutes, ...newRoutes],
};
}

4
vue.config.js

@ -80,8 +80,8 @@ module.exports = {
changeOrigin: true,
},
[process.env.VUE_APP_BASE_API]: {
// target: "http://shuili.product.dev.com:30115/",
target: "http://172.16.34.80:18082/",
target: "http://shuili.product.dev.com:30115/",
// target: "http://172.16.34.80:18082/",
// target: 'http://172.16.32.62:18888/',
// target: "http://172.16.34.27:18082",
changeOrigin: true,

Loading…
Cancel
Save