1234567891011121314151617181920212223242526272829303132333435 |
- /**
- * 永久化存储,存储在本地文件
- */
- export class AppStorageHelper {
- /**
- * 缓存
- * @param key
- * @param value
- */
- public static save<T>(key: string, value: T | undefined) {
- if (value === undefined || value === null) {
- PersistentStorage.deleteProp(key)
- } else {
- PersistentStorage.persistProp(key, value)
- }
- }
- /**
- * 删除缓存
- * @param key
- * @param value
- */
- public static delete(key: string) {
- PersistentStorage.deleteProp(key)
- }
- /**
- * 获取已缓存的内容
- * @param key
- * @returns
- */
- public static get<T>(key: string): T | undefined {
- return AppStorage.get<T>(key)
- }
- }
|