fix login refresh permission

This commit is contained in:
likun 2025-04-30 16:10:09 +08:00
parent 29cb1e0bb8
commit 16b648f3a2
6 changed files with 24 additions and 13 deletions

View File

@ -45,8 +45,10 @@ router.beforeEach((to, from, next) => {
console.log("跳转路径:", to.path, " 报错:", err)
LocalCache.deleteCache("token")
LocalCache.deleteCache("user")
LocalCache.deleteCache("projectsRoute")
})
} else {
// console.log("访问页面" + to.path + "已经请求过用户数据,跳过获取")
// console.log("op tree routes length valid:", projectOpTreeRoutes.value.length)
next()
}

View File

@ -144,5 +144,5 @@ export function setProjectOperationRoutes(projectList) {
}
LocalCache.setCache("projectsRoute", projectList)
// console.log("after set all routes:", router.getRoutes())
// console.log("重新获取了用户数据,刷新路由表:", router.getRoutes())
}

View File

@ -55,11 +55,19 @@ const resInterceptor = (res) => {
location.href = "/login"
return Promise.reject()
}
console.log("interceptor err code", res)
ElMessageBox.alert("请求服务器成功,但是逻辑错误:" + res.data.msg, "服务器错误码[" + code + "]", {
type: "warning",
confirmButtonText: '知道了',
})
if (code == 7) {
ElMessageBox.alert("用户名或密码错误!", {
type: "warning",
confirmButtonText: '知道了',
})
} else {
console.log("interceptor err code", res)
ElMessageBox.alert("请求服务器成功,但是逻辑错误:" + res.data.msg, "服务器错误码[" + code + "]", {
type: "warning",
confirmButtonText: '知道了',
})
}
return Promise.reject(res.data)
}

View File

@ -2,7 +2,7 @@
import {useRoute, useRouter} from 'vue-router'
import {computed} from 'vue'
import avatarUrl from '@/assets/icon/header.png'
import {constUserChildrenRoutes, projectOpTreeRoutes} from '@/router/index.js'
import {constUserChildrenRoutes, isGetUserInfo, projectOpTreeRoutes} from '@/router/index.js'
import LocalCache from "@/stores/localCache.js";
import welcome from '@/views/welcome.vue'
@ -26,7 +26,7 @@ const handleEnterIndex = () => {
//
const handleMenuSelect = (clickResource) => {
console.log("点击资源:", clickResource)
// console.log("", clickResource)
LocalCache.setCache("resource", clickResource)
router.push({path: clickResource.path})
hasClickedMenu.value = true
@ -48,8 +48,10 @@ function logout() {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
isGetUserInfo.value = false
LocalCache.deleteCache("user")
LocalCache.deleteCache("token")
LocalCache.deleteCache("projectsRoute")
router.push('/login')
}).catch(() => {
});

View File

@ -83,8 +83,8 @@ const submitForm = (formEl) => {
LocalCache.setCache('token', res.data.token_info.token)
LocalCache.setCache('user', res.data.user_info)
ExpireCache.setCache("token", res.data.token_info.token, res.data.token_info.expire_at)
console.log("登录成功,返回数据:", res.data, ",准备重定向到页面:", redirect.value)
router.push({path: redirect.value || "/"})
console.log("登录成功,返回数据:", res.data,)
router.push({path: "/"})
}, (res) => {
console.log("login response error:")
console.log(res)

View File

@ -6,9 +6,8 @@ const userInfo = LocalCache.getCache("user")
</script>
<template>
<span style="font-size:40px">亲爱的<span style="color: darkslategrey;font-size: 50px"> {{
userInfo.nick_name
}} </span>欢迎使用本公司后台管理系统</span>
<span style="font-size:40px">亲爱的<span style="color: darkslategrey;font-size: 50px">
{{ userInfo.nick_name }} </span>欢迎使用本公司后台管理系统</span>
<el-divider></el-divider>
<span style="font-size:40px">硬盘有价数据无价操作不规范亲人两行泪</span>
</template>