@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
96 lines (95 loc) • 2.75 kB
TypeScript
/**
* 注册登录工具函数
*/
import { VerificationCodeType, OAuthProvider } from './types';
/**
* 验证邮箱格式
*/
export declare function validateEmail(email: string): boolean;
/**
* 验证手机号格式(支持多种国际格式)
*/
export declare function validatePhone(phone: string): boolean;
/**
* 验证密码强度
*/
export declare function validatePassword(password: string): {
isValid: boolean;
errors: string[];
};
/**
* 验证验证码格式
*/
export declare function validateVerificationCode(code: string, type: VerificationCodeType): boolean;
/**
* 格式化手机号显示
*/
export declare function formatPhoneDisplay(phone: string): string;
/**
* 格式化邮箱显示(隐藏部分字符)
*/
export declare function formatEmailDisplay(email: string, maskLength?: number): string;
/**
* 生成随机字符串(用于状态参数等)
*/
export declare function generateRandomString(length?: number): string;
/**
* 获取 OAuth 提供商的显示名称
*/
export declare function getOAuthProviderDisplayName(provider: OAuthProvider): string;
/**
* 获取 OAuth 提供商的图标 URL
*/
export declare function getOAuthProviderIconUrl(provider: OAuthProvider): string;
/**
* 检查是否在移动设备上
*/
export declare function isMobileDevice(): boolean;
/**
* 检查是否支持 WebAuthn
*/
export declare function isWebAuthnSupported(): boolean;
/**
* 检查是否在 iOS 设备上
*/
export declare function isIOSDevice(): boolean;
/**
* 检查是否在 Android 设备上
*/
export declare function isAndroidDevice(): boolean;
/**
* 获取设备类型
*/
export declare function getDeviceType(): 'desktop' | 'mobile' | 'tablet';
/**
* 防抖函数
*/
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* 节流函数
*/
export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* 深拷贝对象
*/
export declare function deepClone<T>(obj: T): T;
/**
* 安全的 JSON 解析
*/
export declare function safeJsonParse<T = any>(jsonString: string, defaultValue: T): T;
/**
* 安全的 JSON 字符串化
*/
export declare function safeJsonStringify(obj: any, defaultValue?: string): string;
/**
* 格式化时间戳为可读时间
*/
export declare function formatTimestamp(timestamp: number, format?: string): string;
/**
* 计算两个时间戳之间的差值(秒)
*/
export declare function getTimeDifference(timestamp1: number, timestamp2: number): number;
/**
* 检查时间戳是否过期
*/
export declare function isTimestampExpired(timestamp: number, expirationTime?: number): boolean;