|
|
|
@ -26,22 +26,19 @@ class Proxy { |
|
|
|
|
() => Axios.get(url, { params, ...opt }), |
|
|
|
|
data || params |
|
|
|
|
); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
post = (url, params, opt, data) => { |
|
|
|
|
try { |
|
|
|
|
this.check(url, opt, () => Axios.post(url, params, opt), data || params); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
put = (url, params, opt, data) => { |
|
|
|
|
try { |
|
|
|
|
this.check(url, opt, () => Axios.put(url, params, opt), data || params); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
delete = (url, params, opt, data) => { |
|
|
|
@ -52,8 +49,7 @@ class Proxy { |
|
|
|
|
() => Axios.delete(url, { ...opt, data: params }), |
|
|
|
|
data || params |
|
|
|
|
); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
check = async (url, { dispatch }, fetch, params) => { |
|
|
|
@ -72,6 +68,14 @@ class Proxy { |
|
|
|
|
return response.data.data; |
|
|
|
|
}
|
|
|
|
|
break; |
|
|
|
|
case 403: |
|
|
|
|
console.log(url.split("/")[0] + "/" + "error"), |
|
|
|
|
dispatch({ |
|
|
|
|
type: url.split("/")[0] + "/" + "error", |
|
|
|
|
// data: response.data,
|
|
|
|
|
// params,
|
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
default: |
|
|
|
|
dispatch({ |
|
|
|
|
type: url.split("/")[0] + "/" + "error", |
|
|
|
@ -80,8 +84,7 @@ class Proxy { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
refresh = () => { |
|
|
|
@ -95,8 +98,7 @@ class Proxy { |
|
|
|
|
{ headers: { Authorization: `Bearer ${refresh}` } } |
|
|
|
|
); |
|
|
|
|
return login ? true : false; |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
login = (url, params, { dispatch }) => { |
|
|
|
@ -116,8 +118,7 @@ class Proxy { |
|
|
|
|
dispatch(obj); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
logout = (url, params, { dispatch }) => { |
|
|
|
@ -129,8 +130,7 @@ class Proxy { |
|
|
|
|
dispatch(obj); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} catch (error) { |
|
|
|
|
} |
|
|
|
|
} catch (error) {} |
|
|
|
|
}; |
|
|
|
|
status = async () => { |
|
|
|
|
try { |
|
|
|
@ -149,8 +149,8 @@ class Proxy { |
|
|
|
|
}; |
|
|
|
|
getStatus = async ({ dispatch }) => { |
|
|
|
|
let status = await this.status(); |
|
|
|
|
dispatch({ type: "user/getStatus", data: {status}}) |
|
|
|
|
} |
|
|
|
|
dispatch({ type: "user/getStatus", data: { status } }); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
const _proxy = new Proxy(); |
|
|
|
|
export default _proxy; |
|
|
|
|