react-toolkits 2.13.24 → 2.13.26
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 +12 -2
- package/lib/index.js +19 -18
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { AnyObject } from 'antd/es/_util/type';
|
|
|
7
7
|
import { TableProps } from 'antd/es/table';
|
|
8
8
|
import { AxiosHeaderValue, AxiosRequestConfig, AxiosInstance, InternalAxiosRequestConfig, AxiosResponse, AxiosInterceptorOptions } from 'axios';
|
|
9
9
|
import * as swr from 'swr';
|
|
10
|
-
import { MutatorCallback, MutatorOptions, SWRResponse } from 'swr';
|
|
10
|
+
import { MutatorCallback, MutatorOptions, Arguments, SWRResponse } from 'swr';
|
|
11
11
|
import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
|
|
12
12
|
import { Merge } from 'ts-essentials';
|
|
13
13
|
import * as zustand from 'zustand';
|
|
@@ -43,10 +43,20 @@ interface HighlightProps extends PropsWithChildren {
|
|
|
43
43
|
}
|
|
44
44
|
declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
|
|
45
45
|
|
|
46
|
-
interface
|
|
46
|
+
interface SWRInfiniteRevalidateFn<Data = any> {
|
|
47
|
+
(data: Data, key: Arguments): boolean;
|
|
48
|
+
}
|
|
49
|
+
type InfiniteKeyedMutator<Data> = <MutationData = Data>(data?: Data | Promise<Data | undefined> | MutatorCallback<Data>, opts?: boolean | SWRInfiniteMutatorOptions<Data, MutationData>) => Promise<Data | MutationData | undefined>;
|
|
50
|
+
interface SWRInfiniteMutatorOptions<Data = any, MutationData = Data> extends Omit<MutatorOptions<Data, MutationData>, 'revalidate'> {
|
|
51
|
+
revalidate?: boolean | SWRInfiniteRevalidateFn<Data extends unknown[] ? Data[number] : never>;
|
|
52
|
+
}
|
|
53
|
+
interface InfiniteListRef<Item = any, Values = any, Data = any> {
|
|
47
54
|
data: Data[] | undefined;
|
|
48
55
|
dataSource: Item[] | undefined;
|
|
49
56
|
form: FormInstance<Values>;
|
|
57
|
+
mutate: InfiniteKeyedMutator<Data[]>;
|
|
58
|
+
size: number;
|
|
59
|
+
setSize: (size: number | ((_size: number) => number)) => Promise<Data[] | undefined>;
|
|
50
60
|
}
|
|
51
61
|
interface InfiniteListProps<Item, Values, Data> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
|
|
52
62
|
url: string;
|
package/lib/index.js
CHANGED
|
@@ -623,18 +623,16 @@ function usePermission(code, config) {
|
|
|
623
623
|
const url4 = permissionVersion !== "v1" /* V1 */ ? "/api/usystem/user/checkV2" : "/api/usystem/user/check";
|
|
624
624
|
const permissionCodes = typeof code !== "undefined" ? typeof code === "string" ? [code] : code : [];
|
|
625
625
|
const body = { permissions: permissionCodes };
|
|
626
|
+
const mergedConfig = {
|
|
627
|
+
...config,
|
|
628
|
+
headers: {
|
|
629
|
+
// FIXME: 在 QueryList 内,切换游戏的时有时不会触发查询
|
|
630
|
+
[APP_ID_HEADER]: gameId,
|
|
631
|
+
...config?.headers
|
|
632
|
+
}
|
|
633
|
+
};
|
|
626
634
|
const { data, ...rest } = useSWR6(
|
|
627
|
-
permissionCodes.length > 0 ? [
|
|
628
|
-
url4,
|
|
629
|
-
body,
|
|
630
|
-
{
|
|
631
|
-
...config,
|
|
632
|
-
headers: {
|
|
633
|
-
...config?.headers,
|
|
634
|
-
[APP_ID_HEADER]: gameId
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
] : null,
|
|
635
|
+
permissionCodes.length > 0 ? [url4, body, mergedConfig] : null,
|
|
638
636
|
(args) => axios2.post(...args).then((response) => response.data.data)
|
|
639
637
|
);
|
|
640
638
|
let newData;
|
|
@@ -1354,11 +1352,11 @@ var init_QueryList = __esm({
|
|
|
1354
1352
|
return serializedKey;
|
|
1355
1353
|
}, [accessible, isValid, url4, requestConfig]);
|
|
1356
1354
|
const { axios: axios2 } = useToolkitsStore((s) => s);
|
|
1357
|
-
const { data, isLoading
|
|
1355
|
+
const { data, isLoading } = useSWR6(
|
|
1358
1356
|
key,
|
|
1359
1357
|
async () => {
|
|
1360
1358
|
const response = await axios2.request(requestConfig);
|
|
1361
|
-
return response.data
|
|
1359
|
+
return response.data;
|
|
1362
1360
|
},
|
|
1363
1361
|
{
|
|
1364
1362
|
shouldRetryOnError: false,
|
|
@@ -1460,7 +1458,7 @@ var init_QueryList = __esm({
|
|
|
1460
1458
|
{
|
|
1461
1459
|
showReset,
|
|
1462
1460
|
buttonsAlign,
|
|
1463
|
-
isConfirming:
|
|
1461
|
+
isConfirming: isLoading,
|
|
1464
1462
|
onReset,
|
|
1465
1463
|
onConfirm,
|
|
1466
1464
|
children: cloneElement(renderForm(_form), {
|
|
@@ -1484,7 +1482,7 @@ var init_QueryList = __esm({
|
|
|
1484
1482
|
{
|
|
1485
1483
|
...tableProps,
|
|
1486
1484
|
dataSource,
|
|
1487
|
-
loading: isLoading
|
|
1485
|
+
loading: isLoading,
|
|
1488
1486
|
pagination,
|
|
1489
1487
|
footer: renderFooter
|
|
1490
1488
|
}
|
|
@@ -3289,8 +3287,8 @@ var InternalInfiniteList = (props, ref) => {
|
|
|
3289
3287
|
} = useSWRInfinite(
|
|
3290
3288
|
getKey,
|
|
3291
3289
|
async (arg) => {
|
|
3292
|
-
const response = await axios2(
|
|
3293
|
-
return response.data
|
|
3290
|
+
const response = await axios2.get(arg, { headers: _headers });
|
|
3291
|
+
return response.data;
|
|
3294
3292
|
},
|
|
3295
3293
|
{
|
|
3296
3294
|
shouldRetryOnError: false,
|
|
@@ -3341,7 +3339,10 @@ var InternalInfiniteList = (props, ref) => {
|
|
|
3341
3339
|
useImperativeHandle(ref, () => ({
|
|
3342
3340
|
data,
|
|
3343
3341
|
dataSource,
|
|
3344
|
-
form: _form
|
|
3342
|
+
form: _form,
|
|
3343
|
+
mutate: mutate2,
|
|
3344
|
+
size,
|
|
3345
|
+
setSize
|
|
3345
3346
|
}));
|
|
3346
3347
|
if (isLoading) {
|
|
3347
3348
|
return /* @__PURE__ */ jsx(
|