refactor(projects): 请求构造函数适配不同后端接口的数据结构

This commit is contained in:
Soybean
2022-01-22 02:25:59 +08:00
parent db75c91400
commit 4f9d544d43
15 changed files with 128 additions and 63 deletions

View File

@ -87,11 +87,12 @@ export function handleResponseError(response: AxiosResponse) {
* 处理后端返回的错误(业务错误)
* @param backendResult - 后端接口的响应数据
*/
export function handleBackendError(backendResult: Service.BackendServiceResult) {
export function handleBackendError(backendResult: Record<string, any>, config: Service.BackendResultConfig) {
const { codeKey, msgKey } = config;
const error: Service.RequestError = {
type: 'backend',
code: backendResult.code,
msg: backendResult.message
code: backendResult[codeKey],
msg: backendResult[msgKey]
};
showErrorMsg(error);