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.
38 lines
777 B
38 lines
777 B
|
|
|
|
/*
|
|
* @Author: ch
|
|
* @Date: 2022-05-03 23:04:45
|
|
* @LastEditors: ch
|
|
* @LastEditTime: 2022-06-09 19:21:46
|
|
* @Description: file content
|
|
*/
|
|
import { CreatUuid } from "@/plugins/utils";
|
|
let axios = null
|
|
export default function ({ app, $axios, store, req }) {
|
|
let uuid = store.state.uuid;
|
|
if (!uuid) {
|
|
uuid = CreatUuid(16, 2);
|
|
store.commit('setUUID', uuid);
|
|
}
|
|
|
|
$axios.onRequest( config =>{
|
|
config.headers.uid = uuid;
|
|
return config;
|
|
});
|
|
|
|
$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 } |