fix 登录未重定向,前端退出未清空数据、登录重复点击问题

This commit is contained in:
Amjacks 2025-04-07 16:54:32 +08:00
parent 8a263193a0
commit 6fabd38953
3 changed files with 13 additions and 4 deletions

View File

@ -212,6 +212,8 @@ function logout() {
localStorage.removeItem('userId');
localStorage.removeItem('userName');
localStorage.removeItem('orgNo');
localStorage.removeItem('session');
localStorage.removeItem('token');
});
}
</script>

View File

@ -13,7 +13,13 @@ function setGuard(router: any) {
const hasToken = user.getToken();
// 未登录
if (!hasToken) {
if (hasToken) {
// 已登录
if (to.path === '/login') {
next('/');
return;
}
} else {
// 未登录时放通login
if (to.path === '/login') {
next();
@ -27,7 +33,6 @@ function setGuard(router: any) {
const routes = app.getRoutes;
// 若没有设置routes
if (routes && routes.length === 0) {
const { app } = useStore();
// 获取menuList
const menuList: any = await app.getMenuList();
// 如果menuList不存在或为空则不走下面

View File

@ -163,6 +163,7 @@ function handleLogin() {
localStorage.removeItem('ut');
localStorage.removeItem('userId');
localStorage.removeItem('userName');
state.loading = true
// 1store
user.login(form)
.then((res) => {
@ -172,8 +173,9 @@ function handleLogin() {
//
console.log(res);
ElMessageBox.alert(res.response.data.message, '提醒框', {
confirmButtonText: 'OK'
})
confirmButtonText: 'OK'
})
state.loading = false
});
} else {
state.loading = false;