|
|
@@ -10,12 +10,18 @@ export default class StorageUtil {
|
|
|
* @param decrypt 是否需要解密
|
|
|
*/
|
|
|
public getStorage(key: string, decrypt = true): any {
|
|
|
- if (cc.sys.localStorage.getItem(key)) {
|
|
|
- if(decrypt){
|
|
|
+ let value = cc.sys.localStorage.getItem(key);
|
|
|
+ if (value) {
|
|
|
+ if (decrypt) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- return JSON.parse(cc.sys.localStorage.getItem(key));
|
|
|
+ try {
|
|
|
+ let new_value = JSON.parse(value)
|
|
|
+ return new_value;
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
return null;
|