12345678910111213141516171819202122232425262728293031323334353637 |
- /**
- * 永久化存储,存储在本地文件
- */
- export class AppStorageHelper {
- private constructor() {
- }
- /**
- * 缓存
- * @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)
- }
- }
|