diff --git a/common/js/lang.js b/common/js/lang.js index 7029c04..f8bb9a3 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -494,7 +494,6 @@ export default { _langRecursionDepth++; try { let _page = getCurrentPages()[getCurrentPages().length - 1]; - if (!_page) return typeof field === 'string' ? field : String(field || ''); const locale = getCurrentLocale(); @@ -505,11 +504,15 @@ export default { var lang = loadLangPackSync(locale, 'common'); //当前页面语言包(同步加载) - let route = _page.route; - langPath = processRoutePath(route); + // 关键修复:不依赖 _page 是否存在,页面未完全初始化时至少能使用 common 语言包 + let route = ''; + if (_page) { + route = _page.route || (_page.$page && _page.$page.path) || ''; + } + langPath = route ? processRoutePath(route) : ''; - // 加载当前页面语言包 - let currentPageLang = loadLangPackSync(locale, langPath); + // 加载当前页面语言包,langPath 为空时返回空对象(只使用 common) + let currentPageLang = langPath ? loadLangPackSync(locale, langPath) : {}; // 合并语言包 + 远端 KV 覆写 // 关键修复:使用深复制代替 Object.assign,避免 applyOverrides 污染 loadedLangPacks 缓存