|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<view class="cwg-language">
|
|
<view class="cwg-language">
|
|
|
- <cwg-dropdown :menu-list="customMenuList" @menuClick="handleMenuClick" showActive :activeKey="curLange">
|
|
|
|
|
|
|
+ <cwg-dropdown :menu-list="customMenuList" @menuClick="handleMenuClick" showActive :activeKey="lang">
|
|
|
<view class="pc-header-btn">
|
|
<view class="pc-header-btn">
|
|
|
<cwg-icon name="cwg-lang" :color="iconColor " :size="20" />
|
|
<cwg-icon name="cwg-lang" :color="iconColor " :size="20" />
|
|
|
</view>
|
|
</view>
|
|
@@ -10,9 +10,9 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed,ref } from 'vue'
|
|
|
|
|
|
|
+import { computed } from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
-import { localesList, LANG_MAP } from '@/locale/index'
|
|
|
|
|
|
|
+import { localesList, switchAppLanguage } from '@/locale/index'
|
|
|
import { lang } from '@/composables/config'
|
|
import { lang } from '@/composables/config'
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
@@ -22,7 +22,6 @@ const props = defineProps({
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const curLange = ref(lang)
|
|
|
|
|
const { t, locale } = useI18n()
|
|
const { t, locale } = useI18n()
|
|
|
const customMenuList = computed(() =>
|
|
const customMenuList = computed(() =>
|
|
|
localesList.map((code) => ({
|
|
localesList.map((code) => ({
|
|
@@ -33,12 +32,7 @@ const customMenuList = computed(() =>
|
|
|
|
|
|
|
|
function handleMenuClick({ value }: { value: any }) {
|
|
function handleMenuClick({ value }: { value: any }) {
|
|
|
const type = value?.type ?? value
|
|
const type = value?.type ?? value
|
|
|
- if (!type) return
|
|
|
|
|
- locale.value = type
|
|
|
|
|
- lang.value = type
|
|
|
|
|
- curLange.value = type
|
|
|
|
|
- const localeValue = LANG_MAP[type] || 'zh-Hans'
|
|
|
|
|
- uni.setLocale(localeValue)
|
|
|
|
|
|
|
+ switchAppLanguage(type, { locale, lang })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getFlagSrc(code: string) {
|
|
function getFlagSrc(code: string) {
|