/** * 通用的chrome存储管理类 * 提供对 chrome.storage.local 和 chrome.storage.sync 的封装操作,支持单例模式 */ type TStoreType = "local" | "sync"; type TRecord = Record; export declare class ChromeStore { private readonly storageKey; private readonly storeType; private store?; private static instances; private constructor(); private static getInstanceKey; /** * 获取单例实例 */ private static getInstance; /** * 便捷方法:创建本地存储实例 */ static local(storageKey: string): ChromeStore; /** * 便捷方法:创建同步存储实例 */ static sync(storageKey: string): ChromeStore; /** * 清理指定实例 */ static clearInstance(storageKey: string, storeType?: TStoreType): void; /** * 清理所有实例 */ static clearAllInstances(): void; private getStore; /** * 设置数据到 chrome.storage.local 或 chrome.storage.sync */ set(prop: K, value: T[K]): Promise; /** * 获取数据从 chrome.storage.local 或 chrome.storage.sync */ get(prop: K): Promise; /** * 获取所有数据从 chrome.storage.local 或 chrome.storage.sync */ getAll(): Promise; /** * 删除指定的数据从 chrome.storage.local 或 chrome.storage.sync */ remove(prop: K): Promise; /** * 清空所有数据 */ clear(): Promise; /** * 批量设置多个数据 */ setMultiple(data: Partial): Promise; private listeners; private static isGlobalListenerInitialized; private static setupGlobalListener; private dispatchChange; /** * 监听存储变化 (支持单属性监听或全量变化监听) */ onChanged(prop: K, callback: (newValue?: T[K], oldValue?: T[K]) => void): void; onChanged(callback: (changes: { [K in keyof T]?: { newValue?: T[K]; oldValue?: T[K]; }; }) => void): void; /** * 移除监听器 */ offChanged(prop: K, callback: (newValue?: T[K], oldValue?: T[K]) => void): void; offChanged(callback: (changes: { [K in keyof T]?: { newValue?: T[K]; oldValue?: T[K]; }; }) => void): void; /** * 检查是否存在指定的数据 */ has(prop: K): Promise; /** * 获取存储大小(字节数) */ getSize(): Promise; /** * 获取当前存储键名 */ getStoreKey(): string; } export {};