From 954e8cad0be94ec348674a49a12e55c41f62825c Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Tue, 29 Sep 2026 11:12:58 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=8F=8Arevert=20lang.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/lang.js | 37 +++++++++++++++++++++++-------------- package.json | 3 +-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/common/js/lang.js b/common/js/lang.js index 0ce0669..4669648 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -489,27 +489,36 @@ function isBundleComplete(tree) { return false; } - // 2) tree 不能是空对象(空对象没有任何可用文案, 显然不可用) + // 2) tree 不能是空对象(空对象没有 common 也没有 components, 显然不可用) const treeKeys = Object.keys(tree); if (treeKeys.length === 0) { return false; } - // === 粗粒度校验(与上方设计哲学一致) === - // 不再硬性要求 common / components 节点必须同时存在。 - // 远端可能在某些时刻少发某个节点(部署期间、缓存未刷新、租户未配置 common 等), - // 此时仍应让 boot 成功写入 remoteTreeCache, 缺失字段由 $lang() 自然回落为空, - // UI 降级显示(空文案/空按钮文字), 而不是让整个 boot 失败导致整站变英文 / raw key。 - - // 软校验: components.privacyPopup(节点存在才检查, 避免 tree.components 为 undefined 时报错) - const privacyPopup = tree.components && tree.components.privacyPopup; - if (privacyPopup && typeof privacyPopup === 'object') { - // defaultAppNameMp 存在性仅作诊断, 不阻止 boot - if (typeof privacyPopup.defaultAppNameMp !== 'string' || !privacyPopup.defaultAppNameMp) { - // 软校验不阻止 boot, 仅记录(暂无控制台输出, 避免污染生产) - } + // 3) tree 必须有 common 节点(基础文案, 几乎所有 UI 都依赖) + if (!tree.common || typeof tree.common !== 'object') { + return false; } + // 4) tree 必须有 components 节点(组件级文案) + if (!tree.components || typeof tree.components !== 'object') { + return false; + } + + // === 以下为软校验(只 warn 不 return false) === + // 设计: 不再因为"缺某个 key"就让整个 boot 失败 + // 缺失的字段让 $lang() 自然返回空, UI 降级显示 + + // 软校验 1: components.privacyPopup + const privacyPopup = tree.components.privacyPopup; + if (!privacyPopup || typeof privacyPopup !== 'object') { + // 软校验不阻止 boot, 仅记录(暂无控制台输出, 避免污染生产) + } else if (typeof privacyPopup.defaultAppNameMp !== 'string' || !privacyPopup.defaultAppNameMp) { + // 软校验不阻止 boot, 仅记录(暂无控制台输出, 避免污染生产) + } + + // 软校验 2: 哪些 key 看起来像隐私弹窗,但在错误位置?(诊断) + // 此处仅保留注释说明, 不在生产代码中输出 return true; } diff --git a/package.json b/package.json index 33f4afd..3db959f 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "zion-uniapp-mp-load-package": "^1.0.13" }, "dependencies": { - "jweixin-module": "^1.6.0", - "playwright-core": "^1.63.0" + "jweixin-module": "^1.6.0" }, "uni-app": { "scripts": {