feat(user): 将resetToken替换为logout以统一用户登出逻辑

统一了用户权限管理和登出流程,将原本的resetToken方法替换为logout方法,
确保用户在无权限或登录失效时能够正确登出并重定向到登录页面。

- 修改permission.js中的异常处理逻辑
- 更新request.js中的响应拦截器处理
- 统一使用logout方法处理用户登出场景
- 修复了权限验证和错误处理的一致性问题
This commit is contained in:
chenxf 2026-01-04 19:14:34 +08:00
parent d03f874202
commit 4f1b601cca
3 changed files with 4 additions and 4 deletions

View File

@ -101,7 +101,7 @@ router.beforeEach(async(to, from, next) => {
next({ ...to, replace: true }) next({ ...to, replace: true })
} catch (error) { } catch (error) {
// remove token and go to login page to re-login // remove token and go to login page to re-login
await store.dispatch('user/resetToken') await store.dispatch('user/logout')
Message.error(error || 'Has Error') Message.error(error || 'Has Error')
next(`/login`) next(`/login`)
NProgress.done() NProgress.done()

View File

@ -46,7 +46,7 @@ service.interceptors.response.use(
const { status, data } = response const { status, data } = response
if (status === 401 || status === 403) { if (status === 401 || status === 403) {
// 没有登录或者没有权限 // 没有登录或者没有权限
store.dispatch('user/resetToken').then(() => { store.dispatch('user/logout').then(() => {
location.reload() location.reload()
}) })
} }
@ -62,7 +62,7 @@ service.interceptors.response.use(
duration: 5 * 1000 duration: 5 * 1000
}) })
// 没有登录或者没有权限 // 没有登录或者没有权限
store.dispatch('user/resetToken').then(() => { store.dispatch('user/logout').then(() => {
location.reload() location.reload()
}) })
} else { } else {

View File

@ -138,7 +138,7 @@ module.exports = {
config config
// https://webpack.js.org/configuration/devtool/#development // https://webpack.js.org/configuration/devtool/#development
.when(process.env.NODE_ENV === 'development', .when(process.env.NODE_ENV === 'development',
config => config.devtool('cheap-source-map') config => config.devtool('source-map')
) )
config config