feat: refactor user page, fix alova response issue

This commit is contained in:
胡镇
2024-09-26 17:35:10 +08:00
parent f7e1a4aede
commit 88674669e3
11 changed files with 534 additions and 324 deletions

View File

@@ -2,7 +2,8 @@
"name": "@sa/alova",
"version": "0.1.0",
"exports": {
".": "./src/index.ts"
".": "./src/index.ts",
"./client": "./src/client.ts"
},
"typesVersions": {
"*": {

View File

@@ -0,0 +1 @@
export * from 'alova/client';

View File

@@ -62,7 +62,7 @@ export const createAlovaRequest = (customConfig: CustomAlovaConfig<any>, options
!isJSON(resp.headers.get('Content-Type') ?? '') ||
(options.isBackendSuccess && (await options.isBackendSuccess(resp)))
) {
return resp;
return options.transformBackendResponse ? await options.transformBackendResponse(resp) : resp;
}
if (options.onBackendFail) {
const fail = await options.onBackendFail(resp);
@@ -70,7 +70,6 @@ export const createAlovaRequest = (customConfig: CustomAlovaConfig<any>, options
return fail;
}
}
return options.transformBackendResponse ? await options.transformBackendResponse(resp) : resp;
}
throw new Error(resp.statusText);
},
@@ -84,3 +83,4 @@ export const createAlovaRequest = (customConfig: CustomAlovaConfig<any>, options
export { BACKEND_ERROR_CODE, REQUEST_ID_KEY };
export type * from './type';
export type * from 'alova';