解决微信小程序首页空白问题。

This commit is contained in:
cst61
2026-02-01 09:21:11 +08:00
parent 80d6d46182
commit cc01c4dc47
454 changed files with 404 additions and 62235 deletions

View File

@@ -1,96 +0,0 @@
"use strict";
const common_vendor = require("../common/vendor.js");
const lang_en = require("./en.js");
const lang_zhHans = require("./zh-Hans.js");
const uniStarter_config = require("../uni-starter.config.js");
const { i18n: { enable: i18nEnable } } = uniStarter_config.config;
const messages = {
"en": lang_en.langEn,
"zh-Hans": lang_zhHans.zhHans
};
let currentLang;
if (i18nEnable) {
currentLang = common_vendor.index.getStorageSync("CURRENT_LANG");
} else {
currentLang = "zh-Hans";
}
if (!currentLang) {
if (common_vendor.index.getLocale) {
common_vendor.index.__f__("log", "at lang/i18n.js:18", "获取应用语言:", common_vendor.index.getLocale());
let language = "en";
if (common_vendor.index.getLocale() != "en") {
language = "zh-Hans";
}
common_vendor.index.setStorageSync("CURRENT_LANG", language);
currentLang = language;
} else {
common_vendor.index.getSystemInfo({
success: function(res) {
common_vendor.index.__f__("log", "at lang/i18n.js:28", "获取设备信息:", res);
let language = "zh-Hans";
if (res.language == "en") {
language = "en";
}
common_vendor.index.setStorageSync("CURRENT_LANG", language);
currentLang = language;
},
fail: (err) => {
common_vendor.index.__f__("error", "at lang/i18n.js:37", err);
}
});
}
}
let i18nConfig = {
locale: currentLang,
// set locale
messages
// set locale messages
};
const i18n = common_vendor.createI18n(i18nConfig);
if (i18nEnable) {
common_vendor.index.__f__("log", "at lang/i18n.js:65", `
你已开启多语言国际化将自动根据语言获取【lang/en.js】或【lang/zh-Hans.js】文件中配置的tabbar的值
覆盖你在pages.json中的tabbar的值
如果你不需要多语言国际化请打开配置文件uni-starter.config.js找到 -> i18n -> enable把值设置为false
`);
let initLanguageAfter = () => {
function $i18n(e) {
try {
if (i18n && i18n.global && i18n.global.messages && i18n.global.locale) {
return i18n.global.messages[i18n.global.locale][e];
}
if (i18n && i18n.messages && i18n.locale) {
return i18n.messages[i18n.locale][e];
}
return "";
} catch (error) {
common_vendor.index.__f__("error", "at lang/i18n.js:86", "[i18n] 获取翻译文本失败:", error);
return "";
}
}
setTimeout(function() {
try {
const tabbarText = $i18n("tabbar");
if (tabbarText) {
tabbarText.split(",").forEach((text, index) => {
common_vendor.index.setTabBarItem({
index,
text,
complete: () => {
}
});
});
}
} catch (error) {
common_vendor.index.__f__("error", "at lang/i18n.js:104", "[i18n] 更新 tabbar 失败:", error);
}
}, 1);
};
initLanguageAfter();
common_vendor.index.$on("changeLanguage", (e) => {
common_vendor.index.__f__("log", "at lang/i18n.js:110", "changeLanguage", e);
initLanguageAfter();
});
}
exports.i18n = i18n;
//# sourceMappingURL=../../.sourcemap/mp-weixin/lang/i18n.js.map