refactor(auth): extract helpers and actors out of auth-machine

Move the file-local Helpers block (readGuestId) to auth-helpers.ts and the
Actors block (authRepo + 7 fromPromise actors) to auth-actors.ts. Public API
(authMachine, AuthEvent, AuthState, initialState, AuthMachine) is unchanged;
auth-context.tsx and the barrel index.ts need no edits.
This commit is contained in:
2026-06-15 11:32:53 +08:00
parent 65891b3a8a
commit 5d1aebdfad
3 changed files with 195 additions and 168 deletions
+15
View File
@@ -0,0 +1,15 @@
/**
* Auth 状态机:Helpers
*
* 状态机内复用的小函数 —— 独立成文件便于测试 / 复用。
*/
import { AuthStorage } from "@/data/storage/auth/auth_storage";
/** 从本地存储读 guest deviceId;读不到 / 失败时返回 undefined(不抛)。 */
export async function readGuestId(): Promise<string | undefined> {
const r = await AuthStorage.getInstance().getDeviceId();
if (r.success && r.data != null) {
return r.data;
}
return undefined;
}