UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

57 lines (56 loc) 1.45 kB
export declare enum AccountHooks { OnLogin = "account:onLogin", OnLogout = "account:onLogout", OnRegister = "account:onRegister", OnProfileUpdate = "account:onProfileUpdate" } /** * 用户账户信息 */ export interface Account { id: string | number; /** 用户名 */ username: string; /** 邮箱 */ email?: string; /** 手机号 */ phone?: string; /** 昵称 */ name?: string; /** 头像 */ avatar?: string; /** 元数据 */ metadata?: Record<string, any>; /** 是否为游客 */ isGuest?: boolean; /** 账户类型 */ type?: 'account' | 'holder'; /** 账户信息原始数据 */ _origin?: Record<string, any>; /** 是否是登录账号 */ isLogin?: boolean; } /** * 账户模块状态 */ export interface AccountState { accountInfo: Account | null; isLoggedIn: boolean; active: boolean; } /** * 账户模块 API */ export interface AccountModuleAPI { login: (credentials: { username: string; password: string; }) => Promise<void>; logout: () => Promise<void>; register: (account: Omit<Account, 'id'>) => Promise<void>; getCurrentAccount: () => Account | null; updateProfile: (updates: Partial<Account>) => Promise<void>; isLoggedIn: () => boolean; resetPassword: (email: string) => Promise<void>; updatePassword: (oldPassword: string, newPassword: string) => Promise<void>; }