From 21a745cb413aa3056315cba5854129b90d8d7a65 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 3 Aug 2026 14:31:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(auth):=20401=E6=8B=A6=E6=88=AA=E5=99=A8?= =?UTF-8?q?=E6=8E=92=E9=99=A4auth=E7=AB=AF=E7=82=B9=20+=20login=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=B7=B3=E8=BD=AC/app/dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/api/client.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/web/src/api/client.ts b/apps/web/src/api/client.ts index 389a76ec8..6f1aa2a5c 100644 --- a/apps/web/src/api/client.ts +++ b/apps/web/src/api/client.ts @@ -57,7 +57,21 @@ apiClient.interceptors.response.use( } // 401 → 尝试刷新 Token - if (error.response?.status === 401 && originalRequest && !originalRequest._retry) { + // 排除 auth 端点:登录/注册/找回密码的 401 是正常业务响应(如密码错误), + // 不应触发 token 刷新或登出跳转,走后面的错误提示逻辑即可 + const requestUrl = originalRequest?.url || "" + const isAuthEndpoint = + requestUrl.includes("/auth/login") || + requestUrl.includes("/auth/register") || + requestUrl.includes("/auth/forgot-password") || + requestUrl.includes("/auth/reset-password") + + if ( + error.response?.status === 401 && + originalRequest && + !originalRequest._retry && + !isAuthEndpoint + ) { const refreshToken = useAuthStore.getState().refreshToken // 无 refresh_token → 直接登出 -- 2.54.0 From 1e0f84b1727f72ec69d0f8120ee98366e13bd3e8 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 3 Aug 2026 14:31:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(auth):=20login=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC/app/dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/hooks/useAuth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/hooks/useAuth.ts b/apps/web/src/hooks/useAuth.ts index 5e620e3b0..5fa6ba802 100644 --- a/apps/web/src/hooks/useAuth.ts +++ b/apps/web/src/hooks/useAuth.ts @@ -31,8 +31,8 @@ export const useLogin = () => { const user = await authApi.getCurrentUser() setAuth(user, data.access_token, refreshToken) - // 跳转到登录前页面或首页 - const redirect = localStorage.getItem("login_redirect") || "/" + // 跳转到登录前页面或仪表盘(与 Login.tsx onFinish 保持一致) + const redirect = localStorage.getItem("login_redirect") || "/app/dashboard" localStorage.removeItem("login_redirect") navigate(redirect, { replace: true }) return data -- 2.54.0 From 37e4b3f27204b158da24873e4b33c2e06952d527 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 3 Aug 2026 14:31:35 +0800 Subject: [PATCH 3/3] fix(ci): strip ANSI codes before grep in vitest_incremental.sh --- scripts/ci/vitest_incremental.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ci/vitest_incremental.sh b/scripts/ci/vitest_incremental.sh index b94ec6d0e..cef424ae5 100755 --- a/scripts/ci/vitest_incremental.sh +++ b/scripts/ci/vitest_incremental.sh @@ -61,7 +61,9 @@ set -e echo "$VITEST_OUTPUT" # 如果没有找到测试文件,视为通过(改动的文件没有对应测试) -if echo "$VITEST_OUTPUT" | grep -q "No test files found"; then +# 先用 sed 去掉 ANSI 转义码,避免干扰 grep 匹配 +CLEAN_OUTPUT=$(echo "$VITEST_OUTPUT" | sed 's/\x1b\[[0-9;]*m//g') +if echo "$CLEAN_OUTPUT" | grep -q "No test files found"; then echo "" echo "⚠️ 未找到相关测试文件,跳过(非失败)" exit 0 -- 2.54.0