|
@@ -38,34 +38,64 @@ Vue.use(ElementUI, {
|
|
|
Vue.prototype.$http = http;
|
|
|
Vue.prototype.$api = apiService(http);
|
|
|
|
|
|
-let defaultPath='';
|
|
|
+let defaultPath = '';
|
|
|
Vue.prototype.routerLoad = {
|
|
|
- findOne(arr){
|
|
|
- return arr.map(v=>{
|
|
|
- if(v.children){
|
|
|
+ findOne(arr) {
|
|
|
+ return arr.map(v => {
|
|
|
+ if (v.children) {
|
|
|
return this.findOne(v.children)
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return {
|
|
|
- path:"/"+v.linkPath,
|
|
|
- name:v.name
|
|
|
+ path: "/" + v.linkPath,
|
|
|
+ name: v.name
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ findMen(arr, indexPath) {
|
|
|
+ let status = false;
|
|
|
+ arr.map(v => {
|
|
|
+ if (v.children) {
|
|
|
+ this.findMen(v.children)
|
|
|
+ } else {
|
|
|
+ if (('/' + v.linkPath) === indexPath) {
|
|
|
+ status = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return status
|
|
|
+ },
|
|
|
+ close() {
|
|
|
+ let activeRout = localStorage.getItem('path');
|
|
|
+ let tagsList = store.getters['getTagsList'];
|
|
|
+ tagsList.forEach((item, index) => {
|
|
|
+ if (item.path == activeRout) {
|
|
|
+ tagsList.splice(index, 1);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 获取菜单
|
|
|
loadMenus() {
|
|
|
http.get('/user/findUserMenu', { appId: '1001' }).then(({ status, data, msg }) => {
|
|
|
if (0 === status) {
|
|
|
let routerArr = this.findOne(data[0].children);
|
|
|
- if(routerArr[0].length){
|
|
|
+ store.commit('setThisMenuList', data[0].children);
|
|
|
+ if (routerArr[0].length) {
|
|
|
defaultPath = routerArr[0][0].path;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
defaultPath = routerArr[0].path;
|
|
|
- }
|
|
|
+ }
|
|
|
if (localStorage.getItem('path') == '/') {
|
|
|
localStorage.setItem('path', defaultPath)
|
|
|
}
|
|
|
- router.push({ path: localStorage.getItem('path') })
|
|
|
+ if (this.findMen(data[0].children, localStorage.getItem('path'))) {
|
|
|
+ router.push({ path: localStorage.getItem('path') })
|
|
|
+ } else {
|
|
|
+ this.close();
|
|
|
+ router.replace({ path: '403' })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|