This commit is contained in:
星河下的稻草人
2024-03-06 20:59:01 +08:00
parent 755f0cd208
commit c595061dc8
6 changed files with 1057 additions and 125 deletions

7
src/lang/en_us.js Normal file
View File

@@ -0,0 +1,7 @@
// en_us.js文件
export default {
app: {
hello: 'HelloWorld!'
}
}

36
src/lang/index.js Normal file
View File

@@ -0,0 +1,36 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import {Locale} from 'vant'
import enUS from 'vant/lib/locale/lang/en-US'
import zhCN from 'vant/lib/locale/lang/zh-CN'
import enLocale from './en_us'
import zhLocale from './zh_cn'
Vue.use(VueI18n)
const messages = {
en: {
...enUS,
...enLocale
},
zh: {
...zhCN,
...zhLocale
}
}
const i18n = new VueI18n({
locale: 'zh', // 设置默认语言
messages: messages // 设置资源文件对象
})
// 更新vant组件库本身的语言变化支持国际化
function vantLocales (lang) {
if (lang === 'en') {
Locale.use(lang, enUS)
} else if (lang === 'zh') {
Locale.use(lang, zhCN)
}
}
export {i18n, vantLocales}

6
src/lang/zh_cn.js Normal file
View File

@@ -0,0 +1,6 @@
// zh_cn.js文件
export default {
app: {
hello: '你好,世界!'
}
}

View File

@@ -138,8 +138,9 @@ const transform: AxiosTransform = {
if(config.url && config.url.endsWith("domain.txt")){
return config
}else if(domain && domain.length > 0){
let domainUrl = domain[Math.floor((Math.random()*domain.length))];
config.url = domainUrl + config.url;
// let domainUrl = domain[Math.floor((Math.random()*domain.length))];
// config.url = domainUrl + config.url;
// config.url = domainUrl + config.url;
}else if(apiUrl && isString(apiUrl)){
config.url = `${apiUrl}${config.url}`;
}