Commit a62ec5d2 authored by 纪泽龙's avatar 纪泽龙

主页改成了当前用户的第一级路由

parent ac181752
......@@ -154,6 +154,7 @@ export default {
path = this.activeRoutes(key);
// console.log("path",this.$store.state.permission.topbarRouters);
console.log(this.$route.path);
if (this.$route.path != path[0].path) {
if (path[0].path) {
this.$router.push(path[0].path);
......@@ -162,6 +163,7 @@ export default {
this.$router.push("/index");
}
}
// 当点击菜单时,如果当前页面是gis地图,就晴空dilog
// if (key == "/enterprise") {
// // this.$store.commit("TOGGLE_DEVICE","mobile");
......
import router from "./router";
import router, { route } from "./router";
import store from "./store";
import { Message } from "element-ui";
import NProgress from "nprogress";
......@@ -25,7 +25,17 @@ router.beforeEach((to, from, next) => {
store.dispatch("GenerateRoutes").then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes); // 动态添加可访问路由表
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
// next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
// 跳转去第一个路由
const myHome = accessRoutes[0]?.children.filter(
item => !item.hidden
)[0];
// 跳转去第一个子元素当主页
if (to.path == "/enterprise/mapView") {
next({ ...myHome, replace: true });
} else {
next({ ...to, replace: true });
}
});
})
.catch(err => {
......@@ -50,21 +60,19 @@ router.beforeEach((to, from, next) => {
}
});
export const getRouter = () => {};
router.afterEach((to, from) => {
// 查找只有一个菜单的目录
const parentPath = to.matched[0].path;
let arr = store.state.permission.topbarRouters.filter(item=>{
let arr = store.state.permission.topbarRouters
.filter(item => {
return item.path == parentPath;
})[0].children.filter(item=>{
return item.hidden == false
})
if (arr.length==1 ||to.path == "/enterprise/mapView") {
})[0]?.children.filter(item => {
return item.hidden == false;
});
if (arr&&arr.length == 1 || to.path == "/enterprise/mapView") {
store.dispatch("app/toggleDevice", "mobile");
store.dispatch("app/closeSideBar", { withoutAnimation: true });
} else {
store.dispatch("app/toggleDevice", "desktop");
store.dispatch("app/closeSideBar", { withoutAnimation: false });
......
......@@ -41,7 +41,8 @@ const permission = {
}
];
// state.topbarRouters = routes.concat(index);
const arr = [...index, ...routes];
// const arr = [...index, ...routes];
const arr = [...routes];
state.topbarRouters = arr;
// state.topbarRouters = routes;
},
......
......@@ -362,18 +362,19 @@ class gaodeMap {
marker.on("mouseout", infoClose);
marker.setExtData(data);
that.deviceType = markerType;
let editWindow = that.createInfowindow("编辑");
editWindow.fileArr =
data.iconUrl != "" && data.iconUrl != undefined
? [{ url: data.iconUrl }]
: [];
editWindow.obj = marker;
editWindow.gaoMap = that;
editWindow.map = map;
marker.on("click", function(e) {
if ("edit" == that.mapOperateType) {
editWindow.form = e.target.getExtData();
editWindow.show();
// let editWindow = that.createInfowindow("编辑");
// editWindow.fileArr =
// data.iconUrl != "" && data.iconUrl != undefined
// ? [{ url: data.iconUrl }]
// : [];
// editWindow.obj = marker;
// editWindow.gaoMap = that;
// editWindow.map = map;
// editWindow.form = e.target.getExtData();
// editWindow.show();
} else if ("delete" == that.mapOperateType) {
let diviceType = {
"2": "调压箱",
......
......@@ -892,7 +892,15 @@ export default {
console.log("移除window事件");
window.removeEventListener("click", this.barClose);
window.removeEventListener("resize", this.onResize);
// 离开的时候清除创建的元素
let removeElements = document.getElementsByClassName("el-dialog__wrapper");
const arr = [...removeElements]
for(var i =0;i<arr.length;i++){
const item = arr[i];
document.body.removeChild(item);
}
},
destroyed() {},
};
</script>
......
......@@ -1015,9 +1015,9 @@ export default {
this.workerManInfoWindowShow(iten, lat, lng);
} else if (item.value == 8) {
this.trouleInfoWindowShow(iten, lat, lng);
}else if(item.value == 10){
this.videoInfoWindowShow(iten, lat, lng)
}else {
} else if (item.value == 10) {
this.videoInfoWindowShow(iten, lat, lng);
} else {
// 其他设备
this.diveceInfoWindowShow(iten, lat, lng);
}
......@@ -1617,6 +1617,13 @@ export default {
this.ws.close();
this.ws = null;
}
// 离开的时候清除创建的元素
// let removeElements = document.getElementsByClassName("el-dialog__wrapper");
// const arr = [...removeElements];
// for (var i = 0; i < arr.length; i++) {
// const item = arr[i];
// document.body.removeChild(item);
// }
},
};
</script>
......
......@@ -133,10 +133,12 @@ export default {
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
this.$store.dispatch("Login", this.loginForm).then(() => {
this.$store.dispatch("Login", this.loginForm).then((res) => {
// this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
// console.log(this.redirect)
this.$router.push({ path: "/enterprise/mapView" || "/" }).catch(()=>{});
// this.$router.push({ path: "/enterprise/mapView" || "/" }).catch(()=>{});
this.$router.push({ path: "/" }).catch(()=>{});
}).catch(() => {
this.loading = false;
this.getCode();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment