feat(web): Unified frontend code style (#1923)

Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: 谨欣 <echo.cmy@antgroup.com>
Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com>
Co-authored-by: yanzhiyong <932374019@qq.com>
This commit is contained in:
Dreammy23
2024-08-30 14:03:06 +08:00
committed by GitHub
parent f866580703
commit 471689ba20
247 changed files with 4960 additions and 4546 deletions

View File

@@ -1,6 +1,6 @@
import { AxiosError } from 'axios';
import { ApiResponse, FailedTuple, SuccessTuple, ResponseType } from '../';
import { notification } from 'antd';
import { AxiosError } from 'axios';
import { ApiResponse, FailedTuple, ResponseType, SuccessTuple } from '../';
/**
* Response processing
@@ -9,9 +9,12 @@ import { notification } from 'antd';
* @param ignoreCodes ignore error codes
* @returns
*/
export const apiInterceptors = <T = any, D = any>(promise: Promise<ApiResponse<T, D>>, ignoreCodes?: '*' | (number | string)[]) => {
export const apiInterceptors = <T = any, D = any>(
promise: Promise<ApiResponse<T, D>>,
ignoreCodes?: '*' | (number | string)[],
) => {
return promise
.then<SuccessTuple<T, D>>((response) => {
.then<SuccessTuple<T, D>>(response => {
const { data } = response;
if (!data) {
throw new Error('Network Error!');
@@ -34,7 +37,9 @@ export const apiInterceptors = <T = any, D = any>(promise: Promise<ApiResponse<T
try {
const { err_msg } = JSON.parse(err.request.response) as ResponseType<null>;
err_msg && (errMessage = err_msg);
} catch (e) {}
} catch {
/* empty */
}
}
notification.error({
message: `Request error`,