interface Store { [key: string]: any; } /** * 存储类型 */ type StoreType = Store | string | number | boolean; export declare const EnumStoreType: { /** * localStorage */ readonly LOCAl: "localStorage"; /** * sessionStorage */ readonly SESSION: "sessionStorage"; }; export type EnumStoreType = (typeof EnumStoreType)[keyof typeof EnumStoreType]; /** * 设置本地存储, 默认`type` 为`localStorage` * @param key - 字符串唯一key * @param value - 需要存储的内容 * @param type - 存储类型 {@link EnumStoreType} * @example * ```ts * let value = { name: '张三', age: 18 } * // localStorage * setStore('userInfo', value) * // sessionStorage * setStore('userInfo', value, EnumStoreType.SESSION) * ``` */ export declare function setStore(key: string, value: StoreType, type?: EnumStoreType): void; /** * 获取本地存储, 默认`type` 为`localStorage` * @param key - 字符串key * @param type - 存储类型 {@link EnumStoreType} * @returns 获取到的内容 * * @example * ```ts * // localStorage * const value = getStore('token') * // sessionStorage * const value = getStore('token', EnumStoreType.SESSION) * ``` */ export declare function getStore(key: string, type?: EnumStoreType): T | null; /** * 删除指定key的Local * @param key - 字符串key * * @example * ```ts * // localStorage * const value = removeStore('token') * // sessionStorage * const value = removeStore('token', EnumStoreType.SESSION) * ``` */ export declare function removeStore(key: string, type?: EnumStoreType): void; /** * 清空所有Local */ export declare function clearStore(type?: EnumStoreType): void; /** * 设置LocalStorage * @param key - 字符串唯一key * @param content - 需要存储的内容 * @returns void * @example * ```ts * // localStorage * setLocal('token','123') * ``` */ export declare const setLocal: (key: string, content: StoreType) => void; /** * 获取LocalStorage * @param key - 字符串key * @returns 获取到的内容 * @example * ```ts * const value = getLocal('token') * ``` */ export declare const getLocal: (key: string) => T | null; /** * 删除指定key的LocalStorage * @param key - 字符串key * @returns void * @example * ```ts * removeLocal('token') * ``` */ export declare const removeLocal: (key: string) => void; /** * 清除所有LocalStorage * @example * ```ts * clearLocal() * ``` */ export declare const clearLocal: () => void; /** * 设置sessionStorage * @param key - 字符串唯一key * @param content - 需要存储的内容 * @returns void * @example * ```ts * setSession('token','123') * ``` */ export declare const setSession: (key: string, content: StoreType) => void; /** * 获取sessionStorage * @param key - 字符串key * @returns - 获取到的内容 * @example * ```ts * const value = getSession('token') * ``` */ export declare const getSession: (key: string) => T | null; /** * 删除指定key的sessionStorage * @param key - 字符串key * @example * ```ts * const value = removeSession('token') * ``` */ export declare const removeSession: (key: string) => void; /** * 清除所有sessionStorage * @example * ```ts * const value = clearSession() * ``` */ export declare const clearSession: () => void; export {};