react-toolkits 2.31.1 → 2.31.3

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.31.3
4
+
5
+ ### Patch Changes
6
+
7
+ - af302b5: refactor: streamline useKy integration across renderers
8
+
9
+ ## 2.31.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 71e5a70: refactor: replace useKyClient with useKy hook across components
14
+
3
15
  ## 2.31.1
4
16
 
5
17
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -20,16 +20,6 @@ interface RequestOptions extends Options {
20
20
  /** 是否使用全局模式(覆盖 context 中的 isGlobalMode) */
21
21
  isGlobalMode?: boolean;
22
22
  }
23
- /** React 上下文信息接口 */
24
- interface KyClientContext {
25
- token?: string;
26
- isGlobalMode?: boolean;
27
- loginPath?: string;
28
- apiBaseUrl?: string;
29
- appId?: string | number;
30
- clear?: () => void;
31
- notifyError?: (title: string, description: string) => void;
32
- }
33
23
  /** KyClient 构造函数配置 */
34
24
  interface KyClientOptions {
35
25
  /** 基础 URL */
@@ -51,36 +41,11 @@ interface KyMethods {
51
41
  }) => Promise<T>;
52
42
  instance: KyInstance;
53
43
  }
54
- /** useKyClient 配置选项 */
55
- interface UseKyClientOptions {
56
- /** 状态码字段配置:字段名 -> 成功码列表 */
57
- statusFields?: Record<string, readonly number[]>;
58
- /** 自定义响应成功判断函数 */
59
- isSuccess?: (data: unknown, status: number) => boolean;
60
- /** 错误消息字段列表(按优先级) */
61
- errorFields?: readonly string[];
62
- /** 自定义错误消息提取函数 */
63
- extractErrorMessage?: (data: unknown) => string;
64
- /** 401 未授权处理 */
65
- onUnauthorized?: (data?: unknown) => void;
66
- /** 403 禁止访问处理 */
67
- onForbidden?: (data?: unknown) => void;
68
- /** 412 未注册处理 */
69
- onUnregistered?: (data?: unknown) => void;
70
- /** 其他 HTTP 错误处理 */
71
- onError?: (status: number, data?: unknown, errorMessage?: string) => void;
72
- /** 网络错误处理 */
73
- onNetworkError?: (error: Error) => void;
74
- /** 是否禁用默认的错误提示 */
75
- disableDefaultErrorNotification?: boolean;
44
+ /** useKy 配置选项 */
45
+ interface UseKyOptions {
76
46
  /** 自定义 hooks(拦截器) */
77
47
  hooks?: Partial<Hooks>;
78
48
  }
79
- /** 导出类型(向后兼容) */
80
- type BusinessStatusCodeConfig = Pick<UseKyClientOptions, 'statusFields'>;
81
- type ErrorMessageConfig = Pick<UseKyClientOptions, 'errorFields' | 'extractErrorMessage'>;
82
- type HttpErrorHandlers = Pick<UseKyClientOptions, 'onUnauthorized' | 'onForbidden' | 'onUnregistered' | 'onError' | 'onNetworkError'>;
83
- type ResponseValidationConfig = Pick<UseKyClientOptions, 'isSuccess'>;
84
49
  /**
85
50
  * Ky HTTP 客户端类
86
51
  */
@@ -100,10 +65,6 @@ declare class KyClient implements KyMethods {
100
65
  }) => Promise<T>;
101
66
  private makeRequest;
102
67
  }
103
- /**
104
- * 在组件中使用 KyClient 的 Hook
105
- */
106
- declare function useKyClient(options?: UseKyClientOptions): KyClient;
107
68
 
108
69
  interface AuthButtonProps extends ButtonProps {
109
70
  /** 权限码,支持单个或多个 */
@@ -1476,4 +1437,4 @@ declare function useAuth(code?: string | string[], config?: RequestOptions): {
1476
1437
  declare function useMenuList(): _tanstack_react_query.UseQueryResult<MenuListItem[], Error>;
1477
1438
  declare const useGames: () => _tanstack_react_query.UseQueryResult<Game[], Error>;
1478
1439
 
1479
- 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 };
1440
+ export { APP_ID_HEADER, AuthButton, type AuthButtonProps, 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, KyClient, 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, type RequestOptions, RequireAuth, type RequireAuthProps, RequireGame, type ResponseType, 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 UseKyOptions, 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 };