feat: add xstate state management for user state

Introduce xstate v5 and @xstate/react to manage user authentication and profile state. Implement userMachine with actors for initialization, fetching, and logout operations, along with actions for updating user data and clearing state.
This commit is contained in:
2026-06-09 17:26:16 +08:00
parent 50940961ec
commit 5e645b003e
33 changed files with 1466 additions and 1273 deletions
+2 -2
View File
@@ -15,11 +15,11 @@
* - 单例挂在 class 静态字段,HMR 复用安全
*/
import { UserSchema, type UserData } from "@/data/services/schemas/user/user";
import { LocalStorage } from "../local_storage";
import { UserSchema, type UserData } from "@/data/schemas/user/user";
import { type Result as ResultT } from "@/utils/result";
import { StorageKeys } from "../storage_keys";
import type { IUserStorage } from "./iuser_storage";
import { LocalStorage } from "@/utils/local-storage";
export class UserStorage implements IUserStorage {
private readonly ls: LocalStorage;