From 73eceefbf01a6cb88b3fe37e7dc0396f6f308e62 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Tue, 10 Nov 2020 09:33:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 1 + src/api/index.ts | 20 +++++++++++++++----- src/components/NavTop.vue | 2 +- src/config/axiosConfig.ts | 2 +- src/i18n/init.ts | 8 ++++---- src/store/index.ts | 32 ++++++++++++++++++++++++++------ 6 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/App.vue b/src/App.vue index 72c0ee5..8aa74b9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,6 +29,7 @@ export default defineComponent({ console.log('ip') store.dispatch("getip"); store.commit('setWlan') + len.locale.value = !getValue("Lanvuage") ? 'zh' : getValue("Lanvuage"); router.push("/") } const zh = zhCN diff --git a/src/api/index.ts b/src/api/index.ts index fcc51f8..16b6b0c 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,7 +1,7 @@ import router from '@/router'; import store from '@/store'; import { LiveList, LivelistInfo, LoginData, UserInfo } from '@/types'; -import { saveValue } from '@/utils/common'; +import { getValue, saveValue } from '@/utils/common'; import { message } from 'ant-design-vue'; import { del, get, post, put, setToken } from './base' @@ -1014,11 +1014,21 @@ export async function luzhi(roomid: string){ export async function getaddr() { const res = await get('ip'); const gj = res.data.address.split("|")[0]; - if(gj == "CN"){ - return ["zh", "中文", '人民币¥']; - }else { - return ['en', 'English', '美元$'] + const lan = getValue("Lanvuage"); + if(lan != null && lan){ + if(gj == "CN"){ + return ['人民币¥']; + }else { + return [ '美元$'] + } + }else{ + if(gj == "CN"){ + return ["zh", "中文", '人民币¥']; + }else { + return ['en', 'English', '美元$'] + } } + } // export async function StopMCUMixTranscode(roomid: number) { diff --git a/src/components/NavTop.vue b/src/components/NavTop.vue index de01ca6..174d6fc 100644 --- a/src/components/NavTop.vue +++ b/src/components/NavTop.vue @@ -307,7 +307,7 @@ export default defineComponent({ languagelist.value=await getlanguages() console.log(routes.path) nowroute.value=routes.path - lan.locale.value = userinfo.value.languageValue + // lan.locale.value = userinfo.value.languageValue }) function zonechange(e?: any){ diff --git a/src/config/axiosConfig.ts b/src/config/axiosConfig.ts index c54753e..0a2cffd 100644 --- a/src/config/axiosConfig.ts +++ b/src/config/axiosConfig.ts @@ -2,7 +2,7 @@ import { getValue } from '@/utils/common'; import axios from 'axios' axios.defaults.baseURL = 'https://case.sy-my.net/beelink/public/home/'; axios.defaults.headers.common['Authorization'] = "Bearer " + getValue("token"); -axios.defaults.headers.common['Language'] = "Bearer " + getValue("Lanvuage"); +axios.defaults.headers.common['Language'] = !getValue("Lanvuage") ? 'zh' : getValue("Lanvuage"); axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; export default axios \ No newline at end of file diff --git a/src/i18n/init.ts b/src/i18n/init.ts index b05a295..7ebf2c9 100644 --- a/src/i18n/init.ts +++ b/src/i18n/init.ts @@ -10,10 +10,10 @@ getset().then((res: any)=>{ en.shichangtishi = `Minimum ${res.lowerLimit} person, maximum ${res.numberCeiling} people` zh.tixianzhu = `注:每笔提现收取${res.sxf}服务费,最低${ res.symbol + res.minmoney }` en.tixianzhu = `Note: ${res.sxf} service fee will be charged for each withdrawal, with a minimum of ${ res.symbol + res.minmoney }` - const i18n = geti18n(); - const loc = i18n.locale.value; - i18n.locale.value = ''; - i18n.locale.value = loc; + // const i18n = geti18n(); + // const loc = i18n.locale.value; + // i18n.locale.value = ''; + // i18n.locale.value = loc; console.log('i18n') }) diff --git a/src/store/index.ts b/src/store/index.ts index 40ce59e..e0241a9 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,5 +1,6 @@ import { getaddr, userinfo } from '@/api'; -import { getValue } from '@/utils/common'; +import { setLanvuage } from '@/api/base'; +import { getValue, saveValue } from '@/utils/common'; import { isProxy } from 'vue'; import { createStore } from 'vuex' @@ -64,13 +65,32 @@ export default createStore({ setLanguage(state, data){ const split = new Date().toString().split(" "); const timeZoneFormatted = split[split.length - 2] + " " + split[split.length - 1]; - state.userinfo.language = data[1] // English 中文 - state.userinfo.languageValue = data[0] // 'en' 'zh' - state.userinfo.zoneStr = timeZoneFormatted; - state.userinfo.currency = data[2]; + const lan = getValue("Lanvuage"); + if(lan != null && lan){ + // state.userinfo.language = data[1] // English 中文 + // state.userinfo.languageValue = data[0] // 'en' 'zh' + state.userinfo.zoneStr = timeZoneFormatted; + state.userinfo.currency = data[0]; + }else{ + console.log(data, 111) + state.userinfo.language = data[1] // English 中文 + state.userinfo.languageValue = data[0] // 'en' 'zh' + state.userinfo.zoneStr = timeZoneFormatted; + state.userinfo.currency = data[2]; + saveValue("Lanvuage", data[0]); + if( data[0] != 'zh'){ + location.reload() + } + // setLanvuage(data[0]); + } + }, setWlan(state){ - state.userinfo.languageValue = getValue("Lanvuage") + const lan = getValue("Lanvuage"); + if(lan != null && lan){ + state.userinfo.languageValue = !getValue("Lanvuage") ? 'zh' : getValue("Lanvuage"); + state.userinfo.language = (!getValue("Lanvuage") ? 'zh' : getValue("Lanvuage")) == 'zh' ? '中文' : 'English'; + } } }, actions: {