国际化

This commit is contained in:
2025-09-12 13:13:29 +08:00
parent caef2ecc53
commit 2ebaeac1e9
18 changed files with 533 additions and 331 deletions

View File

@@ -1,24 +1,22 @@
<template>
<view class="zd_container">
<nav-bar title="设置" :inner2="true" @goIn="goIn"></nav-bar>
<nav-bar :title="$t('login.settings')" :inner2="true" @goIn="goIn" :show="false"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper">
<view class="setup-item">
<view class="setup-label">LMS地址</view>
<input type="text" class="setup-input" placeholder="请输入服务器地址" v-model="addrip">
<view>
<view class="filter_label">{{$t('setting.language')}}</view>
<view class="filter_select">
<uni-data-select :placeholder="$t('utils.selectPlaceholder')" :emptyTips="$t('utils.selectEmptyTips')" v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
</view>
</view>
<view>
<view class="filter_label">{{$t('setting.server')}}</view>
<input type="text" class="filter_input" v-model="addrip">
</view>
<!-- <view class="setup-item">
<view class="setup-label">ACS地址</view>
<input type="text" class="setup-input" placeholder="请输入ACS地址" v-model="acsip">
</view> -->
<!-- <view class="setup-item">
<view class="setup-label">刷新时间(s)</view>
<input type="text" class="setup-input" placeholder="请输入刷新时间" v-model="setTime">
</view> -->
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-24 button-primary" @click="_submit">确认</button>
<button class="zd-col-24 button-primary" @click="_submit">{{$t('button.confirm')}}</button>
</view>
</view>
</template>
@@ -32,11 +30,43 @@
data() {
return {
addrip: this.$store.getters.baseUrl,
acsip: this.$store.getters.acsUrl,
setTime: this.$store.getters.setTime / 1000
options1: [{text: '中文',value: 'zh-Hans'}, {text: 'English', value: 'en'}],
index1: '',
systemLocale: '',
applicationLocale: ''
};
},
onLoad() {
let systemInfo = uni.getSystemInfoSync();
this.systemLocale = systemInfo.language;
this.applicationLocale = uni.getLocale();
console.log(this.applicationLocale)
this.index1 = this.applicationLocale.split('-')[0]
this.isAndroid = systemInfo.platform.toLowerCase() === 'android';
uni.onLocaleChange((e) => {
this.applicationLocale = e.locale;
})
},
methods: {
onLocaleChange(e) {
if (this.isAndroid) {
uni.showModal({
content: this.$t('setting.language-change-confirm'),
success: (res) => {
if (res.confirm) {
uni.setLocale(e);
}
}
})
} else {
uni.setLocale(e);
this.$i18n.locale = e;
}
},
selectChange1(e) {
this.onLocaleChange(e)
this.index1 = e
},
goIn () {
uni.redirectTo({
url: '/pages/login/login'
@@ -44,28 +74,10 @@
},
_submit () {
if (this.addrip === '') {
uni.showToast({
title: '请填写LMS地址',
icon: 'none'
})
return
}
if (this.acsip === '') {
uni.showToast({
title: '请填写ACS地址',
icon: 'none'
})
return
}
// if (this.setTime === '') {
// uni.showToast({
// title: '请填写刷新时间',
// icon: 'none'
// })
// return
// }
// 存值
this.$store.dispatch('setConfig',{baseUrl: this.addrip, acsUrl: this.acsip, setTime: this.setTime * 1000})
this.$store.dispatch('setConfig',{baseUrl: this.addrip})
uni.redirectTo({
url: '/pages/login/login'
})
@@ -73,19 +85,3 @@
}
}
</script>
<style lang="stylus">
@import '../../common/style/mixin.styl';
.setup-item
width 100%
margin-bottom 40rpx
.setup-label
_font(24rpx,40rpx,#000)
.setup-input
_wh(100%, 80rpx)
background #fff
_font(28rpx,80rpx,#323232)
padding 0 28rpx
border 2px solid #e9ecf3
border-radius 12rpx
</style>