/** * 请求管理器 * * 负责管理和优化 API 请求,包括: * - 请求防抖和节流 * - 请求取消 * - 请求去重 * - 请求缓存 * - 并发控制 */ interface RequestOptions { /** 防抖延迟时间(ms) */ debounceDelay?: number; /** 是否启用缓存 */ enableCache?: boolean; /** 缓存有效期(ms) */ cacheTTL?: number; /** 是否启用请求去重 */ enableDedup?: boolean; /** 最大并发数 */ maxConcurrent?: number; } /** * 请求管理器类 */ export declare class RequestManager { private options; private cache; private pendingRequests; private debounceTimers; private lastRequestTime; private requestQueue; private activeRequests; constructor(options?: RequestOptions); /** * 生成请求缓存键 */ private generateCacheKey; /** * 检查缓存是否有效 */ private isCacheValid; /** * 从缓存获取数据 */ private getFromCache; /** * 保存到缓存 */ private saveToCache; /** * 清理所有缓存 */ clearCache(): void; /** * 清理过期缓存 */ cleanupExpiredCache(): void; /** * 取消所有待处理的请求 */ cancelAllPendingRequests(): void; /** * 取消特定请求 */ cancelRequest(params: any): void; /** * 等待并发槽位 */ private waitForSlot; /** * 执行请求 */ request(params: any, requestFn: (params: any, signal: AbortSignal) => Promise): Promise; /** * 防抖请求 */ debouncedRequest(key: string, params: any, requestFn: (params: any, signal: AbortSignal) => Promise): Promise; /** * 获取统计信息 */ getStats(): { cacheSize: number; pendingRequests: number; activeRequests: number; queueSize: number; }; /** * 清理所有资源 */ cleanup(): void; } /** * 创建请求管理器实例的工厂函数 */ export declare function createRequestManager(options?: RequestOptions): RequestManager; export default RequestManager;