修复登录账号没有任何权限时跳转到403页面错误
This commit is contained in:
parent
331997e1e9
commit
61ef48d446
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
|
|
@ -44,7 +44,7 @@ router.beforeEach(async (to, from, next) => {
|
|||
const routeName = findFirstValidRoute(routes)
|
||||
// 没有有效路由跳转到403页面
|
||||
if (!routeName) {
|
||||
await userStore.logout()
|
||||
clearAuthInfo()
|
||||
next(PageEnum.ERROR_403)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ const useUserStore = defineStore({
|
|||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
resetState() {
|
||||
this.token = ''
|
||||
this.userInfo = {}
|
||||
this.perms = []
|
||||
},
|
||||
login(playload: any) {
|
||||
const { account, password } = playload
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function getToken() {
|
|||
export function clearAuthInfo() {
|
||||
const userStore = useUserStore()
|
||||
const tabsStore = useTabsStore()
|
||||
userStore.$reset()
|
||||
userStore.resetState()
|
||||
tabsStore.$reset()
|
||||
cache.remove(TOKEN_KEY)
|
||||
resetRouter()
|
||||
|
|
|
|||
|
|
@ -72,10 +72,9 @@ export class Axios {
|
|||
}
|
||||
|
||||
if (err.code == AxiosError.ECONNABORTED || err.code == AxiosError.ERR_NETWORK) {
|
||||
setTimeout(() => {
|
||||
console.log(err)
|
||||
return new Promise((resolve) => setTimeout(resolve, 500)).then(() =>
|
||||
this.retryRequest(err)
|
||||
}, 500)
|
||||
)
|
||||
}
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
|
@ -103,17 +102,17 @@ export class Axios {
|
|||
retryRequest(error: AxiosError) {
|
||||
const config = error.config
|
||||
const { retryCount, isOpenRetry } = config.requestOptions
|
||||
if (!isOpenRetry && config.method?.toUpperCase() == RequestMethodsEnum.POST) {
|
||||
return
|
||||
if (!isOpenRetry || config.method?.toUpperCase() == RequestMethodsEnum.POST) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
config.retryCount = config.retryCount ?? 0
|
||||
|
||||
if (config.retryCount >= retryCount) {
|
||||
return
|
||||
return Promise.reject(error)
|
||||
}
|
||||
config.retryCount++
|
||||
|
||||
this.axiosInstance.request(config)
|
||||
return this.axiosInstance.request(config)
|
||||
}
|
||||
/**
|
||||
* @description get请求
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<template>
|
||||
<div class="error404">
|
||||
<error
|
||||
code="403"
|
||||
title="您的账号权限不足,请联系管理员添加权限!"
|
||||
:show-btn="false"
|
||||
></error>
|
||||
<error code="403" title="您的账号权限不足,请联系管理员添加权限!" :show-btn="false">
|
||||
<template #content>
|
||||
<div class="flex justify-center">
|
||||
<img class="w-[150px] h-[150px]" src="@/assets/images/no_perms.png" alt="" />
|
||||
</div>
|
||||
</template>
|
||||
</error>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<template>
|
||||
<div class="error">
|
||||
<div>
|
||||
<div class="error-code">{{ code }}</div>
|
||||
<div class="lg lighter mt-7 mb-7">{{ title }}</div>
|
||||
<slot name="content">
|
||||
<div class="error-code">{{ code }}</div>
|
||||
</slot>
|
||||
<div class="text-lg text-tx-secondary mt-7 mb-7">{{ title }}</div>
|
||||
<el-button v-if="showBtn" type="primary" @click="router.go(-1)">
|
||||
{{ second }} 秒后返回上一页
|
||||
</el-button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue