提交 568f955a 编写于 作者: ping zhang's avatar ping zhang

DISCUSS 组件管理系统

 导航后台接口获取,不用写死
上级 1bd0b00b
...@@ -67,7 +67,7 @@ export default { ...@@ -67,7 +67,7 @@ export default {
token: localStorage.getItem('storageToken') token: localStorage.getItem('storageToken')
} }
vm.POST('/contents/login/log_out',req).then((res) => { vm.POST('/contents/login/log_out',req).then((res) => {
localStorage.removeItem('MSG_CENTER_NAVS') sessionStorage.removeItem('MSG_CENTER_NAVS')
localStorage.removeItem('storageToken') localStorage.removeItem('storageToken')
window.location.href = getInnerLoginUrl() window.location.href = getInnerLoginUrl()
//logout() //logout()
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
}, },
created() { created() {
vm = this vm = this
const navs = localStorage.getItem('MSG_CENTER_NAVS') const navs = sessionStorage.getItem('MSG_CENTER_NAVS')
if (navs != null) { if (navs != null) {
vm.items = JSON.parse(navs) vm.items = JSON.parse(navs)
...@@ -59,9 +59,33 @@ export default { ...@@ -59,9 +59,33 @@ export default {
const { vueMenuDtos } = res.data; const { vueMenuDtos } = res.data;
this.items = vueMenuDtos; this.items = vueMenuDtos;
localStorage.setItem('MSG_CENTER_NAVS', JSON.stringify(vueMenuDtos)); sessionStorage.setItem('MSG_CENTER_NAVS', JSON.stringify(vueMenuDtos));
// 做当前路由无权限时处理
this.checkAuth(this.$route.path.split('/')[1], vueMenuDtos);
} }
}); });
},
checkAuth(path, navs) {
let navList = getNavs(navs);
function getNavs(arr) {
let nvs = [];
for (let i = 0; i < arr.length; i++) {
const nav = arr[i];
const subs = nav.subs;
if (subs.length) {
nvs = nvs.concat(getNavs(subs));
} else {
nvs.push(nav.index);
}
}
return nvs;
}
debugger
if (navList.indexOf(path) == -1) {
this.$router.push(`/${navList[0]}`);
}
} }
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册