UNPKG

xframelib

Version:

积累的前端开发基础库,来源于项目和服务于项目。

67 lines (66 loc) 1.62 kB
/** * 创建本地缓存对象 */ declare class StorageHelper { private prefixKey; private storage; constructor(prefixKey?: string, storage?: Storage); private getKey; /** * @description 设置缓存 * @param {string} key 缓存键 * @param {*} value 缓存值 * @param expire 超时时间为秒 */ set(key: string, value: any, expire?: number | null): void; /** * 读取缓存 * @param {string} key 缓存键 * @param {*=} def 默认值 */ get(key: string, def?: any): any; /** * 获取存储对象,带expire属性 * 返回: * { * value:any, * expire:null|Time * } */ getJsonObject(key: string): any; /** * 从缓存删除某项 * @param {string} key */ remove(key: string): void; /** * 清空所有缓存 * @memberOf Cache */ clear(): void; /** * 设置cookie * @param {string} name cookie 名称 * @param {*} value cookie 值 * @param {number=} expire 过期时间 * 如果过期时间为设置,默认关闭浏览器自动删除 * @example */ setCookie(name: string, value: any, expire?: number | null): void; /** * 根据名字获取cookie值 * @param name */ getCookie(name: string): string; /** * 根据名字删除指定的cookie * @param {string} key */ removeCookie(key: string): void; /** * 清空cookie,使所有cookie失效 */ clearCookie(): void; } export declare const storage: StorageHelper; export default StorageHelper;