react-toolkits 2.30.3 → 2.31.0
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 +11 -0
- package/README.md +3 -3
- package/lib/index.css +1 -1025
- package/lib/index.d.ts +206 -190
- package/lib/index.js +3 -12799
- package/lib/index.js.map +1 -1
- package/locale/context.js +2 -1473
- package/locale/hooks.js +13 -54852
- package/locale/index.js +13 -54852
- package/package.json +6 -5
- package/lib/index.css.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ButtonProps, SelectProps, FormInstance, DrawerProps, Button, FormProps, ModalProps } from 'antd';
|
|
2
|
-
import { Options, KyInstance } from 'ky';
|
|
3
2
|
import { FC, PropsWithChildren, Key, ReactNode, ReactElement, Ref, DetailedHTMLProps, ImgHTMLAttributes, ComponentProps } from 'react';
|
|
3
|
+
import { Options, KyInstance } from 'ky';
|
|
4
4
|
import { ParagraphProps } from 'antd/es/typography/Paragraph';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import { useLocation } from 'react-router
|
|
6
|
+
import { useLocation, PathPattern } from 'react-router';
|
|
7
7
|
import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
|
|
8
8
|
import { AnyObject } from 'antd/es/_util/type';
|
|
9
9
|
import { TableProps } from 'antd/es/table';
|
|
@@ -12,13 +12,160 @@ import { StateCreator } from 'zustand';
|
|
|
12
12
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
13
13
|
import { StateStorage } from 'zustand/middleware';
|
|
14
14
|
|
|
15
|
+
/** 成功响应状态码字段类型 */
|
|
16
|
+
type StatusField = 'code' | 'status' | 'errno';
|
|
17
|
+
/** 响应类型 */
|
|
18
|
+
type ResponseType = 'json' | 'blob' | 'text' | 'arrayBuffer' | 'formData';
|
|
19
|
+
/** 通用请求选项接口 */
|
|
20
|
+
interface RequestOptions extends Options {
|
|
21
|
+
responseType?: ResponseType;
|
|
22
|
+
/** 是否使用全局模式(覆盖 context 中的 isGlobalMode) */
|
|
23
|
+
isGlobalMode?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** 业务状态码字段配置 */
|
|
26
|
+
interface BusinessStatusCodeConfig {
|
|
27
|
+
/** 成功状态码列表,默认为 [0, 1, 200] */
|
|
28
|
+
successCodes?: readonly number[];
|
|
29
|
+
/** 需要检查的业务状态码字段,默认为 ['code', 'status', 'errno'] */
|
|
30
|
+
statusFields?: readonly StatusField[];
|
|
31
|
+
}
|
|
32
|
+
/** 错误消息提取配置 */
|
|
33
|
+
interface ErrorMessageConfig {
|
|
34
|
+
/** 错误消息字段列表(按优先级),默认为 ['msg', 'message', 'error'] */
|
|
35
|
+
errorFields?: readonly string[];
|
|
36
|
+
/** 自定义错误消息提取函数,优先级高于 errorFields */
|
|
37
|
+
extractErrorMessage?: (data: unknown) => string;
|
|
38
|
+
}
|
|
39
|
+
/** HTTP 状态码错误处理回调 */
|
|
40
|
+
interface HttpErrorHandlers {
|
|
41
|
+
/** 401 未授权处理 */
|
|
42
|
+
onUnauthorized?: (data?: unknown) => void;
|
|
43
|
+
/** 403 禁止访问处理 */
|
|
44
|
+
onForbidden?: (data?: unknown) => void;
|
|
45
|
+
/** 412 未注册处理 */
|
|
46
|
+
onUnregistered?: (data?: unknown) => void;
|
|
47
|
+
/** 其他 HTTP 错误处理 */
|
|
48
|
+
onError?: (status: number, data?: unknown, errorMessage?: string) => void;
|
|
49
|
+
/** 网络错误处理 */
|
|
50
|
+
onNetworkError?: (error: Error) => void;
|
|
51
|
+
}
|
|
52
|
+
/** 响应验证配置 */
|
|
53
|
+
interface ResponseValidationConfig {
|
|
54
|
+
/** 自定义响应成功判断函数,优先级高于业务状态码配置 */
|
|
55
|
+
isSuccess?: (data: unknown, status: number) => boolean;
|
|
56
|
+
}
|
|
57
|
+
/** React 上下文信息接口 */
|
|
58
|
+
interface KyClientContext {
|
|
59
|
+
token?: string;
|
|
60
|
+
isGlobalMode?: boolean;
|
|
61
|
+
loginPath?: string;
|
|
62
|
+
apiBaseUrl?: string;
|
|
63
|
+
appId?: string | number;
|
|
64
|
+
clear?: () => void;
|
|
65
|
+
notifyError?: (title: string, description: string) => void;
|
|
66
|
+
}
|
|
67
|
+
/** KyClient 构造函数配置 */
|
|
68
|
+
interface KyClientOptions extends BusinessStatusCodeConfig, ErrorMessageConfig, HttpErrorHandlers, ResponseValidationConfig {
|
|
69
|
+
/** 基础 URL */
|
|
70
|
+
baseURL?: string;
|
|
71
|
+
/** 是否禁用默认的错误提示(notification),默认为 false */
|
|
72
|
+
disableDefaultErrorNotification?: boolean;
|
|
73
|
+
/** React 上下文信息 */
|
|
74
|
+
context?: KyClientContext;
|
|
75
|
+
}
|
|
76
|
+
/** HTTP客户端方法接口 */
|
|
77
|
+
interface KyMethods {
|
|
78
|
+
get: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
79
|
+
post: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
80
|
+
put: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
81
|
+
delete: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
82
|
+
patch: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
83
|
+
options: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
84
|
+
head: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
85
|
+
request: <T = unknown>(options: RequestOptions & {
|
|
86
|
+
url: string;
|
|
87
|
+
}) => Promise<T>;
|
|
88
|
+
instance: KyInstance;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Ky HTTP 客户端类
|
|
92
|
+
* 封装了基于 ky 的 HTTP 请求逻辑,包括认证、错误处理、响应验证等
|
|
93
|
+
*/
|
|
94
|
+
declare class KyClient implements KyMethods {
|
|
95
|
+
private readonly _instance;
|
|
96
|
+
private readonly businessConfig;
|
|
97
|
+
private readonly errorConfig;
|
|
98
|
+
private readonly errorHandlers;
|
|
99
|
+
private context?;
|
|
100
|
+
private readonly disableDefaultErrorNotification;
|
|
101
|
+
constructor(options?: KyClientOptions);
|
|
102
|
+
/** 获取 ky 实例(用于高级用法) */
|
|
103
|
+
get instance(): KyInstance;
|
|
104
|
+
get: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
105
|
+
post: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
106
|
+
put: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
107
|
+
delete: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
108
|
+
patch: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
109
|
+
options: <T = unknown>(url: string, requestOptions?: RequestOptions) => Promise<T>;
|
|
110
|
+
head: <T = unknown>(url: string, requestOptions?: RequestOptions) => Promise<T>;
|
|
111
|
+
request: <T = unknown>(requestOptions: RequestOptions & {
|
|
112
|
+
url: string;
|
|
113
|
+
}) => Promise<T>;
|
|
114
|
+
/**
|
|
115
|
+
* 通用请求处理函数
|
|
116
|
+
*/
|
|
117
|
+
private makeRequest;
|
|
118
|
+
/**
|
|
119
|
+
* 创建响应处理函数
|
|
120
|
+
*/
|
|
121
|
+
private createResponseHandler;
|
|
122
|
+
/**
|
|
123
|
+
* 请求前处理:设置认证和 appId headers
|
|
124
|
+
*/
|
|
125
|
+
private handleBeforeRequest;
|
|
126
|
+
/**
|
|
127
|
+
* 错误前处理:处理 HTTP 状态码错误
|
|
128
|
+
*/
|
|
129
|
+
private handleBeforeError;
|
|
130
|
+
/**
|
|
131
|
+
* 处理 HTTP 状态码错误
|
|
132
|
+
*/
|
|
133
|
+
private handleHttpStatusError;
|
|
134
|
+
/**
|
|
135
|
+
* 默认处理未授权错误
|
|
136
|
+
*/
|
|
137
|
+
private defaultHandleUnauthorized;
|
|
138
|
+
/**
|
|
139
|
+
* 默认处理未注册错误
|
|
140
|
+
*/
|
|
141
|
+
private defaultHandleUnregistered;
|
|
142
|
+
/**
|
|
143
|
+
* 默认处理禁止访问错误
|
|
144
|
+
*/
|
|
145
|
+
private defaultHandleForbidden;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 在组件中使用 KyClient 的 Hook
|
|
149
|
+
* 创建新的 KyClient 实例,并从 ToolkitsProvider 获取 context
|
|
150
|
+
* 这样可以确保每个组件使用正确的 context(特别是 isGlobalMode)
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* import { useKyClient } from '@/libs'
|
|
154
|
+
*
|
|
155
|
+
* function MyComponent() {
|
|
156
|
+
* const { get, post } = useKyClient()
|
|
157
|
+
* // 使用 get, post 等方法
|
|
158
|
+
* }
|
|
159
|
+
*/
|
|
160
|
+
declare function useKyClient(): KyClient;
|
|
161
|
+
|
|
15
162
|
interface AuthButtonProps extends ButtonProps {
|
|
16
163
|
/** 权限码,支持单个或多个 */
|
|
17
164
|
code?: string | string[];
|
|
18
165
|
/** 加载时是否显示 loading 状态 */
|
|
19
166
|
showLoading?: boolean;
|
|
20
167
|
/** 请求配置 */
|
|
21
|
-
config?:
|
|
168
|
+
config?: RequestOptions;
|
|
22
169
|
}
|
|
23
170
|
/**
|
|
24
171
|
* 授权按钮组件
|
|
@@ -100,34 +247,12 @@ interface KeepAliveOutletProps {
|
|
|
100
247
|
disabled?: boolean;
|
|
101
248
|
/** 自定义缓存 key 前缀,用于区分不同的 KeepAliveOutlet 实例 */
|
|
102
249
|
cacheKeyPrefix?: string;
|
|
250
|
+
/** 是否启用路由切换过渡动画,默认 true */
|
|
251
|
+
enableTransition?: boolean;
|
|
252
|
+
/** 过渡动画时长(毫秒),默认 200 */
|
|
253
|
+
transitionDuration?: number;
|
|
103
254
|
}
|
|
104
|
-
|
|
105
|
-
* KeepAliveOutlet 组件
|
|
106
|
-
* 路由级别的 KeepAlive,自动缓存所有通过 Outlet 渲染的组件
|
|
107
|
-
* 使用 React 19 Activity API 实现,避免路由切换时组件被销毁
|
|
108
|
-
* 支持嵌套路由,每个层级的 outlet 都有独立的缓存
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```tsx
|
|
112
|
-
* // 单层路由
|
|
113
|
-
* <Route path="/" element={<Layout />}>
|
|
114
|
-
* <KeepAliveProvider maxCache={10}>
|
|
115
|
-
* <KeepAliveOutlet />
|
|
116
|
-
* </KeepAliveProvider>
|
|
117
|
-
* </Route>
|
|
118
|
-
*
|
|
119
|
-
* // 嵌套路由
|
|
120
|
-
* <Route path="/" element={<Layout />}>
|
|
121
|
-
* <KeepAliveProvider maxCache={10}>
|
|
122
|
-
* <KeepAliveOutlet />
|
|
123
|
-
* <Route path="list" element={<ListLayout />}>
|
|
124
|
-
* <KeepAliveOutlet /> // 嵌套的 outlet,会自动使用不同的缓存 key
|
|
125
|
-
* </Route>
|
|
126
|
-
* </KeepAliveProvider>
|
|
127
|
-
* </Route>
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
declare const KeepAliveOutlet: ({ disabled, cacheKeyPrefix }: KeepAliveOutletProps) => react_jsx_runtime.JSX.Element;
|
|
255
|
+
declare const KeepAliveOutlet: ({ disabled, cacheKeyPrefix, enableTransition, transitionDuration, }: KeepAliveOutletProps) => react_jsx_runtime.JSX.Element;
|
|
131
256
|
|
|
132
257
|
/**
|
|
133
258
|
* KeepAlive 缓存项
|
|
@@ -219,29 +344,16 @@ type Merge<Object1, Object2> = Prettify<Omit<Object1, keyof Object2> & Object2>;
|
|
|
219
344
|
|
|
220
345
|
type MarkRequired<Type, Keys extends keyof Type> = Type extends Type ? Prettify<Type & Required<Omit<Type, Exclude<keyof Type, Keys>>>> : never;
|
|
221
346
|
|
|
222
|
-
type Area = 'all' | 'cn' | 'global';
|
|
223
|
-
type ScreenOrientation = 0 | 1;
|
|
224
347
|
interface Game {
|
|
225
|
-
id: number;
|
|
226
348
|
game_id: string | number;
|
|
227
|
-
|
|
228
|
-
name: string;
|
|
229
|
-
screen_type: ScreenOrientation;
|
|
230
|
-
area: Area;
|
|
231
|
-
icon: string;
|
|
232
|
-
auth: string;
|
|
233
|
-
ctime: string;
|
|
234
|
-
mtime: string;
|
|
235
|
-
is_delete: 0 | 1;
|
|
236
|
-
is_new_game: 0 | 1;
|
|
237
|
-
server_type: string;
|
|
349
|
+
[key: string]: any;
|
|
238
350
|
}
|
|
239
351
|
/**
|
|
240
352
|
* 导航菜单项类型
|
|
241
353
|
* 扩展 antd MenuItemType,添加路由支持
|
|
242
354
|
*/
|
|
243
355
|
type NavMenuItemType = Merge<MenuItemType, {
|
|
244
|
-
/** react-router
|
|
356
|
+
/** react-router 路由地址,用于菜单项点击时跳转 */
|
|
245
357
|
route?: string;
|
|
246
358
|
}>;
|
|
247
359
|
/**
|
|
@@ -294,15 +406,19 @@ interface NavigationConfig {
|
|
|
294
406
|
/** 菜单加载状态 */
|
|
295
407
|
loading?: boolean;
|
|
296
408
|
}
|
|
297
|
-
/** 路由匹配规则类型
|
|
298
|
-
|
|
409
|
+
/** 路由匹配规则类型
|
|
410
|
+
* 支持:
|
|
411
|
+
* - PathPattern 对象(React Router 路由模式,支持 caseSensitive 和 end 选项)
|
|
412
|
+
* - 正则表达式(用于更复杂的匹配需求)
|
|
413
|
+
*/
|
|
414
|
+
type RouteMatchRule = PathPattern | RegExp;
|
|
299
415
|
/** 游戏选择器配置 */
|
|
300
416
|
interface GameSelectConfig<T extends Game = Game> {
|
|
301
417
|
/** 游戏过滤函数 */
|
|
302
418
|
filter?: GameSelectProps<T>['filter'];
|
|
303
419
|
/** 选项自定义函数 */
|
|
304
420
|
options?: GameSelectProps<T>['options'];
|
|
305
|
-
/**
|
|
421
|
+
/** 在这些路由路径下隐藏游戏选择器(支持 PathPattern 对象或正则表达式) */
|
|
306
422
|
hideOnRoutes?: RouteMatchRule[];
|
|
307
423
|
}
|
|
308
424
|
/** Layout 组件属性 */
|
|
@@ -411,6 +527,8 @@ interface InfiniteListRequestConfig<Values = any, PageParamType = PageParam> ext
|
|
|
411
527
|
searchParams?: RequestParamsResolver<Values, PageParamType>;
|
|
412
528
|
/** 请求头,可以是静态对象或动态函数 */
|
|
413
529
|
headers?: Record<string, string> | ((form: FormInstance<Values>) => Record<string, string>);
|
|
530
|
+
/** 是否为全局模式请求 */
|
|
531
|
+
isGlobalMode?: boolean;
|
|
414
532
|
}
|
|
415
533
|
/**
|
|
416
534
|
* 无限列表请求配置类型
|
|
@@ -614,6 +732,8 @@ interface QueryListRequestConfig extends CacheConfig {
|
|
|
614
732
|
body?: FormData | Record<string | number, any>;
|
|
615
733
|
searchParams?: Record<string | number, any>;
|
|
616
734
|
headers?: Record<string, string>;
|
|
735
|
+
/** 是否使用全局模式(覆盖 ToolkitsProvider 中的 isGlobalMode) */
|
|
736
|
+
isGlobalMode?: boolean;
|
|
617
737
|
}
|
|
618
738
|
/**
|
|
619
739
|
* 请求配置类型
|
|
@@ -1171,146 +1291,6 @@ declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues
|
|
|
1171
1291
|
*/
|
|
1172
1292
|
declare function useModalStore(): VisibilityState;
|
|
1173
1293
|
|
|
1174
|
-
/** 成功响应状态码字段类型 */
|
|
1175
|
-
type StatusField = 'code' | 'status' | 'errno';
|
|
1176
|
-
/** 响应类型 */
|
|
1177
|
-
type ResponseType = 'json' | 'blob' | 'text' | 'arrayBuffer' | 'formData';
|
|
1178
|
-
/** 通用请求选项接口 */
|
|
1179
|
-
interface RequestOptions extends Options {
|
|
1180
|
-
responseType?: ResponseType;
|
|
1181
|
-
}
|
|
1182
|
-
/** 业务状态码字段配置 */
|
|
1183
|
-
interface BusinessStatusCodeConfig {
|
|
1184
|
-
/** 成功状态码列表,默认为 [0, 1, 200] */
|
|
1185
|
-
successCodes?: readonly number[];
|
|
1186
|
-
/** 需要检查的业务状态码字段,默认为 ['code', 'status', 'errno'] */
|
|
1187
|
-
statusFields?: readonly StatusField[];
|
|
1188
|
-
}
|
|
1189
|
-
/** 错误消息提取配置 */
|
|
1190
|
-
interface ErrorMessageConfig {
|
|
1191
|
-
/** 错误消息字段列表(按优先级),默认为 ['msg', 'message', 'error'] */
|
|
1192
|
-
errorFields?: readonly string[];
|
|
1193
|
-
/** 自定义错误消息提取函数,优先级高于 errorFields */
|
|
1194
|
-
extractErrorMessage?: (data: unknown) => string;
|
|
1195
|
-
}
|
|
1196
|
-
/** HTTP 状态码错误处理回调 */
|
|
1197
|
-
interface HttpErrorHandlers {
|
|
1198
|
-
/** 401 未授权处理 */
|
|
1199
|
-
onUnauthorized?: (data?: unknown) => void;
|
|
1200
|
-
/** 403 禁止访问处理 */
|
|
1201
|
-
onForbidden?: (data?: unknown) => void;
|
|
1202
|
-
/** 412 未注册处理 */
|
|
1203
|
-
onUnregistered?: (data?: unknown) => void;
|
|
1204
|
-
/** 其他 HTTP 错误处理 */
|
|
1205
|
-
onError?: (status: number, data?: unknown, errorMessage?: string) => void;
|
|
1206
|
-
/** 网络错误处理 */
|
|
1207
|
-
onNetworkError?: (error: Error) => void;
|
|
1208
|
-
}
|
|
1209
|
-
/** 响应验证配置 */
|
|
1210
|
-
interface ResponseValidationConfig {
|
|
1211
|
-
/** 自定义响应成功判断函数,优先级高于业务状态码配置 */
|
|
1212
|
-
isSuccess?: (data: unknown, status: number) => boolean;
|
|
1213
|
-
}
|
|
1214
|
-
/** React 上下文信息接口 */
|
|
1215
|
-
interface KyClientContext {
|
|
1216
|
-
token?: string;
|
|
1217
|
-
isGlobalMode?: boolean;
|
|
1218
|
-
loginPath?: string;
|
|
1219
|
-
apiBaseUrl?: string;
|
|
1220
|
-
appId?: string | number;
|
|
1221
|
-
clear?: () => void;
|
|
1222
|
-
notifyError?: (title: string, description: string) => void;
|
|
1223
|
-
}
|
|
1224
|
-
/** KyClient 构造函数配置 */
|
|
1225
|
-
interface KyClientOptions extends BusinessStatusCodeConfig, ErrorMessageConfig, HttpErrorHandlers, ResponseValidationConfig {
|
|
1226
|
-
/** 基础 URL */
|
|
1227
|
-
baseURL?: string;
|
|
1228
|
-
/** 是否禁用默认的错误提示(notification),默认为 false */
|
|
1229
|
-
disableDefaultErrorNotification?: boolean;
|
|
1230
|
-
/** React 上下文信息 */
|
|
1231
|
-
context?: KyClientContext;
|
|
1232
|
-
}
|
|
1233
|
-
/** HTTP客户端方法接口 */
|
|
1234
|
-
interface KyMethods {
|
|
1235
|
-
get: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1236
|
-
post: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1237
|
-
put: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1238
|
-
delete: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1239
|
-
patch: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1240
|
-
options: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1241
|
-
head: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1242
|
-
request: <T = unknown>(options: RequestOptions & {
|
|
1243
|
-
url: string;
|
|
1244
|
-
}) => Promise<T>;
|
|
1245
|
-
instance: KyInstance;
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* Ky HTTP 客户端类
|
|
1249
|
-
* 封装了基于 ky 的 HTTP 请求逻辑,包括认证、错误处理、响应验证等
|
|
1250
|
-
*/
|
|
1251
|
-
declare class KyClient implements KyMethods {
|
|
1252
|
-
private readonly _instance;
|
|
1253
|
-
private readonly businessConfig;
|
|
1254
|
-
private readonly errorConfig;
|
|
1255
|
-
private readonly errorHandlers;
|
|
1256
|
-
private context?;
|
|
1257
|
-
private readonly disableDefaultErrorNotification;
|
|
1258
|
-
constructor(options?: KyClientOptions);
|
|
1259
|
-
/** 获取 ky 实例(用于高级用法) */
|
|
1260
|
-
get instance(): KyInstance;
|
|
1261
|
-
get: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1262
|
-
post: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1263
|
-
put: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1264
|
-
delete: <T = unknown>(url: string, options?: RequestOptions) => Promise<T>;
|
|
1265
|
-
patch: <T = unknown>(url: string, data?: unknown, options?: RequestOptions) => Promise<T>;
|
|
1266
|
-
options: <T = unknown>(url: string, requestOptions?: RequestOptions) => Promise<T>;
|
|
1267
|
-
head: <T = unknown>(url: string, requestOptions?: RequestOptions) => Promise<T>;
|
|
1268
|
-
request: <T = unknown>(requestOptions: RequestOptions & {
|
|
1269
|
-
url: string;
|
|
1270
|
-
}) => Promise<T>;
|
|
1271
|
-
/**
|
|
1272
|
-
* 通用请求处理函数
|
|
1273
|
-
*/
|
|
1274
|
-
private makeRequest;
|
|
1275
|
-
/**
|
|
1276
|
-
* 创建响应处理函数
|
|
1277
|
-
*/
|
|
1278
|
-
private createResponseHandler;
|
|
1279
|
-
/**
|
|
1280
|
-
* 请求前处理:设置认证和 appId headers
|
|
1281
|
-
*/
|
|
1282
|
-
private handleBeforeRequest;
|
|
1283
|
-
/**
|
|
1284
|
-
* 错误前处理:处理 HTTP 状态码错误
|
|
1285
|
-
*/
|
|
1286
|
-
private handleBeforeError;
|
|
1287
|
-
/**
|
|
1288
|
-
* 处理 HTTP 状态码错误
|
|
1289
|
-
*/
|
|
1290
|
-
private handleHttpStatusError;
|
|
1291
|
-
/**
|
|
1292
|
-
* 默认处理未授权错误
|
|
1293
|
-
*/
|
|
1294
|
-
private defaultHandleUnauthorized;
|
|
1295
|
-
/**
|
|
1296
|
-
* 默认处理未注册错误
|
|
1297
|
-
*/
|
|
1298
|
-
private defaultHandleUnregistered;
|
|
1299
|
-
/**
|
|
1300
|
-
* 默认处理禁止访问错误
|
|
1301
|
-
*/
|
|
1302
|
-
private defaultHandleForbidden;
|
|
1303
|
-
/**
|
|
1304
|
-
* 更新上下文信息
|
|
1305
|
-
* 用于在运行时更新 context(例如在 React 组件中从 context 获取最新信息)
|
|
1306
|
-
*/
|
|
1307
|
-
updateContext(context: KyClientContext): void;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
declare const _default$1: react_jsx_runtime.JSX.Element;
|
|
1311
|
-
|
|
1312
|
-
declare const _default: react_jsx_runtime.JSX.Element;
|
|
1313
|
-
|
|
1314
1294
|
interface NotFoundProps {
|
|
1315
1295
|
redirectUrl?: string;
|
|
1316
1296
|
}
|
|
@@ -1324,7 +1304,43 @@ interface SignInProps {
|
|
|
1324
1304
|
}
|
|
1325
1305
|
declare const SignIn: FC<SignInProps>;
|
|
1326
1306
|
|
|
1327
|
-
|
|
1307
|
+
/**
|
|
1308
|
+
* 菜单管理路由配置
|
|
1309
|
+
* 用于在 React Router 的 createRoutesFromElements 中使用
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```tsx
|
|
1313
|
+
* import { menuRoutes } from 'react-toolkits'
|
|
1314
|
+
* import { createRoutesFromElements, Outlet, Route } from 'react-router'
|
|
1315
|
+
*
|
|
1316
|
+
* createRoutesFromElements(
|
|
1317
|
+
* <Route path="menu/*">
|
|
1318
|
+
* {menuRoutes}
|
|
1319
|
+
* </Route>
|
|
1320
|
+
* )
|
|
1321
|
+
* ```
|
|
1322
|
+
*/
|
|
1323
|
+
declare const _default$1: react_jsx_runtime.JSX.Element;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* 权限管理路由配置
|
|
1327
|
+
* 用于在 React Router 的 createRoutesFromElements 中使用
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```tsx
|
|
1331
|
+
* import { permissionRoutes, PermissionRoutesWrapper } from 'react-toolkits'
|
|
1332
|
+
* import { createRoutesFromElements, Route } from 'react-router'
|
|
1333
|
+
*
|
|
1334
|
+
* createRoutesFromElements(
|
|
1335
|
+
* <Route path="permission/*" element={<PermissionRoutesWrapper />}>
|
|
1336
|
+
* {permissionRoutes}
|
|
1337
|
+
* </Route>
|
|
1338
|
+
* )
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
declare const _default: react_jsx_runtime.JSX.Element;
|
|
1342
|
+
|
|
1343
|
+
declare function useAuth(code?: string | string[], config?: RequestOptions): {
|
|
1328
1344
|
data: boolean | Record<string, boolean>;
|
|
1329
1345
|
error: Error;
|
|
1330
1346
|
isError: true;
|
|
@@ -1514,4 +1530,4 @@ declare function useAuth(code?: string | string[], config?: Options): {
|
|
|
1514
1530
|
declare function useMenuList(): _tanstack_react_query.UseQueryResult<MenuListItem[], Error>;
|
|
1515
1531
|
declare const useGames: () => _tanstack_react_query.UseQueryResult<Game[], Error>;
|
|
1516
1532
|
|
|
1517
|
-
export { APP_ID_HEADER, AuthButton, type AuthButtonProps, type BusinessStatusCodeConfig, DynamicTags, type DynamicTagsProps, type ErrorMessageConfig, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, type GameSelectConfig, type GameSelectProps, type HeaderExtra, type HeaderExtraConfig, Highlight, type HighlightProps, type HttpErrorHandlers, 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, KyClient, type KyClientContext, type KyClientOptions, Layout, type LayoutProps, Logo, type LogoProps, type MenuListItem, type NavItem, type NavMenuItemGroupType, type NavMenuItemType, type NavSubMenuType, type NavigationConfig, NotFound, OperationLogList, type PageParam, type Permission, PermissionMode, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, type RecursivePartial, RequireAuth, type RequireAuthProps, RequireGame, type ResponseType, type ResponseValidationConfig, 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
|
|
1533
|
+
export { APP_ID_HEADER, AuthButton, type AuthButtonProps, type BusinessStatusCodeConfig, DynamicTags, type DynamicTagsProps, type ErrorMessageConfig, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, type GameSelectConfig, type GameSelectProps, type HeaderExtra, type HeaderExtraConfig, Highlight, type HighlightProps, type HttpErrorHandlers, 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, KyClient, type KyClientContext, type KyClientOptions, Layout, type LayoutProps, Logo, type LogoProps, type MenuListItem, type NavItem, type NavMenuItemGroupType, type NavMenuItemType, type NavSubMenuType, type NavigationConfig, NotFound, OperationLogList, type PageParam, type Permission, PermissionMode, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, type RecursivePartial, RequireAuth, type RequireAuthProps, RequireGame, type ResponseType, type ResponseValidationConfig, 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, useKyClient, useMenuList, useModal, useModalStore, useQueryListStore, useToolkitsStore };
|