diff --git a/src/App.vue b/src/App.vue index 57c9e01..72c0ee5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -25,8 +25,10 @@ export default defineComponent({ store.commit("login", true) store.dispatch("setUserInfo"); }else{ + console.log('ip') store.dispatch("getip"); + store.commit('setWlan') router.push("/") } const zh = zhCN diff --git a/src/api/index.ts b/src/api/index.ts index fcace2d..fcc51f8 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -32,10 +32,8 @@ export async function loginpass(phone: string, password: string,type?: number,sm setToken(); store.commit("login", true); store.dispatch("setUserInfo"); - router.push("/mine/archives") - setTimeout(()=>{ - location.reload(); - }, 1000) + await router.push("/mine/archives") + location.reload(); } } } @@ -47,7 +45,9 @@ export async function userinfo(){ const user = await get('personalInfo'); // console.log(user.data.img) if(user.code == 1001){ + saveValue("token","") router.push("/") + return '未登录'; } return user.data; diff --git a/src/components/NavTop.vue b/src/components/NavTop.vue index a15a9d9..de01ca6 100644 --- a/src/components/NavTop.vue +++ b/src/components/NavTop.vue @@ -209,6 +209,7 @@ import { useRoute } from 'vue-router'; import axios from 'axios' import { useI18n } from '@/utils/i18n'; import { setLanvuage } from '@/api/base'; +import { saveValue } from '@/utils/common'; export default defineComponent({ props:{ @@ -322,7 +323,9 @@ export default defineComponent({ if(store.state.islogin){ editsystemsetting({language:e}) }else { - setLanvuage(e) + saveValue("Lanvuage", e) + location.reload(); + // setLanvuage(e) } lan.locale.value = e diff --git a/src/config/axiosConfig.ts b/src/config/axiosConfig.ts index 2d8402a..c54753e 100644 --- a/src/config/axiosConfig.ts +++ b/src/config/axiosConfig.ts @@ -2,6 +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.post['Content-Type'] = 'application/x-www-form-urlencoded'; export default axios \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index f7ae927..40ce59e 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,4 +1,5 @@ import { getaddr, userinfo } from '@/api'; +import { getValue } from '@/utils/common'; import { isProxy } from 'vue'; import { createStore } from 'vuex' @@ -67,6 +68,9 @@ export default createStore({ state.userinfo.languageValue = data[0] // 'en' 'zh' state.userinfo.zoneStr = timeZoneFormatted; state.userinfo.currency = data[2]; + }, + setWlan(state){ + state.userinfo.languageValue = getValue("Lanvuage") } }, actions: { diff --git a/src/views/mine/Archives.vue b/src/views/mine/Archives.vue index 12af251..db0c233 100644 --- a/src/views/mine/Archives.vue +++ b/src/views/mine/Archives.vue @@ -551,9 +551,7 @@ export default defineComponent({ watch(userinfo, () => { formData.value = toRaw(userinfo.value); // console.log(lan.$s(), formData.value.languageValue) - if(lan.$s() != formData.value.languageValue){ - location.reload(); - } + console.log(userinfo.value.currencyValue, "listsssss"); currencyindex.value = userinfo.value.currency; console.log(currencyindex.value, "listsssss"); @@ -885,7 +883,10 @@ export default defineComponent({ // console.log(zonelist.value[i].city + zonelist.value[i].gmt, uesrinfo.zoneStr) } if (reg.test(userinfo.value.email)) { - putmember(uesrinfo); + await putmember(uesrinfo); + if(lan.$s() != uesrinfo.languageValue){ + location.reload(); + } } else { message.error(lan.$t('youxiangcuowu')); }