修改网络请求

master
夜笙歌 2 years ago
parent 92b83c197a
commit 45377ec86e

@ -9,7 +9,12 @@ import useUserStore from '@/store/modules/user'
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import en from "element-plus/lib/locale/lang/en"; import en from "element-plus/lib/locale/lang/en";
import zhCn from "element-plus/lib/locale/lang/zh-cn"; import zhCn from "element-plus/lib/locale/lang/zh-cn";
let lang = Cookies.get('language') === 'en' ? 'en' : 'zhCn'
if(lang === 'en'){
lang = 'en_us'
}else {
lang = 'zh_cn'
}
let downloadLoadingInstance; let downloadLoadingInstance;
// 是否显示重新登录 // 是否显示重新登录
export let isRelogin = {show: false}; export let isRelogin = {show: false};
@ -36,7 +41,7 @@ service.interceptors.request.use(config => {
if (config.method === 'get' && (config.params || {})) { if (config.method === 'get' && (config.params || {})) {
let url = config.url + '?' + tansParams({ let url = config.url + '?' + tansParams({
...(config.params || {}), ...(config.params || {}),
lang: Cookies.get('language') === 'en' ? 'en' : 'zhCn' lang
}); });
url = url.slice(0, -1); url = url.slice(0, -1);
config.params = {}; config.params = {};
@ -47,10 +52,10 @@ service.interceptors.request.use(config => {
url: config.url, url: config.url,
data: typeof config.data === 'object' ? JSON.stringify({ data: typeof config.data === 'object' ? JSON.stringify({
...config.data, ...config.data,
lang: Cookies.get('language') === 'en' ? 'en' : 'zhCn' lang
}) : JSON.stringify({ }) : JSON.stringify({
...JSON.parse(config.data || '{}'), ...JSON.parse(config.data || '{}'),
lang: Cookies.get('language') === 'en' ? 'en' : 'zhCn' lang
}), }),
time: new Date().getTime() time: new Date().getTime()
} }

Loading…
Cancel
Save