Commit 8ad315ee by 梁建民

js

parent 7e755385
......@@ -28,6 +28,7 @@ Object.keys(filters).forEach(key => Vue.filter(key, filters[key]));
Vue.use(directive);
//设置请求头
var csrf = Util.getCookie('Yo4teW_csrf') || '';
Vue.prototype.$http = axios;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.withCredentials = true;
......@@ -35,10 +36,10 @@ axios.interceptors.request.use(function (config) {
if (config.method == 'post') {
if (config.data) {
if (config.data.indexOf("&pf=2") == -1) {
config.data += "&pf=" + window.lxpf;
config.data += "&pf=" + window.lxpf + '&csrf=' + csrf;
}
} else {
config.data = "pf=" + window.lxpf
config.data = "pf=" + window.lxpf + '&csrf=' + csrf;
}
} else if (config.method == 'get') {
let paramsArr = Object.keys(config.params);
......@@ -46,12 +47,14 @@ axios.interceptors.request.use(function (config) {
if (paramsArr.indexOf('pf') == -1) {
config.params = {
pf: window.lxpf,
csrf: csrf,
...config.params
}
}
} else {
config.params = {
pf: window.lxpf
pf: window.lxpf,
csrf: csrf
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment