From e2d16d0f10e5f0e3f131d7ce2cace62c18ab091f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Fri, 29 Aug 2025 05:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/auth.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/auth.ts b/lib/auth.ts index 251d853..d11d324 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -26,7 +26,9 @@ export const loginUser = async (email: string, password: string) => { }); const data = await response.json(); - console.log('data', data) + if(!data.success){ + throw new Error(data.message) + } // 保存token到本地存储 setToken(data.token); @@ -376,7 +378,10 @@ export const registerUser = async ({ }); const data = await response.json(); - + console.log('data', data) + if(!data.success){ + throw new Error(data.message) + } return data as { success: boolean; };