From 4d49752f0cd09096b982351975beaf98a6b6cf6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Sun, 8 Sep 2024 11:33:48 +0800 Subject: [PATCH] [*] Fix response condition bug --- src/views/AddProxies.vue | 8 ++++++-- src/views/Login.vue | 14 +++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/views/AddProxies.vue b/src/views/AddProxies.vue index c544e0d..6d031c0 100644 --- a/src/views/AddProxies.vue +++ b/src/views/AddProxies.vue @@ -283,9 +283,13 @@ async function addProxy() { } if (!rs) return if (rs.status === 200) { - sendSuccessDialog('添加成功') + if (rs.data.status === 200) { + sendSuccessDialog('添加成功') + } else { + sendErrorMessage(rs.message) + } } else { - sendErrorMessage(res.data.msg) + sendErrorMessage(rs.message) } } diff --git a/src/views/Login.vue b/src/views/Login.vue index c74f04f..d475b34 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -157,23 +157,23 @@ async function login() { } let res try { - res = await api.v2.users.login(model.value.username, model.value.password) + rs = await api.v2.users.login(model.value.username, model.value.password) } catch (e) { sendErrorMessage('请求失败: ' + e) } - if (!res) { + if (!rs) { ldb.error() return } - if (res.status === 200) { - message.success(res.data.username + ',欢迎回来!') - store.commit('set_token', res.data.token) + if (rs.status === 200) { + message.success(rs.data.username + ',欢迎回来!') + store.commit('set_token', rs.data.token) // console.log(res.data) - store.commit('set_user_info', res.data) + store.commit('set_user_info', rs.data) router.push(redirect || '/dashboard') ldb.finish() } else { - message.warning(res.data.msg) + message.warning(rs.message) ldb.error() } }