fix 登录未重定向,前端退出未清空数据、登录重复点击问题
This commit is contained in:
parent
8a263193a0
commit
6fabd38953
@ -212,6 +212,8 @@ function logout() {
|
|||||||
localStorage.removeItem('userId');
|
localStorage.removeItem('userId');
|
||||||
localStorage.removeItem('userName');
|
localStorage.removeItem('userName');
|
||||||
localStorage.removeItem('orgNo');
|
localStorage.removeItem('orgNo');
|
||||||
|
localStorage.removeItem('session');
|
||||||
|
localStorage.removeItem('token');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -13,7 +13,13 @@ function setGuard(router: any) {
|
|||||||
|
|
||||||
const hasToken = user.getToken();
|
const hasToken = user.getToken();
|
||||||
// 未登录
|
// 未登录
|
||||||
if (!hasToken) {
|
if (hasToken) {
|
||||||
|
// 已登录
|
||||||
|
if (to.path === '/login') {
|
||||||
|
next('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// 未登录时放通login
|
// 未登录时放通login
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
next();
|
next();
|
||||||
@ -27,7 +33,6 @@ function setGuard(router: any) {
|
|||||||
const routes = app.getRoutes;
|
const routes = app.getRoutes;
|
||||||
// 若没有设置routes
|
// 若没有设置routes
|
||||||
if (routes && routes.length === 0) {
|
if (routes && routes.length === 0) {
|
||||||
const { app } = useStore();
|
|
||||||
// 获取menuList
|
// 获取menuList
|
||||||
const menuList: any = await app.getMenuList();
|
const menuList: any = await app.getMenuList();
|
||||||
// 如果menuList不存在或为空,则不走下面
|
// 如果menuList不存在或为空,则不走下面
|
||||||
|
@ -163,6 +163,7 @@ function handleLogin() {
|
|||||||
localStorage.removeItem('ut');
|
localStorage.removeItem('ut');
|
||||||
localStorage.removeItem('userId');
|
localStorage.removeItem('userId');
|
||||||
localStorage.removeItem('userName');
|
localStorage.removeItem('userName');
|
||||||
|
state.loading = true
|
||||||
// 1、store请求
|
// 1、store请求
|
||||||
user.login(form)
|
user.login(form)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -172,8 +173,9 @@ function handleLogin() {
|
|||||||
// 请求失败时的处理逻辑
|
// 请求失败时的处理逻辑
|
||||||
console.log(res);
|
console.log(res);
|
||||||
ElMessageBox.alert(res.response.data.message, '提醒框', {
|
ElMessageBox.alert(res.response.data.message, '提醒框', {
|
||||||
confirmButtonText: 'OK'
|
confirmButtonText: 'OK'
|
||||||
})
|
})
|
||||||
|
state.loading = false
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user