fix:splash 界面重定向界面问题

This commit is contained in:
2026-06-11 17:00:04 +08:00
parent e3d549d660
commit 1151a9a61b
7 changed files with 144 additions and 94 deletions
+9 -12
View File
@@ -21,7 +21,7 @@ import { authMachine } from "./auth-machine";
import type { AuthEvent, AuthState as MachineContext } from "./auth-machine";
/**
* 对外暴露的 State 形状(保持与原 AuthState 兼容)
* 对外暴露的 State 形状
*/
interface AuthState {
authPanelMode: MachineContext["authPanelMode"];
@@ -32,16 +32,14 @@ interface AuthState {
confirmPassword: string;
isLoading: boolean;
errorMessage: string | null;
/**
* 字段名 `isSuccess` 保留(接口兼容),语义改为:
* true = 用户**已登录**loginStatus ∈ {email, google, facebook, apple, guest}
* false = 未登录(loginStatus === "notLoggedIn"
*
* 之前用 `state.matches("success")` 当信号 —— 但 status check 流也会误入
* success,触发 splash-button 误跳 /chat。现改用 `loginStatus` 判定。
*/
isSuccess: boolean;
/** 当前登录状态(未登录 / 游客 / OAuth / 邮箱) */
loginStatus: MachineContext["loginStatus"];
/**
* 一次性的"刚按了"信号 —— Skip / Facebook / 邮箱登录按钮派完业务事件后置 true,
* splash-screen / auth-screen 看到 `pendingRedirect && loginStatus !== "notLoggedIn"`
* 触发跳转 + 调 `AuthClearPendingRedirect` 置 false。
*/
pendingRedirect: boolean;
}
const AuthStateCtx = createContext<AuthState | null>(null);
@@ -70,9 +68,8 @@ export function AuthProvider({ children }: AuthProviderProps) {
state.matches("loadingOAuth") ||
state.matches("loadingGuestLogin"),
errorMessage: state.context.errorMessage,
// 改用 loginStatus 判断"已登录"(避开 success state 误触发)
isSuccess: state.context.loginStatus !== "notLoggedIn",
loginStatus: state.context.loginStatus,
pendingRedirect: state.context.pendingRedirect,
}),
[state],
);