From 70930f80373fbbb73122afba261f2b6538ba7793 Mon Sep 17 00:00:00 2001 From: dgflash Date: Wed, 22 Apr 2026 09:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E7=9C=9F=E6=9C=BA=E8=B0=83=E8=AF=95=E7=8E=AF=E5=A2=83=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/common/storage/StorageSecuritySimple.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/core/common/storage/StorageSecuritySimple.ts b/assets/core/common/storage/StorageSecuritySimple.ts index 5848a9d..2e88019 100644 --- a/assets/core/common/storage/StorageSecuritySimple.ts +++ b/assets/core/common/storage/StorageSecuritySimple.ts @@ -35,16 +35,17 @@ export class StorageSecuritySimple implements IStorageSecurity { init() { this.secretkey = this.key + this.iv; - // 预计算密钥字节数组,避免每次加密时重复计算 - this.secretKeyBytes = this.stringToBytes(this.secretkey); - - // 初始化编码器(只创建一次) - if (!StorageSecuritySimple.encoder) { + + // 初始化编码器(只创建一次)- 先检测是否支持 TextEncoder + if (typeof TextEncoder !== 'undefined' && !StorageSecuritySimple.encoder) { StorageSecuritySimple.encoder = new TextEncoder(); } - if (!StorageSecuritySimple.decoder) { + if (typeof TextDecoder !== 'undefined' && !StorageSecuritySimple.decoder) { StorageSecuritySimple.decoder = new TextDecoder(); } + + // 预计算密钥字节数组,避免每次加密时重复计算 + this.secretKeyBytes = this.stringToBytes(this.secretkey); } /**