import { ClearStorageOptions } from "./ClearStorageOptions"; import { GetStorageInfoOptions } from "./GetStorageInfoOptions"; import { GetStorageOptions } from "./GetStorageOptions"; import { RemoveStorageOptions } from "./RemoveStorageOptions"; import { SetStorageOptions } from "./SetStorageOptions"; import { StorageContent } from "./StorageContent"; import { StorageInfo } from "./StorageInfo"; export declare class StorageAPI { /** * 清理本地数据缓存。 * @param options * @returns * @example * ```javascript * ks.clearStorage({ * success() { * // 清空缓存成功 * }, * fail() { * // 清空缓存失败 * }, * }); * * ``` * */ clearStorage(options?: ClearStorageOptions): Promise; /** * 同步清理本地数据缓存。 * @example * ```javascript * try { * ks.clearStorageSync(); * } catch (e) { * // 清空缓存失败 * } * * ``` * */ clearStorageSync(): void; /** * 获取当前本地数据缓存的相关信息。 * @param options * @returns * @example * ```javascript * ks.getStorageInfo({ * success(res) { * const { keys, currentSize, limitSize } = res; * }, * fail() { * // 获取 storage 信息失败 * }, * }); * * ``` * */ getStorageInfo(options?: GetStorageInfoOptions): Promise; /** * 同步获取当前本地数据缓存的相关信息。 * @example * ```javascript * try { * const { keys, currentSize, limitSize } = ks.getStorageInfoSync(); * } catch (e) { * // 获取 storage 信息失败 * } * * ``` * */ getStorageInfoSync(): StorageInfo; /** * 从本地缓存中获取指定 key 的内容。 * @param options * @returns * @example * ```javascript * ks.getStorage({ * key: 'key', * success(res) { * const { data } = res; * }, * fail() { * // 获取缓存数据失败 * }, * }); * * ``` * */ getStorage(options: GetStorageOptions): Promise; /** * 同步从本地缓存中获取指定 key 的内容。 * @param key 本地缓存中指定的 key * @returns key 对应的内容 * @example * ```javascript * try { * const data = ks.getStorageSync('key'); * } catch (e) { * // 获取缓存数据失败 * } * * ``` * */ getStorageSync(key: string): unknown; /** * 从本地缓存中移除指定 key。 * @param options * @returns * @example * ```javascript * ks.removeStorage({ * key: 'key', * success() { * // 删除缓存数据成功 * }, * fail() { * // 删除缓存数据成功 * }, * }); * * ``` * */ removeStorage(options: RemoveStorageOptions): Promise; /** * 同步从本地缓存中移除指定 key。 * @param key 本地缓存中指定的 key * @example * ```javascript * try { * ks.removeStorageSync('key'); * } catch (e) { * // 删除缓存数据成功 * } * * ``` * */ removeStorageSync(key: string): void; /** * 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 * @param options * @returns * @example * ```javascript * ks.setStorage({ * key: 'key', * data: 'value', * success() { * // 缓存成功 * }, * fail() { * // 缓存失败 * }, * }); * * ``` * */ setStorage(options: SetStorageOptions): Promise; /** * 同步将数据存储在本地缓存中指定的 key 中。 * @param key 本地缓存中指定的 key * @param data 需要存储的内容。只支持原生类型、Date、及能够通过 JSON.stringify 序列化的对象。 * @example * ```javascript * try { * ks.setStorageSync('key', 'value'); * } catch (e) { * // 缓存失败 * } * * ``` * */ setStorageSync(key: string, data: unknown): void; }