From a86573acecd6c23414effa587b00a5a998f547ba Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 4 Sep 2025 15:35:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?LayerPopUp.onAdded=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8Promise=EF=BC=8C=E4=BC=9A=E7=AD=89Promise?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=B5=81=E7=A8=8B=E5=A4=84=E7=90=86=E5=AE=8C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=98=BE=E7=A4=BAPopUp=E5=B1=82=E7=9A=84?= =?UTF-8?q?=E9=81=AE=E7=BD=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/gui/layer/LayerDialog.ts | 2 +- assets/core/gui/layer/LayerPopup.ts | 64 ++++++++++++---------------- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/assets/core/gui/layer/LayerDialog.ts b/assets/core/gui/layer/LayerDialog.ts index ff7d51c..7f9a150 100644 --- a/assets/core/gui/layer/LayerDialog.ts +++ b/assets/core/gui/layer/LayerDialog.ts @@ -65,7 +65,7 @@ export class LayerDialog extends LayerPopUp { setTimeout(this.next.bind(this), 0); } - protected setBlackDisable() { + protected closeUI() { if (this.params.length == 0) { this.black.enabled = false; this.closeVacancyRemove(); diff --git a/assets/core/gui/layer/LayerPopup.ts b/assets/core/gui/layer/LayerPopup.ts index c950327..e86ad2d 100644 --- a/assets/core/gui/layer/LayerPopup.ts +++ b/assets/core/gui/layer/LayerPopup.ts @@ -25,38 +25,36 @@ export class LayerPopUp extends LayerUI { } private onChildAdded(child: Node) { - if (this.mask) { - this.mask.setSiblingIndex(this.children.length - 2); - } + if (this.mask) this.mask.setSiblingIndex(this.children.length - 2); } private onChildRemoved(child: Node) { - if (this.mask) { - this.mask.setSiblingIndex(this.children.length - 2); - } + if (this.mask) this.mask.setSiblingIndex(this.children.length - 2); } - protected async showUi(uip: UIParams): Promise { - const r = await super.showUi(uip); - if (r) { - // 界面加载完成显示时,启动触摸非窗口区域关闭 - this.openVacancyRemove(uip.config); + protected showUi(uip: UIParams): Promise { + return new Promise(async (resolve) => { + const r = await super.showUi(uip); + if (r) { + // 界面加载完成显示时,启动触摸非窗口区域关闭 + this.openVacancyRemove(uip.config); - // 界面加载完成显示时,层级事件阻挡 - this.black.enabled = true; - } - return r; + // 界面加载完成显示时,层级事件阻挡 + this.black.enabled = true; + } + resolve(r); + }); } protected onCloseWindow(uip: UIParams) { super.onCloseWindow(uip); // 界面关闭后,关闭触摸事件阻挡、关闭触摸非窗口区域关闭、关闭遮罩 - this.setBlackDisable(); + this.closeUI(); } /** 设置触摸事件阻挡 */ - protected setBlackDisable() { + protected closeUI() { // 所有弹窗关闭后,关闭事件阻挡功能 if (this.ui_nodes.size == 0) { if (this.black) this.black.enabled = false; @@ -77,9 +75,7 @@ export class LayerPopUp extends LayerUI { } } - if (flag) { - this.mask.parent = null; - } + if (flag) this.mask.parent = null; } /** 启动触摸非窗口区域关闭 */ @@ -93,19 +89,7 @@ export class LayerPopUp extends LayerUI { this.black.enabled = false; } - if (config.mask) { - this.mask.parent = this; - } - } - - /** 触摸非窗口区域关闭 */ - private onTouchEnd(event: EventTouch) { - if (this.ui_nodes.size > 0) { - let vp = this.ui_nodes.array[this.ui_nodes.size - 1]; - if (vp.valid && vp.config.vacancy) { - this.remove(vp.config.prefab, vp.config.destroy); - } - } + if (config.mask) this.mask.parent = this; } /** 关闭触摸非窗口区域关闭 */ @@ -123,10 +107,18 @@ export class LayerPopUp extends LayerUI { } } + /** 触摸非窗口区域关闭 */ + private onTouchEnd(event: EventTouch) { + if (this.ui_nodes.size > 0) { + let vp = this.ui_nodes.array[this.ui_nodes.size - 1]; + if (vp.valid && vp.config.vacancy) { + this.remove(vp.config.prefab, vp.config.destroy); + } + } + } + clear(isDestroy: boolean) { super.clear(isDestroy) - if (this.black) this.black.enabled = false; - this.closeVacancyRemove(); - this.closeMask(); + this.closeUI(); } } \ No newline at end of file -- Gitee From 99f53fbe463e6deb1c1637989f6ca50ac8f82253 Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 4 Sep 2025 18:07:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.=20LayerPopUp=20=E5=B1=82=E5=9C=A8?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=95=8C=E9=9D=A2=E6=97=B6=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=BD=93=E5=89=8D=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=89=A9=E4=B8=8B=E4=B8=80=E4=B8=AA=E6=B2=A1=E6=9C=89=E5=BC=80?= =?UTF-8?q?=E5=90=AFMask=E5=B1=82=E5=8A=9F=E8=83=BD=E7=9A=84=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E5=88=99=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD?= =?UTF-8?q?Mask=E9=81=AE=E7=BD=A9=E5=B1=82=E7=9A=84=E6=98=BE=E7=A4=BA=202.?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=A0=E5=AF=86=E5=9C=A8=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E6=B8=B8=E6=88=8F=E5=B9=B3=E5=8F=B0=E7=9C=9F=E6=9C=BA?= =?UTF-8?q?=E4=B8=8A=EF=BC=8C=E8=A7=A3=E6=9E=90=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/storage/StorageSecuritySimple.ts | 108 +----------------- assets/core/gui/layer/LayerPopup.ts | 12 +- 2 files changed, 16 insertions(+), 104 deletions(-) diff --git a/assets/core/common/storage/StorageSecuritySimple.ts b/assets/core/common/storage/StorageSecuritySimple.ts index f9aad78..6747f1f 100644 --- a/assets/core/common/storage/StorageSecuritySimple.ts +++ b/assets/core/common/storage/StorageSecuritySimple.ts @@ -27,12 +27,13 @@ export class StorageSecuritySimple implements IStorageSecurity { */ encrypt(data: string): string { if (!data) return ''; + return this.xorEncrypt(data); + } - // 先进行异或加密 - const xorEncrypted = this.xorEncrypt(data); - - // 然后进行 Base64 编码 - return this.base64Encode(xorEncrypted); + /** 解密字符串 */ + decrypt(encryptedData: string): string { + if (!encryptedData) return ''; + return this.xorDecrypt(encryptedData); } /** 异或加密 */ @@ -46,108 +47,11 @@ export class StorageSecuritySimple implements IStorageSecurity { return result; } - /** 解密字符串 */ - decrypt(encryptedData: string): string { - if (!encryptedData) return ''; - - // 先进行 Base64 解码 - const base64Decoded = this.base64Decode(encryptedData); - - // 然后进行异或解密 - return this.xorDecrypt(base64Decoded); - } - /** 异或解密 */ private xorDecrypt(encryptedData: string): string { return this.xorEncrypt(encryptedData); // 异或操作是可逆的 } - /** - * 安全的 Base64 编码 - */ - private base64Encode(data: string): string { - // 使用浏览器或 Node.js 的 Base64 编码 - if (typeof btoa === 'function') { - return btoa(data); - } - else if (typeof Buffer !== 'undefined') { - return Buffer.from(data).toString('base64'); - } - else { - // 回退到纯 JavaScript 实现 - return this.fallbackBase64Encode(data); - } - } - - /** - * 安全的 Base64 解码 - */ - private base64Decode(base64String: string): string { - // 使用浏览器或 Node.js 的 Base64 解码 - if (typeof atob === 'function') { - return atob(base64String); - } - else if (typeof Buffer !== 'undefined') { - return Buffer.from(base64String, 'base64').toString('utf8'); - } - else { - // 回退到纯 JavaScript 实现 - return this.fallbackBase64Decode(base64String); - } - } - - /** - * 回退的 Base64 编码实现 - */ - private fallbackBase64Encode(data: string): string { - const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - let output = ''; - let i = 0; - - while (i < data.length) { - const byte1 = data.charCodeAt(i++); - const byte2 = data.charCodeAt(i++); - const byte3 = data.charCodeAt(i++); - - const enc1 = byte1 >> 2; - const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4); - const enc3 = isNaN(byte2) ? 64 : ((byte2 & 15) << 2) | (byte3 >> 6); - const enc4 = isNaN(byte3) ? 64 : byte3 & 63; - - output += chars.charAt(enc1) + chars.charAt(enc2) + chars.charAt(enc3) + chars.charAt(enc4); - } - - return output; - } - - /** - * 回退的 Base64 解码实现 - */ - private fallbackBase64Decode(base64String: string): string { - const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - let output = ''; - let i = 0; - - base64String = base64String.replace(/[^A-Za-z0-9+/]/g, ''); - - while (i < base64String.length) { - const enc1 = chars.indexOf(base64String.charAt(i++)); - const enc2 = chars.indexOf(base64String.charAt(i++)); - const enc3 = chars.indexOf(base64String.charAt(i++)); - const enc4 = chars.indexOf(base64String.charAt(i++)); - - const byte1 = (enc1 << 2) | (enc2 >> 4); - const byte2 = ((enc2 & 15) << 4) | (enc3 >> 2); - const byte3 = ((enc3 & 3) << 6) | enc4; - - output += String.fromCharCode(byte1); - if (enc3 !== 64) output += String.fromCharCode(byte2); - if (enc4 !== 64) output += String.fromCharCode(byte3); - } - - return output; - } - encryptKey(str: string): string { return this.encrypt(str); } diff --git a/assets/core/gui/layer/LayerPopup.ts b/assets/core/gui/layer/LayerPopup.ts index e86ad2d..95d4d63 100644 --- a/assets/core/gui/layer/LayerPopup.ts +++ b/assets/core/gui/layer/LayerPopup.ts @@ -59,8 +59,8 @@ export class LayerPopUp extends LayerUI { if (this.ui_nodes.size == 0) { if (this.black) this.black.enabled = false; this.closeVacancyRemove(); - this.closeMask(); } + this.closeMask(); } /** 关闭遮罩 */ @@ -75,7 +75,15 @@ export class LayerPopUp extends LayerUI { } } - if (flag) this.mask.parent = null; + if (flag) { + if (this.ui_nodes.size == 0) { + this.mask.uiSprite.enabled = true; + this.mask.parent = null; + } + else { + this.mask.uiSprite.enabled = false; + } + } } /** 启动触摸非窗口区域关闭 */ -- Gitee