/** * 本地存储工具类 * @author 冯聪 */ export default class StorageUtil { /** * 获取存储 * @param key key值 * @param decrypt 是否需要解密 */ public getStorage(key: string, decrypt = true): any { if (cc.sys.localStorage.getItem(key)) { if(decrypt){ } return JSON.parse(cc.sys.localStorage.getItem(key)); } else { return null; } } /** * 存储 * @param key key值 * @param value 要存储的value值 * @param encrypt 是否需要加密 */ public setStorage(key: string, value: any, encrypt: boolean = true) { if (encrypt) { value = mk.encrypt.encrypt(value, g.storageData.storageKey, g.appData.appId); } cc.sys.localStorage.setItem(key, JSON.stringify(value)); } }