diff --git a/src/api/index.ts b/src/api/index.ts index 752c186..4bc4561 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -60,8 +60,8 @@ export class Request { this.instance.interceptors.response.use( (res: AxiosResponse) => { - const { data } = res; - switch (data.code) { + const { data, status } = res; + switch (status) { case HttpStatusCode.Success: return data; default: diff --git a/src/views/login/components/login-form/index.vue b/src/views/login/components/login-form/index.vue index b93d1b3..fff1791 100644 --- a/src/views/login/components/login-form/index.vue +++ b/src/views/login/components/login-form/index.vue @@ -303,6 +303,12 @@ const handleSubmit = async () => { const _fn = isCaptchaLogin.value ? fetchAuthorizationsCaptcha : postLoginPassword; const { code, data, message: errorInfo } = await _fn(loginForm); + console.log(code, errorInfo); + if (code === 10001) { + errMsg.value = errorInfo; + return; + } + if (code === 200) { // 处理登录成功逻辑 message.success('登录成功'); @@ -318,10 +324,6 @@ const handleSubmit = async () => { getProfileInfo(); } - } catch (error) { - if (error?.status === 400) { - errMsg.value = error.data?.message; - } } finally { submitting.value = false; } diff --git a/src/views/login/components/register-form/index.vue b/src/views/login/components/register-form/index.vue index 381be4e..5732982 100644 --- a/src/views/login/components/register-form/index.vue +++ b/src/views/login/components/register-form/index.vue @@ -48,6 +48,9 @@ +
+ {{ errMsg }} +