You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/*
|
|
|
|
* @Author: ch
|
|
|
|
* @Date: 2022-05-03 23:04:45
|
|
|
|
* @LastEditors: ch
|
|
|
|
* @LastEditTime: 2022-05-25 17:48:31
|
|
|
|
* @Description: file content
|
|
|
|
*/
|
|
|
|
let axios = null
|
|
|
|
export default function({app, $axios, req}) {
|
|
|
|
// if(req){
|
|
|
|
// let str = 'Safari'
|
|
|
|
// if(req.headers['user-agent'].includes('Chrome')){
|
|
|
|
// str = 'Chrome'
|
|
|
|
// }
|
|
|
|
// console.log(str, req.headers['cookie'].split('token')[1]);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// export default function ({app, $axios}) {
|
|
|
|
// $axios.onRequest(()=>{
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
$axios.onResponse(response => {
|
|
|
|
const result = response.data;
|
|
|
|
if(response.status === 200){
|
|
|
|
if(result.code === 'SUCCESS'){
|
|
|
|
return result.data;
|
|
|
|
}
|
|
|
|
return Promise.reject(result);
|
|
|
|
}
|
|
|
|
return Promise.reject({message:'请求出错'});
|
|
|
|
|
|
|
|
});
|
|
|
|
$axios.defaults.timeout = 3000;
|
|
|
|
axios = $axios;
|
|
|
|
}
|
|
|
|
export { axios }
|