From 886a19ddfca81fd0055f82f150f29ed8d12f4bb5 Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Mon, 20 Jul 2020 08:49:20 +0800 Subject: [PATCH] chore: add i18n support for TabsView.vue; :star2: --- src/layouts/tabs/TabsView.vue | 16 +++++++++------- src/utils/request.js | 17 ++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/layouts/tabs/TabsView.vue b/src/layouts/tabs/TabsView.vue index 0417391..8fee523 100644 --- a/src/layouts/tabs/TabsView.vue +++ b/src/layouts/tabs/TabsView.vue @@ -40,16 +40,18 @@ export default { return { pageList: [], activePage: '', - menuVisible: false, - menuItemList: [ - { key: '1', icon: 'arrow-left', text: '关闭左侧' }, - { key: '2', icon: 'arrow-right', text: '关闭右侧' }, - { key: '3', icon: 'close', text: '关闭其它' } - ] + menuVisible: false } }, computed: { - ...mapState('setting', ['multiPage', 'animate', 'layout', 'dustbins', 'routesI18n']) + ...mapState('setting', ['multiPage', 'animate', 'layout', 'dustbins', 'routesI18n']), + menuItemList() { + return [ + { key: '1', icon: 'vertical-right', text: this.$t('closeLeft') }, + { key: '2', icon: 'vertical-left', text: this.$t('closeRight') }, + { key: '3', icon: 'close', text: this.$t('closeOthers') } + ] + } }, created () { const route = this.$route diff --git a/src/utils/request.js b/src/utils/request.js index f0f127d..4cb32b7 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,10 +3,10 @@ import Cookie from 'js-cookie' axios.defaults.timeout = 5000 axios.defaults.withCredentials= true -const cookies = Cookie.get() -Object.keys(cookies).forEach(key => { - axios.defaults.headers.common[key] = cookies[key] -}) +// const cookies = Cookie.get() +// Object.keys(cookies).forEach(key => { +// axios.defaults.headers.common[key] = cookies[key] +// }) const METHOD = { GET: 'get', @@ -21,13 +21,16 @@ const METHOD = { * @returns {Promise>} */ async function request(url, method, params) { + // header 加入 token + const token = Cookie.get('Authorization') + const config = token ? {headers: {Authorization: token}} : {} switch (method) { case METHOD.GET: - return axios.get(url, {params}) + return axios.get(url, {params, ...config}) case METHOD.POST: - return axios.post(url, params) + return axios.post(url, params, config) default: - return axios.get(url, {params}) + return axios.get(url, {params, ...config}) } }