mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 13:31:04 +00:00
fix(用户端): uni 框架组件语言与项目 locale 对齐,修复弹窗按钮中英文混排
uni.showModal 等内置组件文案跟随浏览器系统语言(测试环境 en-US 显示 Cancel/OK),与 vue-i18n 的中文文案混排;main.js 启动时 uni.setLocale 对齐项目 locale(zh-CN 映射为 uni 的 zh-Hans)
This commit is contained in:
parent
d020b35cd5
commit
e81b48ff57
@ -96,6 +96,20 @@ function loadStatisticsScript(src) {
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
|
||||
// uni 框架内置组件(showModal 确认/取消按钮等)语言跟随浏览器系统,
|
||||
// 与项目 vue-i18n 的 locale 不一致时会出现中英文混排(如按钮显示 Cancel/OK),
|
||||
// 这里将 uni 框架语言与项目 locale 对齐(legacy 模式下 global.locale 是 ref)
|
||||
try {
|
||||
var uniLocale = i18n.global.locale
|
||||
if (uniLocale && typeof uniLocale.value === 'string') uniLocale = uniLocale.value
|
||||
// uni 框架使用 BCP 47 风格(zh-Hans/zh-Hant/en),项目用 zh-CN 需映射
|
||||
if (uniLocale === 'zh-CN') uniLocale = 'zh-Hans'
|
||||
else if (uniLocale === 'zh-TW' || uniLocale === 'zh-HK') uniLocale = 'zh-Hant'
|
||||
if (typeof uniLocale === 'string' && uniLocale) uni.setLocale(uniLocale)
|
||||
} catch (e) {
|
||||
// 部分 uni 版本/平台无此 API,忽略
|
||||
}
|
||||
|
||||
// Pinia(实例已在 store/index.js 模块加载时创建并 setActivePinia)
|
||||
app.use(pinia)
|
||||
app.use(i18n)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user