添加请求超时时间

fix/im-0526
ch 2 years ago
parent e4f8336673
commit 9df955e8d6

@ -99,8 +99,8 @@ export default {
methods: { methods: {
getList(id) { getList(id) {
let list = this.list.filter((item) => item.id == id); let list = this.list.filter((item) => item.id == id);
console.log(`list[0]?.list`, list[0]?.list); // console.log(`list[0]?.list`, list[0]?.list);
return list[0]?.list; return list[0]?.list || [];
}, },
// //
async getCategroyData() { async getCategroyData() {

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-03 23:04:45 * @Date: 2022-05-03 23:04:45
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-09 09:49:53 * @LastEditTime: 2022-05-25 17:48:31
* @Description: file content * @Description: file content
*/ */
let axios = null let axios = null
@ -31,6 +31,7 @@ export default function({app, $axios, req}) {
return Promise.reject({message:'请求出错'}); return Promise.reject({message:'请求出错'});
}); });
$axios.defaults.timeout = 3000;
axios = $axios; axios = $axios;
} }
export { axios } export { axios }

@ -2,12 +2,14 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-04 17:11:07 * @Date: 2022-05-04 17:11:07
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-10 14:30:24 * @LastEditTime: 2022-05-25 17:48:35
* @Description: file content * @Description: file content
*/ */
let axiosTk = null; let axiosTk = null;
export default function ({$axios, store, route}, inject) { export default function ({$axios, store, route}, inject) {
const $axiosTk = $axios.create(); const $axiosTk = $axios.create();
$axiosTk.defaults.timeout = 3000;
$axiosTk.onRequest( config =>{ $axiosTk.onRequest( config =>{
if(!store.state.token){ if(!store.state.token){
location.href = '/'; location.href = '/';

Loading…
Cancel
Save