react-toolkits 2.14.3 → 2.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/index.d.ts +3 -7
- package/lib/index.js +4 -10
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
5
5
|
import { FormInstance, MenuProps, SelectProps, ModalProps, FormProps, ButtonProps } from 'antd';
|
|
6
6
|
import { AnyObject } from 'antd/es/_util/type';
|
|
7
7
|
import { TableProps } from 'antd/es/table';
|
|
8
|
-
import { AxiosHeaderValue, AxiosRequestConfig, AxiosInstance, InternalAxiosRequestConfig, AxiosResponse
|
|
8
|
+
import { AxiosHeaderValue, AxiosRequestConfig, AxiosInstance, AxiosInterceptorManager, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
|
9
9
|
import * as swr from 'swr';
|
|
10
10
|
import { MutatorCallback, MutatorOptions, Arguments, SWRResponse } from 'swr';
|
|
11
11
|
import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
|
|
@@ -377,12 +377,8 @@ interface ContextSlice {
|
|
|
377
377
|
collapsible?: boolean;
|
|
378
378
|
mainPagePath: string;
|
|
379
379
|
interceptors?: {
|
|
380
|
-
request?:
|
|
381
|
-
response?: [
|
|
382
|
-
(response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>,
|
|
383
|
-
((error: any) => any) | null,
|
|
384
|
-
options?: AxiosInterceptorOptions
|
|
385
|
-
];
|
|
380
|
+
request?: Parameters<AxiosInterceptorManager<InternalAxiosRequestConfig>['use']>;
|
|
381
|
+
response?: Parameters<AxiosInterceptorManager<AxiosResponse>['use']>;
|
|
386
382
|
};
|
|
387
383
|
setContext(state: Partial<Omit<ContextSlice, 'setContext'>>): void;
|
|
388
384
|
}
|
package/lib/index.js
CHANGED
|
@@ -370,7 +370,7 @@ var init_signIn = __esm({
|
|
|
370
370
|
signIn_default = SignIn;
|
|
371
371
|
}
|
|
372
372
|
});
|
|
373
|
-
var Interceptors, Interceptors_default;
|
|
373
|
+
var requestInterceptorId, responseInterceptorId, Interceptors, Interceptors_default;
|
|
374
374
|
var init_Interceptors = __esm({
|
|
375
375
|
"src/components/interceptors/Interceptors.tsx"() {
|
|
376
376
|
init_constants();
|
|
@@ -383,8 +383,8 @@ var init_Interceptors = __esm({
|
|
|
383
383
|
);
|
|
384
384
|
const { setUnregistered } = useSignInStore();
|
|
385
385
|
const navigate = useNavigate();
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
axios2.interceptors.request.eject(requestInterceptorId);
|
|
387
|
+
axios2.interceptors.response.eject(responseInterceptorId);
|
|
388
388
|
if (interceptors?.request) {
|
|
389
389
|
requestInterceptorId = axios2.interceptors.request.use(...interceptors.request);
|
|
390
390
|
} else {
|
|
@@ -420,7 +420,7 @@ var init_Interceptors = __esm({
|
|
|
420
420
|
const responseType = response.request.responseType || "json";
|
|
421
421
|
if (responseType === "json") {
|
|
422
422
|
const data = response.data;
|
|
423
|
-
if (data.code === 0 || data.code === 200 || data.status === 0 || data.errno === 0) {
|
|
423
|
+
if (data.code === 0 || data.code === 1 || data.code === 200 || data.status === 0 || data.errno === 0) {
|
|
424
424
|
return response;
|
|
425
425
|
} else {
|
|
426
426
|
notification.error({
|
|
@@ -461,12 +461,6 @@ var init_Interceptors = __esm({
|
|
|
461
461
|
}
|
|
462
462
|
);
|
|
463
463
|
}
|
|
464
|
-
useEffect(() => {
|
|
465
|
-
return () => {
|
|
466
|
-
axios2.interceptors.request.eject(requestInterceptorId);
|
|
467
|
-
axios2.interceptors.response.eject(responseInterceptorId);
|
|
468
|
-
};
|
|
469
|
-
}, []);
|
|
470
464
|
return children;
|
|
471
465
|
};
|
|
472
466
|
Interceptors_default = Interceptors;
|