router文件
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) {
var temp = [];
for (var i = 0; i < pageRoutes.length; i++) {
if (route.path === pageRoutes[i].path) {
if (route.path === '/kanban' || route.path === '/kanban2') {
if (localStorage.getItem("token")) {
return true;
} else {
return false;
}
} else {
return true;
}
}
if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) {
temp = temp.concat(pageRoutes[i].children);
}
}
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false;
}
登录页面, 两个登录成功后添加
localStorage.setItem("token", res.data.token);
退出登录时清除 localStorage
/**
* 清除登录信息
*/
export function clearLoginInfo () {
store.commit('resetStore')
Cookies.remove('token')
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = false
// localStorage.clear();
}
网友评论