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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user