新增h5qrcode依赖
This commit is contained in:
@@ -4,14 +4,33 @@ import { createSSRApp } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zhCN from './locale/zh-CN.js'
|
||||
import enUS from './locale/en-US.js'
|
||||
import idID from './locale/id-ID.js'
|
||||
import uView from '@climblee/uv-ui'
|
||||
import { initConsoleControl } from './config/console.js'
|
||||
|
||||
// 初始化 console 控制
|
||||
initConsoleControl()
|
||||
|
||||
// 检测是否为 H5 环境
|
||||
const isH5Platform = () => {
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
return systemInfo.platform === 'web' || systemInfo.uniPlatform === 'web' ||
|
||||
(typeof window !== 'undefined' && typeof document !== 'undefined')
|
||||
} catch (e) {
|
||||
// 如果获取系统信息失败,尝试通过全局对象判断
|
||||
return typeof window !== 'undefined' && typeof document !== 'undefined'
|
||||
}
|
||||
}
|
||||
|
||||
// 获取系统语言
|
||||
const getSystemLanguage = () => {
|
||||
// H5 环境默认使用印尼语
|
||||
if (isH5Platform()) {
|
||||
return 'id-ID'
|
||||
}
|
||||
|
||||
// 非 H5 环境根据系统语言判断
|
||||
let language = 'en-US'
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
@@ -22,6 +41,8 @@ const getSystemLanguage = () => {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取系统语言失败:', e)
|
||||
// 默认使用中文
|
||||
language = 'zh-CN'
|
||||
}
|
||||
return language
|
||||
}
|
||||
@@ -38,7 +59,8 @@ const getSavedLanguage = () => {
|
||||
return systemLang
|
||||
} catch (e) {
|
||||
console.error('语言设置出错:', e)
|
||||
return 'zh-CN'
|
||||
// 出错时根据平台返回默认语言
|
||||
return isH5Platform() ? 'id-ID' : 'zh-CN'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +103,8 @@ function getI18nInstance() {
|
||||
fallbackLocale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS
|
||||
'en-US': enUS,
|
||||
'id-ID': idID
|
||||
},
|
||||
silentTranslationWarn: true,
|
||||
silentFallbackWarn: true
|
||||
|
||||
Reference in New Issue
Block a user