chore: add i18n support for TabsView.vue; 🌟

This commit is contained in:
chenghongxing
2020-07-20 08:49:20 +08:00
parent 3573a51dbd
commit 886a19ddfc
2 changed files with 19 additions and 14 deletions

View File

@@ -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<AxiosResponse<T>>}
*/
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})
}
}