|
|
@@ -15,27 +15,30 @@
|
|
|
<app-iconfont icon="g-icon-cancel">{{ $t('routes.usercancel') }}</app-iconfont>
|
|
|
</template>
|
|
|
</Cell>
|
|
|
- <Cell is-link @click="changeLuanguage" v-if="i18nEnabled">
|
|
|
- <template #title>
|
|
|
+ <Field is-link v-if="i18nEnabled">
|
|
|
+ <template #left-icon>
|
|
|
<app-iconfont icon="g-icon-lang">{{ $t('mine.setting.language') }}</app-iconfont>
|
|
|
</template>
|
|
|
- <template #value>
|
|
|
- {{ i18n.global.locale === 'zh-CN' ? $t('mine.setting.chinese') : $t('mine.setting.english') }}
|
|
|
+ <template #button>
|
|
|
+ <app-select v-model="luanguage" :options="luanguageList" :optionProps="{ label: 'label', value: 'value' }" @confirm="changeLuanguage"/>
|
|
|
</template>
|
|
|
- </Cell>
|
|
|
+ </Field>
|
|
|
</CellGroup>
|
|
|
</div>
|
|
|
</app-view>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { Cell, CellGroup } from 'vant'
|
|
|
+import { Cell, CellGroup, Field } from 'vant'
|
|
|
import AppIconfont from '@/components/base/iconfont/index.vue'
|
|
|
import { i18n } from '@/stores'
|
|
|
import { Locale } from 'vant'
|
|
|
import { localData } from '@/stores/storage'
|
|
|
+import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
import enUS from 'vant/es/locale/lang/en-US'
|
|
|
import enCN from 'vant/es/locale/lang/zh-CN'
|
|
|
+import thTH from 'vant/es/locale/lang/th-TH'
|
|
|
+import router from '@/packages/gcszt/router'
|
|
|
|
|
|
defineProps({
|
|
|
i18nEnabled: {
|
|
|
@@ -48,16 +51,41 @@ defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const changeLuanguage = () => {
|
|
|
- if (i18n.global.locale === 'zh-CN') {
|
|
|
- i18n.global.locale = 'en-US'
|
|
|
- Locale.use(i18n.global.locale, enUS)
|
|
|
- } else {
|
|
|
- i18n.global.locale = 'zh-CN'
|
|
|
- Locale.use(i18n.global.locale, enCN)
|
|
|
+const { t } = i18n.global
|
|
|
+const luanguage = i18n.global.locale
|
|
|
+
|
|
|
+const luanguageList = [
|
|
|
+ {
|
|
|
+ label: t('mine.setting.chinese'),
|
|
|
+ value: 'zh-CN'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: t('mine.setting.english'),
|
|
|
+ value: 'en-US'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: t('mine.setting.enth'),
|
|
|
+ value: 'th-TH'
|
|
|
}
|
|
|
+]
|
|
|
+
|
|
|
+const changeLuanguage = (e) => {
|
|
|
+ i18n.global.locale = e
|
|
|
+ /// 返回上一页
|
|
|
+ router.back()
|
|
|
/// 设置语言
|
|
|
localData.setValue('appLanguage', i18n.global.locale)
|
|
|
+ switch (e) {
|
|
|
+ case 'zh-CN':
|
|
|
+ Locale.use(i18n.global.locale, enCN)
|
|
|
+ break;
|
|
|
+ case 'en-US':
|
|
|
+ Locale.use(i18n.global.locale, enUS)
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ Locale.use(i18n.global.locale, thTH)
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
</script>
|