@flow97/react-toolkit 0.0.1
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 +3090 -0
- package/README.md +383 -0
- package/lib/index.css +1 -0
- package/lib/index.d.ts +1448 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/locale/context.d.ts +7 -0
- package/locale/context.js +7 -0
- package/locale/en_GB.d.ts +5 -0
- package/locale/en_GB.js +94 -0
- package/locale/hooks.d.ts +1 -0
- package/locale/hooks.js +35 -0
- package/locale/index.d.ts +100 -0
- package/locale/index.js +35 -0
- package/locale/ja_JP.d.ts +5 -0
- package/locale/ja_JP.js +94 -0
- package/locale/ko_KR.d.ts +5 -0
- package/locale/ko_KR.js +94 -0
- package/locale/zh_CN.d.ts +5 -0
- package/locale/zh_CN.js +94 -0
- package/package.json +90 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,1448 @@
|
|
|
1
|
+
import { ButtonProps, SelectProps, FormInstance, DrawerProps, Button, FormProps, ModalProps } from 'antd';
|
|
2
|
+
import { FC, PropsWithChildren, Key, ReactNode, ReactElement, CSSProperties, Ref, DetailedHTMLProps, ImgHTMLAttributes, ComponentProps } from 'react';
|
|
3
|
+
import { Options } from 'ky';
|
|
4
|
+
import { ParagraphProps } from 'antd/es/typography/Paragraph';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { useLocation, PathPattern } from 'react-router';
|
|
7
|
+
import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
|
|
8
|
+
import { AnyObject } from 'antd/es/_util/type';
|
|
9
|
+
import { TableProps } from 'antd/es/table';
|
|
10
|
+
import * as zustand from 'zustand';
|
|
11
|
+
import { StateCreator } from 'zustand';
|
|
12
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
13
|
+
import { StateStorage } from 'zustand/middleware';
|
|
14
|
+
|
|
15
|
+
/** 响应类型 */
|
|
16
|
+
type ResponseType = 'json' | 'blob' | 'text' | 'arrayBuffer' | 'formData';
|
|
17
|
+
/** 通用请求选项接口 */
|
|
18
|
+
interface RequestOptions extends Options {
|
|
19
|
+
/** 响应类型 */
|
|
20
|
+
responseType?: ResponseType;
|
|
21
|
+
/** 是否使用全局模式,为 true 时 app-id header 设置为 global */
|
|
22
|
+
isGlobalMode?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface AuthButtonProps extends ButtonProps {
|
|
26
|
+
/** 权限码,支持单个或多个 */
|
|
27
|
+
code?: string | string[];
|
|
28
|
+
/** 加载时是否显示 loading 状态 */
|
|
29
|
+
showLoading?: boolean;
|
|
30
|
+
/** 请求配置 */
|
|
31
|
+
config?: RequestOptions;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 授权按钮组件
|
|
35
|
+
* 根据权限码自动控制按钮的启用/禁用状态
|
|
36
|
+
* - 有权限:正常显示可点击按钮
|
|
37
|
+
* - 无权限:显示禁用按钮并带有提示
|
|
38
|
+
* - 加载中:显示加载状态
|
|
39
|
+
*/
|
|
40
|
+
declare const AuthButton: FC<PropsWithChildren<AuthButtonProps>>;
|
|
41
|
+
|
|
42
|
+
interface DynamicTagsProps {
|
|
43
|
+
initialTags?: string[];
|
|
44
|
+
addable?: boolean;
|
|
45
|
+
removable?: boolean;
|
|
46
|
+
addCallback?: (addedTag: string) => Promise<boolean>;
|
|
47
|
+
removeCallback?: (removedTag: string) => Promise<boolean>;
|
|
48
|
+
}
|
|
49
|
+
declare const DynamicTags: FC<DynamicTagsProps>;
|
|
50
|
+
|
|
51
|
+
type ExpandableParagraphProps = Omit<ParagraphProps, 'ellipsis' | 'className'>;
|
|
52
|
+
declare const ExpandableParagraph: FC<ExpandableParagraphProps>;
|
|
53
|
+
|
|
54
|
+
interface FilterFormWrapperProps extends PropsWithChildren {
|
|
55
|
+
onConfirm?: () => void | Promise<void>;
|
|
56
|
+
onReset?: () => void;
|
|
57
|
+
extras?: {
|
|
58
|
+
key: Key;
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
}[];
|
|
61
|
+
isConfirming?: boolean;
|
|
62
|
+
buttonsAlign?: 'left' | 'right' | 'bottom';
|
|
63
|
+
showReset?: boolean;
|
|
64
|
+
}
|
|
65
|
+
declare const FilterFormWrapper: (props: FilterFormWrapperProps) => react_jsx_runtime.JSX.Element;
|
|
66
|
+
|
|
67
|
+
interface HighlightProps extends PropsWithChildren {
|
|
68
|
+
texts: Array<string | number>;
|
|
69
|
+
}
|
|
70
|
+
declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* KeepAlive Props
|
|
74
|
+
*/
|
|
75
|
+
interface KeepAliveProps {
|
|
76
|
+
/** 缓存的唯一标识,如果不提供则使用当前路由路径 */
|
|
77
|
+
cacheKey?: string;
|
|
78
|
+
/** 需要缓存的子组件 */
|
|
79
|
+
children: ReactElement;
|
|
80
|
+
/** 是否禁用缓存,默认 false */
|
|
81
|
+
disabled?: boolean;
|
|
82
|
+
/** 自定义缓存 key 生成函数 */
|
|
83
|
+
getCacheKey?: (location: ReturnType<typeof useLocation>) => string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* KeepAlive 组件
|
|
87
|
+
* 使用 React 19 Activity API 实现组件状态缓存,避免路由切换时重新挂载
|
|
88
|
+
* 支持路由级别的自动缓存:如果不提供 cacheKey,会自动使用当前路由路径作为缓存 key
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* // 手动指定缓存 key
|
|
93
|
+
* <KeepAlive cacheKey="/list/pagination">
|
|
94
|
+
* <PaginationList />
|
|
95
|
+
* </KeepAlive>
|
|
96
|
+
*
|
|
97
|
+
* // 自动使用路由路径作为缓存 key
|
|
98
|
+
* <KeepAlive>
|
|
99
|
+
* <PaginationList />
|
|
100
|
+
* </KeepAlive>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare const KeepAlive: ({ cacheKey, children, disabled, getCacheKey }: KeepAliveProps) => react_jsx_runtime.JSX.Element;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* KeepAliveOutlet Props
|
|
107
|
+
*/
|
|
108
|
+
interface KeepAliveOutletProps {
|
|
109
|
+
/** 是否禁用缓存,默认 false */
|
|
110
|
+
disabled?: boolean;
|
|
111
|
+
/** 自定义缓存 key 前缀,用于区分不同的 KeepAliveOutlet 实例 */
|
|
112
|
+
cacheKeyPrefix?: string;
|
|
113
|
+
/** 是否启用路由切换过渡动画,默认 true */
|
|
114
|
+
enableTransition?: boolean;
|
|
115
|
+
/** 过渡动画时长(毫秒),默认 200 */
|
|
116
|
+
transitionDuration?: number;
|
|
117
|
+
}
|
|
118
|
+
declare const KeepAliveOutlet: ({ disabled, cacheKeyPrefix, enableTransition, transitionDuration, }: KeepAliveOutletProps) => react_jsx_runtime.JSX.Element;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* KeepAlive 缓存项
|
|
122
|
+
*/
|
|
123
|
+
interface KeepAliveCacheItem {
|
|
124
|
+
/** 缓存的组件 */
|
|
125
|
+
element: ReactNode;
|
|
126
|
+
/** 是否激活 */
|
|
127
|
+
active: boolean;
|
|
128
|
+
/** 缓存时间戳 */
|
|
129
|
+
timestamp: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* KeepAlive 上下文类型
|
|
133
|
+
*/
|
|
134
|
+
interface KeepAliveContextType {
|
|
135
|
+
/** 缓存映射 */
|
|
136
|
+
cache: Map<string, KeepAliveCacheItem>;
|
|
137
|
+
/** 添加缓存 */
|
|
138
|
+
addCache: (key: string, element: ReactNode) => void;
|
|
139
|
+
/** 移除缓存 */
|
|
140
|
+
removeCache: (key: string) => void;
|
|
141
|
+
/** 清除所有缓存 */
|
|
142
|
+
clearCache: () => void;
|
|
143
|
+
/** 激活缓存项 */
|
|
144
|
+
activateCache: (key: string) => void;
|
|
145
|
+
/** 停用缓存项 */
|
|
146
|
+
deactivateCache: (key: string) => void;
|
|
147
|
+
/** 获取缓存项 */
|
|
148
|
+
getCache: (key: string) => KeepAliveCacheItem | undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* KeepAlive Provider Props
|
|
152
|
+
*/
|
|
153
|
+
interface KeepAliveProviderProps {
|
|
154
|
+
/** 子组件 */
|
|
155
|
+
children: ReactNode;
|
|
156
|
+
/** 最大缓存数量,默认 10 */
|
|
157
|
+
maxCache?: number;
|
|
158
|
+
/** 是否在组件卸载时清除缓存,默认 false */
|
|
159
|
+
clearOnUnmount?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* KeepAlive Provider
|
|
163
|
+
* 提供 KeepAlive 缓存管理功能
|
|
164
|
+
*/
|
|
165
|
+
declare const KeepAliveProvider: ({ children, maxCache, clearOnUnmount }: KeepAliveProviderProps) => react_jsx_runtime.JSX.Element;
|
|
166
|
+
/**
|
|
167
|
+
* 使用 KeepAlive 上下文
|
|
168
|
+
*/
|
|
169
|
+
declare function useKeepAliveContext(): KeepAliveContextType;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* useKeepAlive Hook
|
|
173
|
+
* 用于控制 KeepAlive 缓存
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```tsx
|
|
177
|
+
* const { clearCache, removeCache, getCacheKeys } = useKeepAlive()
|
|
178
|
+
*
|
|
179
|
+
* const handleClearAll = () => {
|
|
180
|
+
* clearCache() // 清除所有缓存
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* const handleClearSpecific = () => {
|
|
184
|
+
* removeCache('/list/pagination') // 清除特定缓存
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useKeepAlive(): {
|
|
189
|
+
cache: Map<string, KeepAliveCacheItem>;
|
|
190
|
+
removeCache: (key: string) => void;
|
|
191
|
+
clearCache: () => void;
|
|
192
|
+
clearCacheByPath: (path: string) => void;
|
|
193
|
+
clearCurrentCache: () => void;
|
|
194
|
+
getCacheKeys: () => string[];
|
|
195
|
+
getAllCache: () => [string, KeepAliveCacheItem][];
|
|
196
|
+
getCache: (key: string) => KeepAliveCacheItem | undefined;
|
|
197
|
+
activateCache: (key: string) => void;
|
|
198
|
+
deactivateCache: (key: string) => void;
|
|
199
|
+
};
|
|
200
|
+
type UseKeepAliveReturn = ReturnType<typeof useKeepAlive>;
|
|
201
|
+
|
|
202
|
+
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
203
|
+
|
|
204
|
+
type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
205
|
+
|
|
206
|
+
type Prettify<Type> = Type extends Function ? Type : Extract<{
|
|
207
|
+
[Key in keyof Type]: Type[Key];
|
|
208
|
+
}, Type>;
|
|
209
|
+
|
|
210
|
+
type Merge<Object1, Object2> = Prettify<Omit<Object1, keyof Object2> & Object2>;
|
|
211
|
+
|
|
212
|
+
type IsAny<Type> = 0 extends 1 & Type ? true : false;
|
|
213
|
+
|
|
214
|
+
type IsUnknown<Type> = IsAny<Type> extends true ? false : unknown extends Type ? true : false;
|
|
215
|
+
|
|
216
|
+
type MarkRequired<Type, Keys extends keyof Type> = Type extends Type ? Prettify<Type & Required<Omit<Type, Exclude<keyof Type, Keys>>>> : never;
|
|
217
|
+
|
|
218
|
+
type IsTuple<Type> = Type extends readonly any[] ? (any[] extends Type ? never : Type) : never;
|
|
219
|
+
|
|
220
|
+
type DeepPartial<Type> = Type extends Exclude<Builtin, Error> ? Type : Type extends Map<infer Keys, infer Values> ? Map<DeepPartial<Keys>, DeepPartial<Values>> : Type extends ReadonlyMap<infer Keys, infer Values> ? ReadonlyMap<DeepPartial<Keys>, DeepPartial<Values>> : Type extends WeakMap<infer Keys, infer Values> ? WeakMap<DeepPartial<Keys>, DeepPartial<Values>> : Type extends Set<infer Values> ? Set<DeepPartial<Values>> : Type extends ReadonlySet<infer Values> ? ReadonlySet<DeepPartial<Values>> : Type extends WeakSet<infer Values> ? WeakSet<DeepPartial<Values>> : Type extends ReadonlyArray<infer Values> ? Type extends IsTuple<Type> ? {
|
|
221
|
+
[Key in keyof Type]?: DeepPartial<Type[Key]>;
|
|
222
|
+
} : Type extends Array<Values> ? Array<DeepPartial<Values> | undefined> : ReadonlyArray<DeepPartial<Values> | undefined> : Type extends Promise<infer Value> ? Promise<DeepPartial<Value>> : Type extends {} ? {
|
|
223
|
+
[Key in keyof Type]?: DeepPartial<Type[Key]>;
|
|
224
|
+
} : IsUnknown<Type> extends true ? unknown : Partial<Type>;
|
|
225
|
+
|
|
226
|
+
interface Game {
|
|
227
|
+
game_id: string | number;
|
|
228
|
+
[key: string]: any;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 导航菜单项类型
|
|
232
|
+
* 扩展 antd MenuItemType,添加路由支持
|
|
233
|
+
*/
|
|
234
|
+
type NavMenuItemType = Merge<MenuItemType, {
|
|
235
|
+
/** react-router 路由地址,用于菜单项点击时跳转 */
|
|
236
|
+
route?: string;
|
|
237
|
+
}>;
|
|
238
|
+
/**
|
|
239
|
+
* 导航子菜单类型
|
|
240
|
+
* 使用接口来支持递归类型定义,允许嵌套子菜单
|
|
241
|
+
*/
|
|
242
|
+
interface NavSubMenuType extends Omit<SubMenuType, 'children'> {
|
|
243
|
+
/** 子菜单项数组,支持嵌套结构 */
|
|
244
|
+
children?: NavItem[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* 导航菜单组类型
|
|
248
|
+
* 用于将多个菜单项分组显示,菜单组本身不计入路径
|
|
249
|
+
*/
|
|
250
|
+
interface NavMenuItemGroupType extends Omit<MenuItemGroupType, 'children'> {
|
|
251
|
+
/** 菜单组内的菜单项数组 */
|
|
252
|
+
children?: NavItem[];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 导航项联合类型
|
|
256
|
+
* 包含所有支持的导航项类型:
|
|
257
|
+
* - 特殊项(如分割线)
|
|
258
|
+
* - 普通菜单项(NavMenuItemType)
|
|
259
|
+
* - 子菜单(NavSubMenuType)
|
|
260
|
+
* - 菜单组(NavMenuItemGroupType)
|
|
261
|
+
*/
|
|
262
|
+
type NavItem = Exclude<ItemType, SubMenuType | MenuItemGroupType | MenuItemType> | NavMenuItemType | NavSubMenuType | NavMenuItemGroupType;
|
|
263
|
+
|
|
264
|
+
interface GameSelectProps<T extends Game = Game> {
|
|
265
|
+
filter?: (game: T) => boolean;
|
|
266
|
+
options?: (data?: T[]) => SelectProps['options'];
|
|
267
|
+
onChange?: (value: string) => void;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Header 扩展项配置 */
|
|
271
|
+
type HeaderExtra = {
|
|
272
|
+
key: Key;
|
|
273
|
+
children: ReactNode;
|
|
274
|
+
};
|
|
275
|
+
/** Header 扩展区域配置 */
|
|
276
|
+
interface HeaderExtraConfig {
|
|
277
|
+
/** 左侧扩展项 */
|
|
278
|
+
left?: HeaderExtra[];
|
|
279
|
+
/** 右侧扩展项 */
|
|
280
|
+
right?: HeaderExtra[];
|
|
281
|
+
}
|
|
282
|
+
/** 导航配置 */
|
|
283
|
+
interface NavigationConfig {
|
|
284
|
+
/** 导航菜单项 */
|
|
285
|
+
items?: NavItem[];
|
|
286
|
+
/** 菜单加载状态 */
|
|
287
|
+
loading?: boolean;
|
|
288
|
+
}
|
|
289
|
+
/** 路由匹配规则类型
|
|
290
|
+
* 支持:
|
|
291
|
+
* - PathPattern 对象(React Router 路由模式,支持 caseSensitive 和 end 选项)
|
|
292
|
+
* - 正则表达式(用于更复杂的匹配需求)
|
|
293
|
+
*/
|
|
294
|
+
type RouteMatchRule = PathPattern | RegExp;
|
|
295
|
+
/** 游戏选择器配置 */
|
|
296
|
+
interface GameSelectConfig<T extends Game = Game> {
|
|
297
|
+
/** 游戏过滤函数 */
|
|
298
|
+
filter?: GameSelectProps<T>['filter'];
|
|
299
|
+
/** 选项自定义函数 */
|
|
300
|
+
options?: GameSelectProps<T>['options'];
|
|
301
|
+
/** 在这些路由路径下隐藏游戏选择器(支持 PathPattern 对象或正则表达式) */
|
|
302
|
+
hideOnRoutes?: RouteMatchRule[];
|
|
303
|
+
/** 游戏切换时的回调函数 */
|
|
304
|
+
onChange?: (value: string | number) => void;
|
|
305
|
+
}
|
|
306
|
+
/** Layout 组件属性 */
|
|
307
|
+
interface LayoutProps<T extends Game = Game> {
|
|
308
|
+
/** 应用标题(显示在侧边栏顶部) */
|
|
309
|
+
title?: string;
|
|
310
|
+
/** 应用标题样式 */
|
|
311
|
+
titleStyle?: CSSProperties;
|
|
312
|
+
/** 应用副标题(显示在标题下方) */
|
|
313
|
+
subtitle?: string;
|
|
314
|
+
/** 导航配置 */
|
|
315
|
+
navigation?: NavigationConfig;
|
|
316
|
+
/** 游戏选择器配置 */
|
|
317
|
+
gameSelect?: GameSelectConfig<T>;
|
|
318
|
+
/** Header 扩展区域配置 */
|
|
319
|
+
headerExtra?: HeaderExtraConfig;
|
|
320
|
+
}
|
|
321
|
+
declare const Layout: <T extends Game = Game>(props: PropsWithChildren<LayoutProps<T>>) => react_jsx_runtime.JSX.Element;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 列表组件的公共类型定义
|
|
325
|
+
*/
|
|
326
|
+
/**
|
|
327
|
+
* HTTP 请求方法
|
|
328
|
+
*/
|
|
329
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
330
|
+
/**
|
|
331
|
+
* React Query 缓存配置
|
|
332
|
+
*/
|
|
333
|
+
interface CacheConfig {
|
|
334
|
+
/** 缓存时间(毫秒),数据在缓存中保留的时间 */
|
|
335
|
+
cacheTime?: number;
|
|
336
|
+
/** 过期时间(毫秒),数据在过期前被认为是新鲜的 */
|
|
337
|
+
staleTime?: number;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* 基础 Payload 接口
|
|
341
|
+
* @template Values 筛选条件的类型
|
|
342
|
+
*/
|
|
343
|
+
interface BaseListPayload<Values = any> {
|
|
344
|
+
/** 当前页码 */
|
|
345
|
+
page?: number;
|
|
346
|
+
/** 表单筛选条件 */
|
|
347
|
+
filters?: Values;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* QueryList 的 Payload(包含 size)
|
|
351
|
+
* @template Values 筛选条件的类型
|
|
352
|
+
*/
|
|
353
|
+
interface QueryListPayload<Values = any> extends BaseListPayload<Values> {
|
|
354
|
+
/** 每页数量 */
|
|
355
|
+
size?: number;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* InfiniteList 的 Payload
|
|
359
|
+
* @template Values 表单值的类型
|
|
360
|
+
*/
|
|
361
|
+
type InfiniteListPayload<Values = any> = BaseListPayload<Values>;
|
|
362
|
+
/**
|
|
363
|
+
* 状态同步回调函数类型
|
|
364
|
+
* @template Payload Payload 类型
|
|
365
|
+
*/
|
|
366
|
+
type StateSyncCallback<Payload> = (payload: Payload) => void;
|
|
367
|
+
/**
|
|
368
|
+
* Query 更新函数类型
|
|
369
|
+
*/
|
|
370
|
+
type QueryRefetchFunction = () => void | Promise<unknown>;
|
|
371
|
+
/**
|
|
372
|
+
* Infinite Query 的 fetchNextPage 函数类型
|
|
373
|
+
*/
|
|
374
|
+
type InfiniteQueryFetchNextPageFunction = () => void | Promise<unknown>;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* 分页参数类型,支持多种分页方式:
|
|
378
|
+
* - number: 页码分页
|
|
379
|
+
* - string: 游标分页(cursor)
|
|
380
|
+
* - object: 复杂分页参数对象
|
|
381
|
+
* - undefined: 无下一页
|
|
382
|
+
*/
|
|
383
|
+
type PageParam = number | string | Record<string, any> | undefined;
|
|
384
|
+
/**
|
|
385
|
+
* 请求体解析器
|
|
386
|
+
* 可以是静态值,也可以是动态函数
|
|
387
|
+
* @template Values 表单值的类型
|
|
388
|
+
* @template PageParamType 分页参数的类型(可能是 undefined,表示第一页)
|
|
389
|
+
*/
|
|
390
|
+
type RequestBodyResolver<Values = any, PageParamType = PageParam> = FormData | Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => FormData | Record<string | number, any>);
|
|
391
|
+
/**
|
|
392
|
+
* 请求参数解析器(用于 URL 查询参数)
|
|
393
|
+
* 可以是静态值,也可以是动态函数
|
|
394
|
+
* @template Values 表单值的类型
|
|
395
|
+
* @template PageParamType 分页参数的类型(可能是 undefined,表示第一页)
|
|
396
|
+
*/
|
|
397
|
+
type RequestParamsResolver<Values = any, PageParamType = PageParam> = Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => Record<string | number, any>);
|
|
398
|
+
/**
|
|
399
|
+
* 无限列表请求配置
|
|
400
|
+
* @template Values 表单值的类型
|
|
401
|
+
* @template PageParamType 分页参数的类型
|
|
402
|
+
*/
|
|
403
|
+
interface InfiniteListRequestConfig<Values = any, PageParamType = PageParam> extends CacheConfig {
|
|
404
|
+
/** 请求 URL */
|
|
405
|
+
url: string;
|
|
406
|
+
/** HTTP 请求方法,默认为 GET */
|
|
407
|
+
method?: HttpMethod;
|
|
408
|
+
/** 请求体(用于 POST、PUT、PATCH、DELETE 等方法) */
|
|
409
|
+
body?: RequestBodyResolver<Values, PageParamType>;
|
|
410
|
+
/** URL 查询参数 */
|
|
411
|
+
searchParams?: RequestParamsResolver<Values, PageParamType>;
|
|
412
|
+
/** 请求头,可以是静态对象或动态函数 */
|
|
413
|
+
headers?: Record<string, string> | ((form: FormInstance<Values>) => Record<string, string>);
|
|
414
|
+
/** 是否为全局模式请求 */
|
|
415
|
+
isGlobalMode?: boolean;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* 无限列表请求配置类型
|
|
419
|
+
* 支持字符串、对象或函数形式:
|
|
420
|
+
* - string: 仅指定 url,其他参数使用默认值
|
|
421
|
+
* - 对象: 完整配置
|
|
422
|
+
* - 函数: 根据 payload 和 pageParam 动态生成配置
|
|
423
|
+
* @template Values 表单值的类型
|
|
424
|
+
* @template PageParamType 分页参数的类型
|
|
425
|
+
*/
|
|
426
|
+
type InfiniteListRequestConfigType<Values = any, PageParamType = PageParam> = string | InfiniteListRequestConfig<Values, PageParamType> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => InfiniteListRequestConfig<Values, PageParamType>);
|
|
427
|
+
/**
|
|
428
|
+
* 数据适配器,用于转换和适配后端返回的数据格式
|
|
429
|
+
* @template Item 列表项类型
|
|
430
|
+
* @template Values 表单值类型
|
|
431
|
+
* @template Data 后端返回的数据类型
|
|
432
|
+
* @template PageParamType 分页参数的类型
|
|
433
|
+
*/
|
|
434
|
+
interface InfiniteListDataAdapter<Item = any, Values = any, Data = any, PageParamType = PageParam> {
|
|
435
|
+
/**
|
|
436
|
+
* 从后端数据中提取列表项
|
|
437
|
+
* @param data 所有已加载的页面数据
|
|
438
|
+
* @param form 表单实例
|
|
439
|
+
* @returns 提取的列表项数组
|
|
440
|
+
*/
|
|
441
|
+
items?: (data: Data[] | undefined, form: FormInstance<Values>) => Item[] | undefined;
|
|
442
|
+
/**
|
|
443
|
+
* 判断是否还有更多数据
|
|
444
|
+
* @param lastPage 最后一页的数据
|
|
445
|
+
* @param allPages 所有已加载的页面数据
|
|
446
|
+
* @returns 是否还有更多数据
|
|
447
|
+
*/
|
|
448
|
+
hasMore?: (lastPage: Data | undefined, allPages: Data[]) => boolean;
|
|
449
|
+
/**
|
|
450
|
+
* 计算下一页的分页参数
|
|
451
|
+
* @param lastPage 最后一页的数据
|
|
452
|
+
* @param allPages 所有已加载的页面数据
|
|
453
|
+
* @param pageParam 当前的分页参数
|
|
454
|
+
* @returns 下一页的分页参数,返回 undefined 表示没有下一页
|
|
455
|
+
*/
|
|
456
|
+
nextPageParam?: (lastPage: Data | undefined, allPages: Data[], pageParam: PageParamType) => PageParamType | undefined;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* InfiniteList 组件的引用对象,提供外部访问的 API
|
|
460
|
+
* @template Item 列表项类型
|
|
461
|
+
* @template Values 表单值类型
|
|
462
|
+
* @template Data 后端返回的数据类型
|
|
463
|
+
*/
|
|
464
|
+
interface InfiniteListRef<Item = any, Values = any, Data = any> {
|
|
465
|
+
/** 所有已加载的页面数据 */
|
|
466
|
+
data: Data[] | undefined;
|
|
467
|
+
/** 处理后的列表数据源 */
|
|
468
|
+
dataSource: Item[] | undefined;
|
|
469
|
+
/** 表单实例 */
|
|
470
|
+
form: FormInstance<Values>;
|
|
471
|
+
/** 重新获取数据 */
|
|
472
|
+
refetch: () => void;
|
|
473
|
+
/** 获取下一页数据 */
|
|
474
|
+
fetchNextPage: () => void;
|
|
475
|
+
/** 是否还有下一页 */
|
|
476
|
+
hasNextPage: boolean;
|
|
477
|
+
/** 是否正在获取下一页 */
|
|
478
|
+
isFetchingNextPage: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* InfiniteList 组件的属性
|
|
482
|
+
* @template Item 列表项类型
|
|
483
|
+
* @template Values 表单值类型
|
|
484
|
+
* @template Data 后端返回的数据类型
|
|
485
|
+
* @template PageParamType 分页参数的类型
|
|
486
|
+
*/
|
|
487
|
+
interface InfiniteListProps<Item, Values, Data, PageParamType = PageParam> extends Omit<TableProps<Item>, 'pagination' | 'dataSource' | 'loading' | 'footer'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
|
|
488
|
+
/** 唯一标识符,用于在 store 中区分不同的列表实例 */
|
|
489
|
+
identifier?: string;
|
|
490
|
+
/** 权限代码,用于权限控制 */
|
|
491
|
+
code?: string;
|
|
492
|
+
/** 表单实例,如果不提供则内部创建 */
|
|
493
|
+
form?: FormInstance<Values>;
|
|
494
|
+
/** 自动刷新间隔(毫秒),0 表示不自动刷新 */
|
|
495
|
+
refreshInterval?: number;
|
|
496
|
+
/** 请求配置,可以是静态配置或动态函数 */
|
|
497
|
+
request: InfiniteListRequestConfigType<Values, PageParamType>;
|
|
498
|
+
/** 表格额外内容,可以是静态内容或动态函数 */
|
|
499
|
+
tableExtra?: ReactNode | ((form: FormInstance<Values>, data?: Data[]) => ReactNode);
|
|
500
|
+
/** 自定义表单渲染函数 */
|
|
501
|
+
renderForm?: (form: FormInstance<Values>) => ReactElement;
|
|
502
|
+
/** 请求成功后的回调 */
|
|
503
|
+
afterSuccess?: (form: FormInstance<Values>, data?: Data[]) => void;
|
|
504
|
+
/** 请求失败后的回调 */
|
|
505
|
+
afterError?: (error: Error, form: FormInstance<Values>) => void;
|
|
506
|
+
/** 数据适配器,用于转换后端数据格式 */
|
|
507
|
+
dataAdapter?: InfiniteListDataAdapter<Item, Values, Data, PageParamType>;
|
|
508
|
+
/** 初始分页参数,默认为 0 */
|
|
509
|
+
initialPageParam?: PageParamType;
|
|
510
|
+
/** 表格底部内容,可以是静态内容或动态函数 */
|
|
511
|
+
footer?: (data: Data[] | undefined) => ReactNode;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* InfiniteList 组件
|
|
515
|
+
* @template Item 列表项类型
|
|
516
|
+
* @template Values 表单值类型
|
|
517
|
+
* @template Data 后端返回的数据类型
|
|
518
|
+
* @template PageParamType 分页参数的类型
|
|
519
|
+
*/
|
|
520
|
+
declare function InfiniteListComponent<Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any, PageParamType = PageParam>(props: InfiniteListProps<Item, Values, Data, PageParamType> & {
|
|
521
|
+
ref?: Ref<InfiniteListRef<Item, Values, Data>>;
|
|
522
|
+
}): ReactElement;
|
|
523
|
+
declare const InfiniteList: typeof InfiniteListComponent;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 通用列表实例接口
|
|
527
|
+
* @template Payload Payload 类型
|
|
528
|
+
* @template ExtraMethods 额外的实例方法(如 fetchNextPage)
|
|
529
|
+
*/
|
|
530
|
+
interface BaseListInstance<Payload, ExtraMethods = Record<string, unknown>> {
|
|
531
|
+
id: string;
|
|
532
|
+
url: string;
|
|
533
|
+
queryKey: readonly unknown[];
|
|
534
|
+
payload: Payload;
|
|
535
|
+
refetch: QueryRefetchFunction;
|
|
536
|
+
syncCallback?: StateSyncCallback<Payload>;
|
|
537
|
+
/** 额外的实例方法 */
|
|
538
|
+
extraMethods?: ExtraMethods;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* 通用列表状态接口
|
|
542
|
+
* @template Payload Payload 类型
|
|
543
|
+
* @template Instance 实例类型
|
|
544
|
+
*/
|
|
545
|
+
interface BaseListState<Payload, Instance extends BaseListInstance<Payload>> {
|
|
546
|
+
instances: Map<string, Instance>;
|
|
547
|
+
registerInstance(instance: Omit<Instance, 'payload'>): void;
|
|
548
|
+
unregisterInstance(id: string): void;
|
|
549
|
+
updatePayload(id: string, payload: Partial<Payload>, syncToComponent?: boolean): void;
|
|
550
|
+
getPayload(id: string): Payload;
|
|
551
|
+
refetch(id: string, payload?: Partial<Payload>): Promise<void>;
|
|
552
|
+
getInstance(id: string): Instance | undefined;
|
|
553
|
+
getAllInstances(): Instance[];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* InfiniteList 实例的额外方法
|
|
558
|
+
*/
|
|
559
|
+
interface InfiniteListExtraMethods extends Record<string, unknown> {
|
|
560
|
+
fetchNextPage: InfiniteQueryFetchNextPageFunction;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* InfiniteList 实例信息
|
|
564
|
+
*/
|
|
565
|
+
interface InfiniteListInstance extends BaseListInstance<InfiniteListPayload, InfiniteListExtraMethods> {
|
|
566
|
+
refetch: QueryRefetchFunction;
|
|
567
|
+
fetchNextPage: InfiniteQueryFetchNextPageFunction;
|
|
568
|
+
syncCallback?: StateSyncCallback<InfiniteListPayload>;
|
|
569
|
+
}
|
|
570
|
+
declare const baseStore$1: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<BaseListState<InfiniteListPayload, InfiniteListInstance>>, "setState" | "devtools"> & {
|
|
571
|
+
setState(partial: BaseListState<InfiniteListPayload, InfiniteListInstance> | Partial<BaseListState<InfiniteListPayload, InfiniteListInstance>> | ((state: BaseListState<InfiniteListPayload, InfiniteListInstance>) => BaseListState<InfiniteListPayload, InfiniteListInstance> | Partial<BaseListState<InfiniteListPayload, InfiniteListInstance>>), replace?: false | undefined, action?: (string | {
|
|
572
|
+
[x: string]: unknown;
|
|
573
|
+
[x: number]: unknown;
|
|
574
|
+
[x: symbol]: unknown;
|
|
575
|
+
type: string;
|
|
576
|
+
}) | undefined): void;
|
|
577
|
+
setState(state: BaseListState<InfiniteListPayload, InfiniteListInstance> | ((state: BaseListState<InfiniteListPayload, InfiniteListInstance>) => BaseListState<InfiniteListPayload, InfiniteListInstance>), replace: true, action?: (string | {
|
|
578
|
+
[x: string]: unknown;
|
|
579
|
+
[x: number]: unknown;
|
|
580
|
+
[x: symbol]: unknown;
|
|
581
|
+
type: string;
|
|
582
|
+
}) | undefined): void;
|
|
583
|
+
devtools: {
|
|
584
|
+
cleanup: () => void;
|
|
585
|
+
};
|
|
586
|
+
}, "subscribe"> & {
|
|
587
|
+
subscribe: {
|
|
588
|
+
(listener: (selectedState: BaseListState<InfiniteListPayload, InfiniteListInstance>, previousSelectedState: BaseListState<InfiniteListPayload, InfiniteListInstance>) => void): () => void;
|
|
589
|
+
<U>(selector: (state: BaseListState<InfiniteListPayload, InfiniteListInstance>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
590
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
591
|
+
fireImmediately?: boolean;
|
|
592
|
+
} | undefined): () => void;
|
|
593
|
+
};
|
|
594
|
+
}>;
|
|
595
|
+
declare const useInfiniteListStore: typeof baseStore$1 & {
|
|
596
|
+
registerInstance(id: string, url: string, queryKey: readonly unknown[], refetch: QueryRefetchFunction, fetchNextPage: InfiniteQueryFetchNextPageFunction, syncCallback?: StateSyncCallback<InfiniteListPayload>): void;
|
|
597
|
+
fetchNextPage: (id: string) => Promise<void>;
|
|
598
|
+
getQueryKey(id: string): readonly unknown[] | undefined;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* 标准列表响应格式
|
|
603
|
+
* @template T 列表项类型
|
|
604
|
+
*/
|
|
605
|
+
interface ListResponse<T = any> {
|
|
606
|
+
code: number;
|
|
607
|
+
data: {
|
|
608
|
+
list: T[];
|
|
609
|
+
total: number;
|
|
610
|
+
};
|
|
611
|
+
msg: string;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* 请求配置
|
|
615
|
+
* 支持配置 URL、方法、请求体、查询参数等
|
|
616
|
+
*/
|
|
617
|
+
interface QueryListRequestConfig extends CacheConfig {
|
|
618
|
+
url: string;
|
|
619
|
+
method?: HttpMethod;
|
|
620
|
+
body?: FormData | Record<string | number, any>;
|
|
621
|
+
searchParams?: Record<string | number, any>;
|
|
622
|
+
headers?: Record<string, string>;
|
|
623
|
+
/** 是否使用全局模式(覆盖 ToolkitsProvider 中的 isGlobalMode) */
|
|
624
|
+
isGlobalMode?: boolean;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* 请求配置类型
|
|
628
|
+
* 支持字符串、对象或函数形式:
|
|
629
|
+
* - string: 仅指定 url,其他参数使用默认值
|
|
630
|
+
* - 对象: 完整配置
|
|
631
|
+
* - 函数: 根据 payload 动态生成配置
|
|
632
|
+
*
|
|
633
|
+
* @template Values 筛选条件的类型
|
|
634
|
+
*/
|
|
635
|
+
type QueryListRequestConfigType<Values = any> = string | QueryListRequestConfig | ((payload: QueryListPayload<Values>) => QueryListRequestConfig);
|
|
636
|
+
/**
|
|
637
|
+
* 操作类型枚举
|
|
638
|
+
* 用于在回调函数中区分操作来源
|
|
639
|
+
*/
|
|
640
|
+
declare enum QueryListAction {
|
|
641
|
+
Confirm = 0,// 确认搜索
|
|
642
|
+
Reset = 1,// 重置表单
|
|
643
|
+
Jump = 2,// 跳转页码
|
|
644
|
+
Init = 3
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* QueryList 组件通过 ref 暴露的接口
|
|
648
|
+
* @template Item 列表项类型
|
|
649
|
+
* @template Values 表单值类型
|
|
650
|
+
* @template Data 响应数据类型
|
|
651
|
+
*/
|
|
652
|
+
interface QueryListRef<Item extends AnyObject = AnyObject, Values = AnyObject, Data = ListResponse<Item>> {
|
|
653
|
+
data: Data | undefined;
|
|
654
|
+
dataSource: Item[] | undefined;
|
|
655
|
+
form: FormInstance<Values>;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* 数据适配器配置
|
|
659
|
+
* 用于从响应数据中提取列表项和总数
|
|
660
|
+
* @template Item 列表项类型
|
|
661
|
+
*/
|
|
662
|
+
interface QueryListDataAdapter<Item extends AnyObject = AnyObject> {
|
|
663
|
+
total?: number;
|
|
664
|
+
items?: Item[];
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* 数据适配器配置类型
|
|
668
|
+
* 支持对象或函数形式,函数形式可以根据响应数据动态提取
|
|
669
|
+
* @template Item 列表项类型
|
|
670
|
+
* @template Data 响应数据类型
|
|
671
|
+
*/
|
|
672
|
+
type QueryListDataAdapterConfig<Item extends AnyObject = AnyObject, Data = ListResponse<Item>> = QueryListDataAdapter<Item> | ((data: Data) => QueryListDataAdapter<Item>);
|
|
673
|
+
/**
|
|
674
|
+
* QueryList 组件的 Props
|
|
675
|
+
* @template Item 列表项类型
|
|
676
|
+
* @template Values 表单值类型
|
|
677
|
+
* @template Data 响应数据类型
|
|
678
|
+
*/
|
|
679
|
+
interface QueryListProps<Item extends AnyObject = AnyObject, Values = AnyObject, Data = ListResponse<Item>> extends Omit<TableProps<Item>, 'pagination' | 'dataSource' | 'loading' | 'footer'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
|
|
680
|
+
/** 可选的标识符,用于标识和外部控制,未提供时自动生成 */
|
|
681
|
+
identifier?: string;
|
|
682
|
+
/** 权限代码,用于权限检查 */
|
|
683
|
+
code?: string;
|
|
684
|
+
/** 表单实例,如果不提供会自动创建 */
|
|
685
|
+
form?: FormInstance<Values>;
|
|
686
|
+
/** 轮询间隔(毫秒),0 表示不轮询 */
|
|
687
|
+
refreshInterval?: number;
|
|
688
|
+
/** 是否无分页,为 true 时不显示分页组件 */
|
|
689
|
+
onePage?: boolean;
|
|
690
|
+
/** 默认每页数量 */
|
|
691
|
+
defaultSize?: number;
|
|
692
|
+
/** 每页数量选项 */
|
|
693
|
+
pageSizeOptions?: number[];
|
|
694
|
+
/** 请求配置,支持对象或函数形式 */
|
|
695
|
+
request: QueryListRequestConfigType<Values>;
|
|
696
|
+
/** 表格额外内容,支持节点或函数形式 */
|
|
697
|
+
tableExtra?: ReactNode | ((form: FormInstance<Values>, data?: Data) => ReactNode);
|
|
698
|
+
/** 表单渲染函数 */
|
|
699
|
+
renderForm?: (form: FormInstance<Values>) => ReactElement;
|
|
700
|
+
/** 请求成功后的回调 */
|
|
701
|
+
afterSuccess?: (action: QueryListAction, form: FormInstance<Values>, data?: Data) => void;
|
|
702
|
+
/** 请求失败后的回调 */
|
|
703
|
+
afterError?: (error: Error, action: QueryListAction, form: FormInstance<Values>) => void;
|
|
704
|
+
/** 数据适配器,用于从响应数据中提取列表项和总数 */
|
|
705
|
+
dataAdapter?: QueryListDataAdapterConfig<Item, Data>;
|
|
706
|
+
/** 表格底部内容 */
|
|
707
|
+
footer?: (data: Data | undefined) => ReactNode;
|
|
708
|
+
}
|
|
709
|
+
declare const QueryList: <Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any>(props: QueryListProps<Item, Values, Data> & {
|
|
710
|
+
ref?: Ref<QueryListRef<Item, Values, Data>>;
|
|
711
|
+
}) => ReactElement;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* QueryList 实例信息
|
|
715
|
+
*/
|
|
716
|
+
interface QueryListInstance extends BaseListInstance<QueryListPayload> {
|
|
717
|
+
refetch: QueryRefetchFunction;
|
|
718
|
+
syncCallback?: StateSyncCallback<QueryListPayload>;
|
|
719
|
+
}
|
|
720
|
+
declare const baseStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<BaseListState<QueryListPayload<any>, QueryListInstance>>, "setState" | "devtools"> & {
|
|
721
|
+
setState(partial: BaseListState<QueryListPayload<any>, QueryListInstance> | Partial<BaseListState<QueryListPayload<any>, QueryListInstance>> | ((state: BaseListState<QueryListPayload<any>, QueryListInstance>) => BaseListState<QueryListPayload<any>, QueryListInstance> | Partial<BaseListState<QueryListPayload<any>, QueryListInstance>>), replace?: false | undefined, action?: (string | {
|
|
722
|
+
[x: string]: unknown;
|
|
723
|
+
[x: number]: unknown;
|
|
724
|
+
[x: symbol]: unknown;
|
|
725
|
+
type: string;
|
|
726
|
+
}) | undefined): void;
|
|
727
|
+
setState(state: BaseListState<QueryListPayload<any>, QueryListInstance> | ((state: BaseListState<QueryListPayload<any>, QueryListInstance>) => BaseListState<QueryListPayload<any>, QueryListInstance>), replace: true, action?: (string | {
|
|
728
|
+
[x: string]: unknown;
|
|
729
|
+
[x: number]: unknown;
|
|
730
|
+
[x: symbol]: unknown;
|
|
731
|
+
type: string;
|
|
732
|
+
}) | undefined): void;
|
|
733
|
+
devtools: {
|
|
734
|
+
cleanup: () => void;
|
|
735
|
+
};
|
|
736
|
+
}, "subscribe"> & {
|
|
737
|
+
subscribe: {
|
|
738
|
+
(listener: (selectedState: BaseListState<QueryListPayload<any>, QueryListInstance>, previousSelectedState: BaseListState<QueryListPayload<any>, QueryListInstance>) => void): () => void;
|
|
739
|
+
<U>(selector: (state: BaseListState<QueryListPayload<any>, QueryListInstance>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
740
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
741
|
+
fireImmediately?: boolean;
|
|
742
|
+
} | undefined): () => void;
|
|
743
|
+
};
|
|
744
|
+
}>;
|
|
745
|
+
declare const useQueryListStore: typeof baseStore & {
|
|
746
|
+
registerInstance(id: string, url: string, queryKey: readonly unknown[], refetch: QueryRefetchFunction, syncCallback?: StateSyncCallback<QueryListPayload>): void;
|
|
747
|
+
getQueryKey(id: string): readonly unknown[] | undefined;
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
type LogoProps = Omit<DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'src' | 'alt'>;
|
|
751
|
+
declare const Logo: FC<LogoProps>;
|
|
752
|
+
|
|
753
|
+
interface RequireAuthProps {
|
|
754
|
+
/** 权限码 */
|
|
755
|
+
code: string;
|
|
756
|
+
/** 请求配置 */
|
|
757
|
+
config?: RequestOptions;
|
|
758
|
+
/** 无权限时点击返回按钮跳转的路径,默认为首页 '/' */
|
|
759
|
+
redirectPath?: string;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* 授权保护组件
|
|
763
|
+
* 根据权限码控制子组件的访问权限
|
|
764
|
+
* - 有权限:渲染子组件
|
|
765
|
+
* - 无权限:显示 403 无权限页面,可点击按钮返回指定路径
|
|
766
|
+
* - 加载中:显示加载动画
|
|
767
|
+
*/
|
|
768
|
+
declare const RequireAuth: FC<PropsWithChildren<RequireAuthProps>>;
|
|
769
|
+
|
|
770
|
+
declare const RequireGame: FC<PropsWithChildren>;
|
|
771
|
+
|
|
772
|
+
type BaseValue = string | number;
|
|
773
|
+
type InternalValue<V extends BaseValue> = V | string;
|
|
774
|
+
type InternalValueArray<V extends BaseValue> = Array<InternalValue<V>>;
|
|
775
|
+
interface SelectAllProps<V extends BaseValue = string> extends Omit<SelectProps<InternalValueArray<V>>, 'mode' | 'options' | 'value' | 'onChange'> {
|
|
776
|
+
/** antd Select options(支持分组) */
|
|
777
|
+
options: NonNullable<SelectProps<V>['options']>;
|
|
778
|
+
/** 当前选中值(多选) */
|
|
779
|
+
value?: V[];
|
|
780
|
+
/** 选中值变化回调(不会包含“全选”占位 value) */
|
|
781
|
+
onChange?: (value: V[], option: unknown) => void;
|
|
782
|
+
/** Select mode,默认 multiple */
|
|
783
|
+
mode?: 'multiple' | 'tags';
|
|
784
|
+
/** “全选”显示文案 */
|
|
785
|
+
allLabel?: ReactNode;
|
|
786
|
+
/** “全选”的占位 value,需避免与业务 value 冲突 */
|
|
787
|
+
allValue?: string;
|
|
788
|
+
/** 计算“全选”时是否包含 disabled 的选项,默认 false */
|
|
789
|
+
includeDisabledInAll?: boolean;
|
|
790
|
+
}
|
|
791
|
+
declare const SelectAll: <V extends BaseValue = string>(props: SelectAllProps<V>) => react_jsx_runtime.JSX.Element;
|
|
792
|
+
|
|
793
|
+
declare const SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
|
|
794
|
+
declare const APP_ID_HEADER = "App-ID";
|
|
795
|
+
declare const FRONTEND_ROUTE_PREFIX = "/console/";
|
|
796
|
+
/**
|
|
797
|
+
* 认证系统模式枚举
|
|
798
|
+
* - GAME_SCOPED: 游戏范围权限(角色权限包含游戏信息)
|
|
799
|
+
* - GROUP_BASED: 基于项目组的权限(需要先选择项目组才能选择游戏)
|
|
800
|
+
* - DIRECT_GAME: 直接游戏权限(不需要项目组,直接选择游戏)
|
|
801
|
+
*/
|
|
802
|
+
declare enum AuthMode {
|
|
803
|
+
/** 游戏范围权限:角色权限包含游戏范围信息 */
|
|
804
|
+
GAME_SCOPED = "game_scoped",
|
|
805
|
+
/** 基于项目组的权限:权限依赖项目组,需要先选择项目组才能选择游戏 */
|
|
806
|
+
GROUP_BASED = "group_based",
|
|
807
|
+
/** 直接游戏权限:权限直接选择游戏,不需要项目组作为中间层 */
|
|
808
|
+
DIRECT_GAME = "direct_game"
|
|
809
|
+
}
|
|
810
|
+
declare const WILDCARD = "*";
|
|
811
|
+
|
|
812
|
+
type Locale = {
|
|
813
|
+
global: {
|
|
814
|
+
noEntitlement: string;
|
|
815
|
+
name: string;
|
|
816
|
+
creationTime: string;
|
|
817
|
+
operation: string;
|
|
818
|
+
update: string;
|
|
819
|
+
edit: string;
|
|
820
|
+
delete: string;
|
|
821
|
+
selectAll: string;
|
|
822
|
+
game: string;
|
|
823
|
+
user: string;
|
|
824
|
+
role: string;
|
|
825
|
+
username: string;
|
|
826
|
+
password: string;
|
|
827
|
+
label: string;
|
|
828
|
+
method: string;
|
|
829
|
+
route: string;
|
|
830
|
+
request: string;
|
|
831
|
+
response: string;
|
|
832
|
+
add: string;
|
|
833
|
+
signIn: string;
|
|
834
|
+
projectGroup: string;
|
|
835
|
+
view: string;
|
|
836
|
+
back: string;
|
|
837
|
+
};
|
|
838
|
+
SignIn: {
|
|
839
|
+
title: string;
|
|
840
|
+
signInWithIDass: string;
|
|
841
|
+
unregistered: string;
|
|
842
|
+
welcome: string;
|
|
843
|
+
};
|
|
844
|
+
NotFound: {
|
|
845
|
+
subTitle: string;
|
|
846
|
+
buttonText: string;
|
|
847
|
+
};
|
|
848
|
+
FilterFormWrapper: {
|
|
849
|
+
confirmText: string;
|
|
850
|
+
resetText: string;
|
|
851
|
+
};
|
|
852
|
+
FormModal: {
|
|
853
|
+
confirmText: string;
|
|
854
|
+
cancelText: string;
|
|
855
|
+
};
|
|
856
|
+
GameSelect: {
|
|
857
|
+
label: string;
|
|
858
|
+
placeholder: string;
|
|
859
|
+
};
|
|
860
|
+
RequireGame: {
|
|
861
|
+
description: string;
|
|
862
|
+
};
|
|
863
|
+
UserDropdown: {
|
|
864
|
+
signOutText: string;
|
|
865
|
+
};
|
|
866
|
+
User: {
|
|
867
|
+
createTitle: string;
|
|
868
|
+
createSuccessfully: string;
|
|
869
|
+
updateTitle: string;
|
|
870
|
+
updateSuccessfully: string;
|
|
871
|
+
deleteTitle: string;
|
|
872
|
+
deleteContent: string;
|
|
873
|
+
deleteSuccessfully: string;
|
|
874
|
+
};
|
|
875
|
+
Role: {
|
|
876
|
+
createTitle: string;
|
|
877
|
+
createSuccessfully: string;
|
|
878
|
+
updateTitle: string;
|
|
879
|
+
updateSuccessfully: string;
|
|
880
|
+
deleteTitle: string;
|
|
881
|
+
deleteContent: string;
|
|
882
|
+
deleteSuccessfully: string;
|
|
883
|
+
};
|
|
884
|
+
PermissionList: {
|
|
885
|
+
failedDescription: string;
|
|
886
|
+
baseSectionTitle: string;
|
|
887
|
+
gameSectionTitle: string;
|
|
888
|
+
gameSectionDescription: string;
|
|
889
|
+
gameSelectPlaceholder: string;
|
|
890
|
+
removeText: string;
|
|
891
|
+
addText: string;
|
|
892
|
+
};
|
|
893
|
+
RoleDetail: {
|
|
894
|
+
title: string;
|
|
895
|
+
};
|
|
896
|
+
InfiniteList: {
|
|
897
|
+
loadingText: string;
|
|
898
|
+
reachEndText: string;
|
|
899
|
+
loadMoreText: string;
|
|
900
|
+
};
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
interface ContextSlice {
|
|
904
|
+
/** 是否使用游戏 API V2 版本 */
|
|
905
|
+
useGameApiV2: boolean;
|
|
906
|
+
/** 接口基础路径 */
|
|
907
|
+
apiBaseUrl?: string;
|
|
908
|
+
/** 登录页路径 */
|
|
909
|
+
loginPath: string;
|
|
910
|
+
/** 首页地址 */
|
|
911
|
+
homePath: string;
|
|
912
|
+
/** 侧边栏宽度 */
|
|
913
|
+
sidebarWidth?: number;
|
|
914
|
+
/** 侧边栏是否可折叠 */
|
|
915
|
+
sidebarCollapsible?: boolean;
|
|
916
|
+
/** 数据是否按游戏划分范围,默认为 false */
|
|
917
|
+
gameScoped?: boolean;
|
|
918
|
+
/** 本地化语言包 */
|
|
919
|
+
locale: Locale;
|
|
920
|
+
/** 认证模式 */
|
|
921
|
+
authMode: AuthMode;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
interface GameSlice {
|
|
925
|
+
appId?: string | number;
|
|
926
|
+
setAppId: (id?: string | number) => void;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
interface LayoutSlice {
|
|
930
|
+
collapsed: boolean;
|
|
931
|
+
toggleCollapsed: () => void;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* 导航菜单状态接口
|
|
936
|
+
*/
|
|
937
|
+
interface NavSlice {
|
|
938
|
+
/** 当前展开的菜单项 key 数组 */
|
|
939
|
+
openKeys: string[];
|
|
940
|
+
/** 当前选中的菜单项 key 数组 */
|
|
941
|
+
selectedKeys: string[];
|
|
942
|
+
/** 设置展开的菜单项 */
|
|
943
|
+
setOpenKeys: (keys: string[]) => void;
|
|
944
|
+
/** 设置选中的菜单项 */
|
|
945
|
+
setSelectedKeys: (keys: string[]) => void;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* JWT Token 解密后的用户信息
|
|
950
|
+
*/
|
|
951
|
+
interface UserInfo {
|
|
952
|
+
authorityId: string;
|
|
953
|
+
exp: number;
|
|
954
|
+
}
|
|
955
|
+
interface TokenSlice {
|
|
956
|
+
/** JWT Token */
|
|
957
|
+
token?: string;
|
|
958
|
+
user: UserInfo | null;
|
|
959
|
+
setToken: (token: string) => void;
|
|
960
|
+
clearToken: () => void;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
type ToolkitsState = {
|
|
964
|
+
context: ContextSlice;
|
|
965
|
+
token: TokenSlice;
|
|
966
|
+
game: GameSlice;
|
|
967
|
+
layout: LayoutSlice;
|
|
968
|
+
nav: NavSlice;
|
|
969
|
+
clear: () => void;
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
declare function useToolkitsStore(): ToolkitsState;
|
|
973
|
+
declare function useToolkitsStore<T>(selector: (state: ToolkitsState) => T): T;
|
|
974
|
+
type ToolkitsProviderProps = PropsWithChildren<DeepPartial<ContextSlice>>;
|
|
975
|
+
/**
|
|
976
|
+
* ToolkitsProvider 组件
|
|
977
|
+
*
|
|
978
|
+
* 支持嵌套使用,子 Provider 会从最近的父 Provider 继承 context 配置。
|
|
979
|
+
* 子 Provider 的 props 会覆盖父 Provider 的对应配置。
|
|
980
|
+
*
|
|
981
|
+
* 当父级 context 或当前 props 发生变化时,会重新创建 store 以确保配置同步。
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* 外层 Provider 和内层 Provider 嵌套使用示例:
|
|
985
|
+
* - 外层:loginPath="/login" apiBaseUrl="https://api.example.com"
|
|
986
|
+
* - 内层:apiBaseUrl="https://api-v2.example.com" (会覆盖外层的 apiBaseUrl)
|
|
987
|
+
*/
|
|
988
|
+
declare const ToolkitsProvider: FC<ToolkitsProviderProps>;
|
|
989
|
+
|
|
990
|
+
declare const UserDropdown: FC;
|
|
991
|
+
|
|
992
|
+
/** 抽屉操作对象 */
|
|
993
|
+
interface UseDrawerOperation {
|
|
994
|
+
/** 隐藏抽屉 */
|
|
995
|
+
hide: () => void;
|
|
996
|
+
}
|
|
997
|
+
/** useDrawer 的配置选项 */
|
|
998
|
+
interface UseDrawerProps extends Omit<DrawerProps, 'open' | 'confirmLoading' | 'onClose' | 'footer'> {
|
|
999
|
+
/** 抽屉内容,可以是 ReactNode 或函数 */
|
|
1000
|
+
content?: ReactNode | ((operation: UseDrawerOperation) => ReactNode);
|
|
1001
|
+
/** 确认回调 */
|
|
1002
|
+
onConfirm?: () => void | Promise<void>;
|
|
1003
|
+
/** 打开后回调 */
|
|
1004
|
+
afterOpen?: () => void | Promise<void>;
|
|
1005
|
+
/** 关闭后回调 */
|
|
1006
|
+
afterClose?: () => void | Promise<void>;
|
|
1007
|
+
/** 自定义底部(传 null 隐藏底部) */
|
|
1008
|
+
footer?: ReactNode | null;
|
|
1009
|
+
/** 确认按钮文本 */
|
|
1010
|
+
confirmText?: string;
|
|
1011
|
+
/** 取消按钮文本 */
|
|
1012
|
+
cancelText?: string;
|
|
1013
|
+
/** 确认按钮配置 */
|
|
1014
|
+
confirmButtonProps?: ComponentProps<typeof Button>;
|
|
1015
|
+
/** 取消按钮配置 */
|
|
1016
|
+
cancelButtonProps?: ComponentProps<typeof Button>;
|
|
1017
|
+
}
|
|
1018
|
+
declare function useDrawer(props: UseDrawerProps): {
|
|
1019
|
+
id: number;
|
|
1020
|
+
show: () => Promise<void>;
|
|
1021
|
+
hide: () => void;
|
|
1022
|
+
confirmLoading: boolean;
|
|
1023
|
+
drawer: react_jsx_runtime.JSX.Element;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
interface Permission {
|
|
1027
|
+
label: string;
|
|
1028
|
+
value: string;
|
|
1029
|
+
route: string;
|
|
1030
|
+
method?: string;
|
|
1031
|
+
}
|
|
1032
|
+
interface MenuListItem {
|
|
1033
|
+
id: number;
|
|
1034
|
+
category: string;
|
|
1035
|
+
is_common: boolean;
|
|
1036
|
+
is_model: boolean;
|
|
1037
|
+
model_name: string;
|
|
1038
|
+
permissions: Permission[];
|
|
1039
|
+
front_route: string;
|
|
1040
|
+
order: number;
|
|
1041
|
+
scheme: string;
|
|
1042
|
+
ext: string;
|
|
1043
|
+
}
|
|
1044
|
+
type RecursivePartial<T> = NonNullable<T> extends object ? {
|
|
1045
|
+
[P in keyof T]?: NonNullable<T[P]> extends (infer U)[] ? RecursivePartial<U>[] : NonNullable<T[P]> extends object ? RecursivePartial<T[P]> : T[P];
|
|
1046
|
+
} : T;
|
|
1047
|
+
interface JsonResponse<T> {
|
|
1048
|
+
code: number;
|
|
1049
|
+
message: string;
|
|
1050
|
+
data: T;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* 条件类型:根据 ExtraValues 是否为默认空对象,决定 extraValues 是否必传
|
|
1055
|
+
* - 如果 ExtraValues 是 Record<string, unknown>,extraValues 为可选
|
|
1056
|
+
* - 如果 ExtraValues 是具体类型(有明确字段),extraValues 为必传
|
|
1057
|
+
*/
|
|
1058
|
+
type BaseShowFormOptions$1<Values extends AnyObject, ExtraValues> = {
|
|
1059
|
+
initialValues?: RecursivePartial<Values>;
|
|
1060
|
+
extraValues?: ExtraValues;
|
|
1061
|
+
};
|
|
1062
|
+
type ShowFormOptions$1<Values extends AnyObject, ExtraValues> = Record<string, unknown> extends ExtraValues ? BaseShowFormOptions$1<Values, ExtraValues> : MarkRequired<BaseShowFormOptions$1<Values, ExtraValues>, 'extraValues'>;
|
|
1063
|
+
/**
|
|
1064
|
+
* useFormDrawer 的配置选项
|
|
1065
|
+
* @template Values 表单值类型
|
|
1066
|
+
* @template ExtraValues 额外参数类型,如果指定具体类型(非 Record<string, unknown>),调用 show 时必须传入
|
|
1067
|
+
*/
|
|
1068
|
+
interface UseFormDrawerProps<Values extends AnyObject = AnyObject, ExtraValues = Record<string, unknown>> extends Omit<UseDrawerProps, 'onConfirm' | 'content' | 'afterClose'> {
|
|
1069
|
+
/** 表单配置 */
|
|
1070
|
+
formProps?: Omit<FormProps, 'form'>;
|
|
1071
|
+
/** 表单实例(可选,不传则自动创建) */
|
|
1072
|
+
form?: FormInstance<Values>;
|
|
1073
|
+
/** 抽屉内容,可以是 ReactNode 或函数 */
|
|
1074
|
+
content?: ReactNode | ((extraValues: ExtraValues, operation: UseDrawerOperation) => ReactNode);
|
|
1075
|
+
/** 表单提交回调 */
|
|
1076
|
+
onConfirm?: (values: Values, extraValues: ExtraValues) => void | Promise<void>;
|
|
1077
|
+
/** 提交成功回调 */
|
|
1078
|
+
onSuccess?: () => void;
|
|
1079
|
+
/** 关闭后回调 */
|
|
1080
|
+
afterClose?: (form: FormInstance<Values>) => void;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* useFormDrawer 的返回值
|
|
1084
|
+
* @template Values 表单值类型
|
|
1085
|
+
* @template ExtraValues 额外参数类型
|
|
1086
|
+
*/
|
|
1087
|
+
interface UseFormDrawerReturn<Values extends AnyObject, ExtraValues> {
|
|
1088
|
+
/** 抽屉唯一标识 */
|
|
1089
|
+
id: number;
|
|
1090
|
+
/** 显示抽屉,根据 ExtraValues 类型自动判断参数是否必传 */
|
|
1091
|
+
show: (options?: ShowFormOptions$1<Values, ExtraValues>) => void;
|
|
1092
|
+
/** 隐藏抽屉 */
|
|
1093
|
+
hide: () => void;
|
|
1094
|
+
/** 抽屉组件 */
|
|
1095
|
+
drawer: ReactNode;
|
|
1096
|
+
}
|
|
1097
|
+
declare function useFormDrawer<Values extends AnyObject = AnyObject, ExtraValues = Record<string, unknown>>(props: UseFormDrawerProps<Values, ExtraValues>): UseFormDrawerReturn<Values, ExtraValues>;
|
|
1098
|
+
|
|
1099
|
+
interface VisibilityState {
|
|
1100
|
+
open: Map<number, boolean>;
|
|
1101
|
+
usedIds: Set<number>;
|
|
1102
|
+
isOpen: (uuid: number) => boolean;
|
|
1103
|
+
show: (uuid: number) => void;
|
|
1104
|
+
hide: (uuid: number) => void;
|
|
1105
|
+
hideAll: () => void;
|
|
1106
|
+
checkUniqueness: (uuid: number) => boolean;
|
|
1107
|
+
registerIds: (uuid: number) => boolean;
|
|
1108
|
+
cleanup: (uuid: number) => void;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* 创建可见性管理的 Zustand store 配置
|
|
1112
|
+
* 这是一个纯函数,返回 store 的配置对象
|
|
1113
|
+
* 使用函数形式延迟执行,避免模块初始化顺序问题
|
|
1114
|
+
*/
|
|
1115
|
+
declare function createVisibilityStoreConfig(): StateCreator<VisibilityState, [], [], VisibilityState>;
|
|
1116
|
+
|
|
1117
|
+
declare const generateId: () => number;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* 混合存储策略
|
|
1121
|
+
* - 优先从 SessionStorage 读取数据,防止多开页面时的数据冲突
|
|
1122
|
+
* - 写入时同时更新 SessionStorage 和 LocalStorage
|
|
1123
|
+
* - SessionStorage 不存在时,fallback 到 LocalStorage
|
|
1124
|
+
*/
|
|
1125
|
+
declare const mixedStorage: StateStorage;
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Drawer store hook
|
|
1129
|
+
* 使用 lazy initialization 确保 create 函数在调用时已经准备好
|
|
1130
|
+
*/
|
|
1131
|
+
declare function useDrawerStore(): VisibilityState;
|
|
1132
|
+
|
|
1133
|
+
/** 模态框操作对象 */
|
|
1134
|
+
interface UseModalOperation {
|
|
1135
|
+
/** 隐藏模态框 */
|
|
1136
|
+
hide: () => void;
|
|
1137
|
+
}
|
|
1138
|
+
/** useModal 的配置选项 */
|
|
1139
|
+
interface UseModalProps extends Omit<ModalProps, 'open' | 'confirmLoading' | 'onOk' | 'onCancel'> {
|
|
1140
|
+
/** 模态框内容,可以是 ReactNode 或函数 */
|
|
1141
|
+
content?: ReactNode | ((operation: UseModalOperation) => ReactNode);
|
|
1142
|
+
/** 确认回调 */
|
|
1143
|
+
onConfirm?: () => void | Promise<void>;
|
|
1144
|
+
/** 打开后回调 */
|
|
1145
|
+
afterOpen?: () => void | Promise<void>;
|
|
1146
|
+
/** 关闭后回调 */
|
|
1147
|
+
afterClose?: () => void | Promise<void>;
|
|
1148
|
+
}
|
|
1149
|
+
declare function useModal(props: UseModalProps): {
|
|
1150
|
+
id: number;
|
|
1151
|
+
show: () => Promise<void>;
|
|
1152
|
+
hide: () => void;
|
|
1153
|
+
modal: react_jsx_runtime.JSX.Element;
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* 条件类型:根据 ExtraValues 是否为默认空对象,决定 extraValues 是否必传
|
|
1158
|
+
* - 如果 ExtraValues 是 Record<string, unknown>,extraValues 为可选
|
|
1159
|
+
* - 如果 ExtraValues 是具体类型(有明确字段),extraValues 为必传
|
|
1160
|
+
*/
|
|
1161
|
+
type BaseShowFormOptions<Values extends AnyObject, ExtraValues> = {
|
|
1162
|
+
initialValues?: RecursivePartial<Values>;
|
|
1163
|
+
extraValues?: ExtraValues;
|
|
1164
|
+
};
|
|
1165
|
+
type ShowFormOptions<Values extends AnyObject, ExtraValues> = Record<string, unknown> extends ExtraValues ? BaseShowFormOptions<Values, ExtraValues> : MarkRequired<BaseShowFormOptions<Values, ExtraValues>, 'extraValues'>;
|
|
1166
|
+
/**
|
|
1167
|
+
* useFormModal 的配置选项
|
|
1168
|
+
* @template Values 表单值类型
|
|
1169
|
+
* @template ExtraValues 额外参数类型,如果指定具体类型(非 Record<string, unknown>),调用 show 时必须传入
|
|
1170
|
+
*/
|
|
1171
|
+
interface UseFormModalProps<Values extends AnyObject = AnyObject, ExtraValues = Record<string, unknown>> extends Omit<UseModalProps, 'onConfirm' | 'content' | 'afterClose'> {
|
|
1172
|
+
/** 表单配置 */
|
|
1173
|
+
formProps?: Omit<FormProps, 'form'>;
|
|
1174
|
+
/** 表单实例(可选,不传则自动创建) */
|
|
1175
|
+
form?: FormInstance<Values>;
|
|
1176
|
+
/** 模态框内容,可以是 ReactNode 或函数 */
|
|
1177
|
+
content?: ReactNode | ((extraValues: ExtraValues, operation: UseModalOperation) => ReactNode);
|
|
1178
|
+
/** 表单提交回调 */
|
|
1179
|
+
onConfirm?: (values: Values, extraValues: ExtraValues) => void | Promise<void>;
|
|
1180
|
+
/** 提交成功回调 */
|
|
1181
|
+
onSuccess?: () => void;
|
|
1182
|
+
/** 关闭后回调 */
|
|
1183
|
+
afterClose?: (form: FormInstance<Values>) => void;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* useFormModal 的返回值
|
|
1187
|
+
* @template Values 表单值类型
|
|
1188
|
+
* @template ExtraValues 额外参数类型
|
|
1189
|
+
*/
|
|
1190
|
+
interface UseFormModalReturn<Values extends AnyObject, ExtraValues> {
|
|
1191
|
+
/** 模态框唯一标识 */
|
|
1192
|
+
id: number;
|
|
1193
|
+
/** 显示模态框,根据 ExtraValues 类型自动判断参数是否必传 */
|
|
1194
|
+
show: (options?: ShowFormOptions<Values, ExtraValues>) => void;
|
|
1195
|
+
/** 隐藏模态框 */
|
|
1196
|
+
hide: () => void;
|
|
1197
|
+
/** 模态框组件 */
|
|
1198
|
+
modal: ReactNode;
|
|
1199
|
+
}
|
|
1200
|
+
declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues = Record<string, unknown>>(props: UseFormModalProps<Values, ExtraValues>): UseFormModalReturn<Values, ExtraValues>;
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Modal store hook
|
|
1204
|
+
* 使用 lazy initialization 确保 create 函数在调用时已经准备好
|
|
1205
|
+
*/
|
|
1206
|
+
declare function useModalStore(): VisibilityState;
|
|
1207
|
+
|
|
1208
|
+
interface NotFoundProps {
|
|
1209
|
+
redirectUrl?: string;
|
|
1210
|
+
}
|
|
1211
|
+
declare const NotFound: FC<NotFoundProps>;
|
|
1212
|
+
|
|
1213
|
+
declare const OperationLogList: FC;
|
|
1214
|
+
|
|
1215
|
+
interface SignInProps {
|
|
1216
|
+
extra?: ReactNode;
|
|
1217
|
+
title?: string;
|
|
1218
|
+
titleStyle?: CSSProperties;
|
|
1219
|
+
}
|
|
1220
|
+
declare const SignIn: FC<SignInProps>;
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* 菜单管理路由配置
|
|
1224
|
+
* 用于在 React Router 的 createRoutesFromElements 中使用
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* ```tsx
|
|
1228
|
+
* import { menuRoutes } from '@flow97/react-toolkit'
|
|
1229
|
+
* import { createRoutesFromElements, Outlet, Route } from 'react-router'
|
|
1230
|
+
*
|
|
1231
|
+
* createRoutesFromElements(
|
|
1232
|
+
* <Route path="menu/*">
|
|
1233
|
+
* {menuRoutes}
|
|
1234
|
+
* </Route>
|
|
1235
|
+
* )
|
|
1236
|
+
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
declare const _default$1: react_jsx_runtime.JSX.Element;
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* 权限管理路由配置
|
|
1242
|
+
* 用于在 React Router 的 createRoutesFromElements 中使用
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```tsx
|
|
1246
|
+
* import { permissionRoutes, PermissionRoutesWrapper } from '@flow97/react-toolkit'
|
|
1247
|
+
* import { createRoutesFromElements, Route } from 'react-router'
|
|
1248
|
+
*
|
|
1249
|
+
* createRoutesFromElements(
|
|
1250
|
+
* <Route path="permission/*" element={<PermissionRoutesWrapper />}>
|
|
1251
|
+
* {permissionRoutes}
|
|
1252
|
+
* </Route>
|
|
1253
|
+
* )
|
|
1254
|
+
* ```
|
|
1255
|
+
*/
|
|
1256
|
+
declare const _default: react_jsx_runtime.JSX.Element;
|
|
1257
|
+
|
|
1258
|
+
declare function useAuth(code?: string | string[], config?: RequestOptions): {
|
|
1259
|
+
data: boolean | Record<string, boolean>;
|
|
1260
|
+
error: Error;
|
|
1261
|
+
isError: true;
|
|
1262
|
+
isPending: false;
|
|
1263
|
+
isLoading: false;
|
|
1264
|
+
isLoadingError: false;
|
|
1265
|
+
isRefetchError: true;
|
|
1266
|
+
isSuccess: false;
|
|
1267
|
+
isPlaceholderData: false;
|
|
1268
|
+
status: "error";
|
|
1269
|
+
dataUpdatedAt: number;
|
|
1270
|
+
errorUpdatedAt: number;
|
|
1271
|
+
failureCount: number;
|
|
1272
|
+
failureReason: Error | null;
|
|
1273
|
+
errorUpdateCount: number;
|
|
1274
|
+
isFetched: boolean;
|
|
1275
|
+
isFetchedAfterMount: boolean;
|
|
1276
|
+
isFetching: boolean;
|
|
1277
|
+
isInitialLoading: boolean;
|
|
1278
|
+
isPaused: boolean;
|
|
1279
|
+
isRefetching: boolean;
|
|
1280
|
+
isStale: boolean;
|
|
1281
|
+
isEnabled: boolean;
|
|
1282
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1283
|
+
has_all?: boolean;
|
|
1284
|
+
}, Error>>;
|
|
1285
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1286
|
+
promise: Promise<Record<string, boolean> & {
|
|
1287
|
+
has_all?: boolean;
|
|
1288
|
+
}>;
|
|
1289
|
+
} | {
|
|
1290
|
+
data: boolean | Record<string, boolean>;
|
|
1291
|
+
error: null;
|
|
1292
|
+
isError: false;
|
|
1293
|
+
isPending: false;
|
|
1294
|
+
isLoading: false;
|
|
1295
|
+
isLoadingError: false;
|
|
1296
|
+
isRefetchError: false;
|
|
1297
|
+
isSuccess: true;
|
|
1298
|
+
isPlaceholderData: false;
|
|
1299
|
+
status: "success";
|
|
1300
|
+
dataUpdatedAt: number;
|
|
1301
|
+
errorUpdatedAt: number;
|
|
1302
|
+
failureCount: number;
|
|
1303
|
+
failureReason: Error | null;
|
|
1304
|
+
errorUpdateCount: number;
|
|
1305
|
+
isFetched: boolean;
|
|
1306
|
+
isFetchedAfterMount: boolean;
|
|
1307
|
+
isFetching: boolean;
|
|
1308
|
+
isInitialLoading: boolean;
|
|
1309
|
+
isPaused: boolean;
|
|
1310
|
+
isRefetching: boolean;
|
|
1311
|
+
isStale: boolean;
|
|
1312
|
+
isEnabled: boolean;
|
|
1313
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1314
|
+
has_all?: boolean;
|
|
1315
|
+
}, Error>>;
|
|
1316
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1317
|
+
promise: Promise<Record<string, boolean> & {
|
|
1318
|
+
has_all?: boolean;
|
|
1319
|
+
}>;
|
|
1320
|
+
} | {
|
|
1321
|
+
data: boolean | Record<string, boolean>;
|
|
1322
|
+
error: Error;
|
|
1323
|
+
isError: true;
|
|
1324
|
+
isPending: false;
|
|
1325
|
+
isLoading: false;
|
|
1326
|
+
isLoadingError: true;
|
|
1327
|
+
isRefetchError: false;
|
|
1328
|
+
isSuccess: false;
|
|
1329
|
+
isPlaceholderData: false;
|
|
1330
|
+
status: "error";
|
|
1331
|
+
dataUpdatedAt: number;
|
|
1332
|
+
errorUpdatedAt: number;
|
|
1333
|
+
failureCount: number;
|
|
1334
|
+
failureReason: Error | null;
|
|
1335
|
+
errorUpdateCount: number;
|
|
1336
|
+
isFetched: boolean;
|
|
1337
|
+
isFetchedAfterMount: boolean;
|
|
1338
|
+
isFetching: boolean;
|
|
1339
|
+
isInitialLoading: boolean;
|
|
1340
|
+
isPaused: boolean;
|
|
1341
|
+
isRefetching: boolean;
|
|
1342
|
+
isStale: boolean;
|
|
1343
|
+
isEnabled: boolean;
|
|
1344
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1345
|
+
has_all?: boolean;
|
|
1346
|
+
}, Error>>;
|
|
1347
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1348
|
+
promise: Promise<Record<string, boolean> & {
|
|
1349
|
+
has_all?: boolean;
|
|
1350
|
+
}>;
|
|
1351
|
+
} | {
|
|
1352
|
+
data: boolean | Record<string, boolean>;
|
|
1353
|
+
error: null;
|
|
1354
|
+
isError: false;
|
|
1355
|
+
isPending: true;
|
|
1356
|
+
isLoading: true;
|
|
1357
|
+
isLoadingError: false;
|
|
1358
|
+
isRefetchError: false;
|
|
1359
|
+
isSuccess: false;
|
|
1360
|
+
isPlaceholderData: false;
|
|
1361
|
+
status: "pending";
|
|
1362
|
+
dataUpdatedAt: number;
|
|
1363
|
+
errorUpdatedAt: number;
|
|
1364
|
+
failureCount: number;
|
|
1365
|
+
failureReason: Error | null;
|
|
1366
|
+
errorUpdateCount: number;
|
|
1367
|
+
isFetched: boolean;
|
|
1368
|
+
isFetchedAfterMount: boolean;
|
|
1369
|
+
isFetching: boolean;
|
|
1370
|
+
isInitialLoading: boolean;
|
|
1371
|
+
isPaused: boolean;
|
|
1372
|
+
isRefetching: boolean;
|
|
1373
|
+
isStale: boolean;
|
|
1374
|
+
isEnabled: boolean;
|
|
1375
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1376
|
+
has_all?: boolean;
|
|
1377
|
+
}, Error>>;
|
|
1378
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1379
|
+
promise: Promise<Record<string, boolean> & {
|
|
1380
|
+
has_all?: boolean;
|
|
1381
|
+
}>;
|
|
1382
|
+
} | {
|
|
1383
|
+
data: boolean | Record<string, boolean>;
|
|
1384
|
+
error: null;
|
|
1385
|
+
isError: false;
|
|
1386
|
+
isPending: true;
|
|
1387
|
+
isLoadingError: false;
|
|
1388
|
+
isRefetchError: false;
|
|
1389
|
+
isSuccess: false;
|
|
1390
|
+
isPlaceholderData: false;
|
|
1391
|
+
status: "pending";
|
|
1392
|
+
dataUpdatedAt: number;
|
|
1393
|
+
errorUpdatedAt: number;
|
|
1394
|
+
failureCount: number;
|
|
1395
|
+
failureReason: Error | null;
|
|
1396
|
+
errorUpdateCount: number;
|
|
1397
|
+
isFetched: boolean;
|
|
1398
|
+
isFetchedAfterMount: boolean;
|
|
1399
|
+
isFetching: boolean;
|
|
1400
|
+
isLoading: boolean;
|
|
1401
|
+
isInitialLoading: boolean;
|
|
1402
|
+
isPaused: boolean;
|
|
1403
|
+
isRefetching: boolean;
|
|
1404
|
+
isStale: boolean;
|
|
1405
|
+
isEnabled: boolean;
|
|
1406
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1407
|
+
has_all?: boolean;
|
|
1408
|
+
}, Error>>;
|
|
1409
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1410
|
+
promise: Promise<Record<string, boolean> & {
|
|
1411
|
+
has_all?: boolean;
|
|
1412
|
+
}>;
|
|
1413
|
+
} | {
|
|
1414
|
+
data: boolean | Record<string, boolean>;
|
|
1415
|
+
isError: false;
|
|
1416
|
+
error: null;
|
|
1417
|
+
isPending: false;
|
|
1418
|
+
isLoading: false;
|
|
1419
|
+
isLoadingError: false;
|
|
1420
|
+
isRefetchError: false;
|
|
1421
|
+
isSuccess: true;
|
|
1422
|
+
isPlaceholderData: true;
|
|
1423
|
+
status: "success";
|
|
1424
|
+
dataUpdatedAt: number;
|
|
1425
|
+
errorUpdatedAt: number;
|
|
1426
|
+
failureCount: number;
|
|
1427
|
+
failureReason: Error | null;
|
|
1428
|
+
errorUpdateCount: number;
|
|
1429
|
+
isFetched: boolean;
|
|
1430
|
+
isFetchedAfterMount: boolean;
|
|
1431
|
+
isFetching: boolean;
|
|
1432
|
+
isInitialLoading: boolean;
|
|
1433
|
+
isPaused: boolean;
|
|
1434
|
+
isRefetching: boolean;
|
|
1435
|
+
isStale: boolean;
|
|
1436
|
+
isEnabled: boolean;
|
|
1437
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, boolean> & {
|
|
1438
|
+
has_all?: boolean;
|
|
1439
|
+
}, Error>>;
|
|
1440
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1441
|
+
promise: Promise<Record<string, boolean> & {
|
|
1442
|
+
has_all?: boolean;
|
|
1443
|
+
}>;
|
|
1444
|
+
};
|
|
1445
|
+
declare function useMenuList(): _tanstack_react_query.UseQueryResult<MenuListItem[], Error>;
|
|
1446
|
+
declare const useGames: () => _tanstack_react_query.UseQueryResult<Game[], Error>;
|
|
1447
|
+
|
|
1448
|
+
export { APP_ID_HEADER, AuthButton, type AuthButtonProps, AuthMode, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, type GameSelectConfig, type GameSelectProps, type HeaderExtra, type HeaderExtraConfig, Highlight, type HighlightProps, InfiniteList, type InfiniteListDataAdapter, type InfiniteListPayload, type InfiniteListProps, type InfiniteListRef, type InfiniteListRequestConfig, type InfiniteListRequestConfigType, type JsonResponse, KeepAlive, type KeepAliveCacheItem, KeepAliveOutlet, type KeepAliveOutletProps, type KeepAliveProps, KeepAliveProvider, type KeepAliveProviderProps, Layout, type LayoutProps, Logo, type LogoProps, type MenuListItem, type NavItem, type NavMenuItemGroupType, type NavMenuItemType, type NavSubMenuType, type NavigationConfig, NotFound, OperationLogList, type PageParam, type Permission, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, type RecursivePartial, RequireAuth, type RequireAuthProps, RequireGame, type RouteMatchRule, SSO_URL, SelectAll, type SelectAllProps, type ShowFormOptions$1 as ShowFormDrawerOptions, type ShowFormOptions as ShowFormModalOptions, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseDrawerOperation, type UseDrawerProps, type UseFormDrawerProps, type UseFormDrawerReturn, type UseFormModalProps, type UseFormModalReturn, type UseKeepAliveReturn, type UseModalOperation, type UseModalProps, UserDropdown, type VisibilityState, WILDCARD, createVisibilityStoreConfig, generateId, _default$1 as menuRoutes, mixedStorage, _default as permissionRoutes, useAuth, useDrawer, useDrawerStore, useFormDrawer, useFormModal, useGames, useInfiniteListStore, useKeepAlive, useKeepAliveContext, useMenuList, useModal, useModalStore, useQueryListStore, useToolkitsStore };
|