/**
* 登录注册 2.0 组件类型定义
*/
///
/** 验证方式枚举 */
export declare type VerificationMethod = 'verification_code' | 'password';
/** 邮箱注册验证方式 */
export declare type EmailRegistrationVerification = 'verification_link' | 'verification_code';
/** 认证方式类型 */
export declare type AuthMethodType = 'email' | 'phone' | 'google' | 'facebook' | 'apple';
/** 当前状态:登录或注册 */
export declare type AuthState = 'login' | 'register';
/** 邮箱认证配置 */
export interface EmailAuthConfig {
/** 是否启用邮箱认证 */
enable_email: boolean;
/** 注册验证方式 */
registration_verification: EmailRegistrationVerification;
/** 登录验证方式列表 */
login_verification_methods: VerificationMethod[];
}
/** 手机认证配置 */
export interface PhoneAuthConfig {
/** 是否启用手机认证 */
enable_phone_number: boolean;
/** 注册验证方式(手机仅支持验证码) */
registration_verification: 'verification_code';
/** 登录验证方式列表 */
login_verification_methods: VerificationMethod[];
}
/** 三方 OAuth 配置 */
export interface OAuthConfig {
/** Google 登录 */
google?: {
enabled: boolean;
client_id?: string;
};
/** Facebook 登录 */
facebook?: {
enabled: boolean;
app_id?: string;
};
/** Apple 登录 */
apple?: {
enabled: boolean;
client_id?: string;
};
}
/** UI 配置 */
export interface UIConfig {
/** Logo 配置 */
logo?: {
show: boolean;
url?: string;
position?: 'left' | 'center' | 'right';
size?: {
width: number;
height: number;
};
};
/** 标题配置 */
title?: {
show: boolean;
text?: string;
align?: 'left' | 'center' | 'right';
};
/** 副标题配置 */
subtitle?: {
show: boolean;
text?: string;
align?: 'left' | 'center' | 'right';
};
/** 描述配置 */
desc?: {
show: boolean;
text?: string;
align?: 'left' | 'center' | 'right';
};
/** 标签页配置 */
tabs?: {
show: boolean;
loginText?: string;
registerText?: string;
};
/** 主题色 */
themeColor?: string;
}
/** 组件总配置 */
export interface Login2Config {
/** 邮箱认证配置 */
email?: EmailAuthConfig;
/** 手机认证配置 */
phone?: PhoneAuthConfig;
/** 三方 OAuth 配置 */
oauth?: OAuthConfig;
/** UI 配置 */
ui?: UIConfig;
/** 默认认证方式 */
defaultAuthMethod?: AuthMethodType;
/** 默认状态(登录或注册) */
defaultState?: AuthState;
}
/** 登录表单数据 */
export interface LoginFormData {
/** 邮箱或手机号 */
account: string;
/** 密码 */
password?: string;
/** 验证码 */
verification_code?: string;
/** 记住我 */
remember_me?: boolean;
}
/** 注册表单数据 */
export interface RegisterFormData {
/** 邮箱或手机号 */
account: string;
/** 密码 */
password?: string;
/** 确认密码 */
confirm_password?: string;
/** 验证码 */
verification_code?: string;
/** 验证链接 token */
verification_token?: string;
}
/** 组件事件回调 */
export interface Login2Events {
/** 登录回调 */
onLogin?: (data: LoginFormData, method: AuthMethodType) => Promise | void;
/** 注册回调 */
onRegister?: (data: RegisterFormData, method: AuthMethodType) => Promise | void;
/** 三方登录回调 */
onOAuthLogin?: (provider: 'google' | 'facebook' | 'apple') => Promise | void;
/** 发送验证码回调 */
onSendVerificationCode?: (account: string, type: 'email' | 'phone') => Promise | void;
/** 忘记密码回调 */
onForgotPassword?: (account: string) => Promise | void;
}
/** 组件完整属性 */
export interface Login2Props extends Login2Events {
/** 配置对象 */
config: Login2Config;
/** 是否显示 */
visible?: boolean;
/** 关闭回调 */
onClose?: () => void;
/** 自定义类名 */
className?: string;
/** 自定义样式 */
style?: React.CSSProperties;
}
/** 组件内部状态 */
export interface Login2State {
/** 当前状态:登录或注册 */
authState: AuthState;
/** 当前认证方式 */
currentAuthMethod: AuthMethodType;
/** 当前使用的验证方式 */
currentVerificationMethod: VerificationMethod;
/** 加载状态 */
loading: boolean;
/** 验证码倒计时 */
countdown: number;
/** 表单数据 */
formData: Partial;
}