修复本地存储对象传递布尔值会触发catch的问题

This commit is contained in:
dgflash
2022-08-29 15:21:12 +08:00
parent 7daabf3d89
commit 1b90b7c10f
4 changed files with 9 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import { PREVIEW } from "cc/env";
import { md5 } from "../../../libs/security/Md5";
import { EncryptUtil } from "./EncryptUtil";
/** 本地存储 */
export module storage {
let _key: string | null = null;
let _iv: string | null = null;
@@ -63,9 +64,10 @@ export module storage {
else if (typeof value === 'number') {
value = value + "";
}
if (!PREVIEW && null != _key && null != _iv) {
try {
value = EncryptUtil.aesEncrypt(value, _key, _iv);
value = EncryptUtil.aesEncrypt(`${value}`, _key, _iv);
}
catch (e) {
value = null;
@@ -99,8 +101,8 @@ export module storage {
catch (e) {
str = null;
}
}
if (null == defaultValue || typeof defaultValue === 'string') {
return str;
}

View File

@@ -10,8 +10,7 @@
"userData": {
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"dependencies": []
"loadPluginInNative": false,
"loadPluginInEditor": false
}
}

View File

@@ -10,6 +10,7 @@
"userData": {
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true
"loadPluginInNative": false,
"executionScope": "global"
}
}

View File

@@ -11,6 +11,6 @@
"dependencies": [],
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true
"loadPluginInNative": false
}
}