diff --git a/assets/core/common/storage/StorageManager.ts b/assets/core/common/storage/StorageManager.ts index ca535b9..9553ff1 100644 --- a/assets/core/common/storage/StorageManager.ts +++ b/assets/core/common/storage/StorageManager.ts @@ -6,7 +6,7 @@ import { EncryptUtil } from "../../utils/EncryptUtil"; export class StorageManager { private _key: string | null = null; private _iv: string | null = null; - private _id: string = ""; + private _id: string = null!; /** * 初始化密钥 @@ -35,7 +35,7 @@ export class StorageManager { * @returns */ set(key: string, value: any) { - var keywords = `${key}_${this._id}`; + var keywords = this.getKey(key); if (null == key) { console.error("存储的key不能为空"); @@ -84,7 +84,7 @@ export class StorageManager { return null!; } - key = `${key}_${this._id}`; + key = this.getKey(key); if (!PREVIEW) { key = EncryptUtil.md5(key); @@ -145,4 +145,11 @@ export class StorageManager { clear() { sys.localStorage.clear(); } + + private getKey(key: string): string { + if (this._id == null || this._id == "") { + return key; + } + return `${this._id}_${key}`; + } } \ No newline at end of file