From dd08807e8edb8f55a8e69e7be4a81ffbe891516f Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Tue, 3 Nov 2020 15:37:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base.ts | 6 +++++- src/components/NavTop.vue | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/base.ts b/src/api/base.ts index 70ce126..9dbec9a 100644 --- a/src/api/base.ts +++ b/src/api/base.ts @@ -80,11 +80,15 @@ const put: Get = async function (url: string, data?: unknown){ function setToken(){ axios.defaults.headers.common['Authorization'] = "Bearer " + getValue("token"); } +function setLanvuage(yuyan: string){ + axios.defaults.headers.common['Language'] = yuyan; +} export { get, post, del, put, - setToken + setToken, + setLanvuage } \ No newline at end of file diff --git a/src/components/NavTop.vue b/src/components/NavTop.vue index 81167e0..0fb74c2 100644 --- a/src/components/NavTop.vue +++ b/src/components/NavTop.vue @@ -208,6 +208,7 @@ import { computed, defineComponent, onMounted, ref } from 'vue'; import { useRoute } from 'vue-router'; import axios from 'axios' import { useI18n } from '@/utils/i18n'; +import { setLanvuage } from '@/api/base'; export default defineComponent({ props:{ @@ -318,8 +319,13 @@ export default defineComponent({ } function setlanguage(e?: any){ console.log(e) - editsystemsetting({language:e}) + if(store.state.islogin){ + editsystemsetting({language:e}) + }else { + setLanvuage(e) + } lan.locale.value = e + } function toindex(){ router.push("/")