diff --git a/backend/dvadmin/utils/exception.py b/backend/dvadmin/utils/exception.py index 8498441..d1dbedc 100644 --- a/backend/dvadmin/utils/exception.py +++ b/backend/dvadmin/utils/exception.py @@ -38,12 +38,16 @@ def CustomExceptionHandler(ex, context): # 调用默认的异常处理函数 response = exception_handler(ex, context) if isinstance(ex, AuthenticationFailed): - code = 401 - code_type = response.data.get('detail').code - if code_type == 'no_active_account': - code=400 + # 如果是身份验证错误 + if response and response.data.get('detail') == "Given token not valid for any token type": + code = 401 + msg = ex.detail + elif response and response.data.get('detail') == "Token is blacklisted": + # token在黑名单 return ErrorResponse(status=HTTP_401_UNAUTHORIZED) - msg = ex.detail + else: + code = 401 + msg = ex.detail elif isinstance(ex,Http404): code = 400 msg = "接口地址不正确" diff --git a/web/src/i18n/pages/login/en.ts b/web/src/i18n/pages/login/en.ts index 2654a18..28c6983 100644 --- a/web/src/i18n/pages/login/en.ts +++ b/web/src/i18n/pages/login/en.ts @@ -9,8 +9,8 @@ export default { two4: 'Links', }, account: { - accountPlaceholder1: 'The user name admin or not is common', - accountPlaceholder2: 'Password: 123456', + accountPlaceholder1: 'Please enter your login account', + accountPlaceholder2: 'Please enter your login password', accountPlaceholder3: 'Please enter the verification code', accountBtnText: 'Sign in', }, diff --git a/web/src/i18n/pages/login/zh-cn.ts b/web/src/i18n/pages/login/zh-cn.ts index 3367b53..61f994d 100644 --- a/web/src/i18n/pages/login/zh-cn.ts +++ b/web/src/i18n/pages/login/zh-cn.ts @@ -9,8 +9,8 @@ export default { two4: '友情链接', }, account: { - accountPlaceholder1: '用户名 admin 或不输均为 common', - accountPlaceholder2: '密码:123456', + accountPlaceholder1: '请输入登录账号', + accountPlaceholder2: '请输入登录密码', accountPlaceholder3: '请输入验证码', accountBtnText: '登 录', }, diff --git a/web/src/i18n/pages/login/zh-tw.ts b/web/src/i18n/pages/login/zh-tw.ts index 138e8c8..13ad013 100644 --- a/web/src/i18n/pages/login/zh-tw.ts +++ b/web/src/i18n/pages/login/zh-tw.ts @@ -9,8 +9,8 @@ export default { two4: '友情連結', }, account: { - accountPlaceholder1: '用戶名admin或不輸均為common', - accountPlaceholder2: '密碼:123456', + accountPlaceholder1: '請輸入登入賬號', + accountPlaceholder2: '請輸入登入密碼', accountPlaceholder3: '請輸入驗證碼', accountBtnText: '登入', }, diff --git a/web/src/utils/service.ts b/web/src/utils/service.ts index 8798898..2385c48 100644 --- a/web/src/utils/service.ts +++ b/web/src/utils/service.ts @@ -70,7 +70,7 @@ function createService() { case 401: Local.clear(); Session.clear(); - dataAxios.msg = '登录授权过期,请重新登录'; + dataAxios.msg = '登录认证失败,请重新登录'; ElMessageBox.alert(dataAxios.msg, '提示', { confirmButtonText: 'OK', callback: (action: Action) => { @@ -100,7 +100,15 @@ function createService() { error.message = '请求错误'; break; case 401: - error.message = '未授权,请登录'; + Local.clear(); + Session.clear(); + error.message = '登录授权过期,请重新登录'; + ElMessageBox.alert(error.message, '提示', { + confirmButtonText: 'OK', + callback: (action: Action) => { + window.location.reload(); + }, + }) break; case 403: error.message = '拒绝访问'; diff --git a/web/src/utils/websocket.ts b/web/src/utils/websocket.ts index 72fe410..987273e 100644 --- a/web/src/utils/websocket.ts +++ b/web/src/utils/websocket.ts @@ -30,7 +30,7 @@ const websocket: socket = { } const token = Session.get('token') if(!token){ - message.warning('websocket认证失败') + // message.warning('websocket认证失败') return null } const wsUrl = `${getWsBaseURL()}ws/${token}/`