@robot-admin/request-core 0.2.0 → 0.4.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/LICENSE +21 -0
  3. package/README.md +248 -357
  4. package/SECURITY.md +14 -0
  5. package/dist/axios.cjs +134 -809
  6. package/dist/axios.cjs.map +1 -1
  7. package/dist/axios.d.cts +55 -220
  8. package/dist/axios.d.ts +55 -220
  9. package/dist/axios.js +2 -790
  10. package/dist/axios.js.map +1 -1
  11. package/dist/chunk-2JXH7SIL.js +711 -0
  12. package/dist/chunk-2JXH7SIL.js.map +1 -0
  13. package/dist/chunk-56QOEWUS.js +8 -0
  14. package/dist/chunk-56QOEWUS.js.map +1 -0
  15. package/dist/chunk-DUP3Y4DN.js +320 -0
  16. package/dist/chunk-DUP3Y4DN.js.map +1 -0
  17. package/dist/chunk-JGFRUAZT.cjs +1007 -0
  18. package/dist/chunk-JGFRUAZT.cjs.map +1 -0
  19. package/dist/chunk-KHI6XQRN.cjs +717 -0
  20. package/dist/chunk-KHI6XQRN.cjs.map +1 -0
  21. package/dist/chunk-OAZ5BUBU.js +969 -0
  22. package/dist/chunk-OAZ5BUBU.js.map +1 -0
  23. package/dist/chunk-QSDNDTOZ.js +28 -0
  24. package/dist/chunk-QSDNDTOZ.js.map +1 -0
  25. package/dist/chunk-UHXBAFY6.cjs +323 -0
  26. package/dist/chunk-UHXBAFY6.cjs.map +1 -0
  27. package/dist/chunk-WUZ43MLM.cjs +30 -0
  28. package/dist/chunk-WUZ43MLM.cjs.map +1 -0
  29. package/dist/chunk-WXHQXPS4.cjs +10 -0
  30. package/dist/chunk-WXHQXPS4.cjs.map +1 -0
  31. package/dist/crud.cjs +12 -484
  32. package/dist/crud.cjs.map +1 -1
  33. package/dist/crud.d.cts +8 -269
  34. package/dist/crud.d.ts +8 -269
  35. package/dist/crud.js +4 -487
  36. package/dist/crud.js.map +1 -1
  37. package/dist/index.cjs +136 -1302
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +7 -165
  40. package/dist/index.d.ts +7 -165
  41. package/dist/index.js +5 -1283
  42. package/dist/index.js.map +1 -1
  43. package/dist/naive.cjs +14 -0
  44. package/dist/naive.cjs.map +1 -0
  45. package/dist/naive.d.cts +9 -0
  46. package/dist/naive.d.ts +9 -0
  47. package/dist/naive.js +5 -0
  48. package/dist/naive.js.map +1 -0
  49. package/dist/types-BRDRqYFs.d.cts +197 -0
  50. package/dist/types-BVJhlSuh.d.cts +310 -0
  51. package/dist/types-BVJhlSuh.d.ts +310 -0
  52. package/dist/types-CUyibJZX.d.ts +197 -0
  53. package/dist/vue.cjs +93 -0
  54. package/dist/vue.cjs.map +1 -0
  55. package/dist/vue.d.cts +38 -0
  56. package/dist/vue.d.ts +38 -0
  57. package/dist/vue.js +71 -0
  58. package/dist/vue.js.map +1 -0
  59. package/package.json +60 -16
package/dist/crud.d.cts CHANGED
@@ -1,271 +1,10 @@
1
- import { Ref, ComputedRef } from 'vue';
1
+ import { useNaiveTableCrud } from './naive.cjs';
2
+ export { A as ActionContext, a as ApiEndpoints, C as CustomAction, D as DataRecord, b as DetailConfig, c as DetailItem, d as DetailModal, e as DetailSection, T as TableColumn, U as UseTableCrudConfig, f as UseTableCrudReturn } from './types-BRDRqYFs.cjs';
3
+ import 'vue';
4
+ import './types-BVJhlSuh.cjs';
5
+ import 'axios';
2
6
 
3
- /**
4
- * 数据记录基础类型
5
- */
6
- interface DataRecord {
7
- [key: string]: any;
8
- }
9
- /**
10
- * 表格列配置(兼容 Naive UI DataTable)
11
- */
12
- interface TableColumn<T = any> {
13
- /** 列标题 */
14
- title?: string;
15
- /** 数据字段 key */
16
- key?: string;
17
- /** 渲染函数 */
18
- render?: (row: T, index: number) => any;
19
- /** 列宽度 */
20
- width?: number | string;
21
- /** 最小宽度 */
22
- minWidth?: number | string;
23
- /** 最大宽度 */
24
- maxWidth?: number | string;
25
- /** 固定列 */
26
- fixed?: "left" | "right";
27
- /** 对齐方式 */
28
- align?: "left" | "center" | "right";
29
- /** 省略 */
30
- ellipsis?: boolean | object;
31
- /** 排序 */
32
- sorter?: boolean | ((a: T, b: T) => number) | string;
33
- /** 过滤 */
34
- filter?: boolean | ((value: string, row: T) => boolean);
35
- /** 其他属性 */
36
- [key: string]: any;
37
- }
38
- /**
39
- * API 端点配置
40
- */
41
- interface ApiEndpoints {
42
- /** 列表查询接口 */
43
- list: string;
44
- /** 详情查询接口 */
45
- get?: string;
46
- /** 新增接口 */
47
- create?: string;
48
- /** 更新接口 */
49
- update?: string;
50
- /** 删除接口 */
51
- remove?: string;
52
- /** 批量删除接口 */
53
- batchRemove?: string;
54
- }
55
- /**
56
- * 操作上下文(传递给自定义操作处理函数)
57
- */
58
- interface ActionContext<T> {
59
- /** 表格数据数组 */
60
- data: T[];
61
- /** 当前行索引 */
62
- index: number;
63
- /** 分页信息 */
64
- page: {
65
- current: number;
66
- size: number;
67
- };
68
- /** 分页是否启用 */
69
- paginationEnabled: boolean;
70
- /** 消息通知实例 */
71
- message: any;
72
- /** 对话框实例 */
73
- dialog: any;
74
- /** 刷新数据 */
75
- refresh: () => Promise<void>;
76
- }
77
- /**
78
- * 自定义操作按钮配置
79
- */
80
- interface CustomAction<T> {
81
- /** 操作唯一标识 */
82
- key: string;
83
- /** 按钮文本 */
84
- label: string;
85
- /** 图标名称 */
86
- icon: string;
87
- /** 按钮类型 */
88
- type?: "default" | "primary" | "info" | "success" | "warning" | "error";
89
- /** 操作处理函数 */
90
- handler: (row: T, context: ActionContext<T>) => void | Promise<void>;
91
- }
92
- /**
93
- * 详情项配置
94
- */
95
- interface DetailItem {
96
- /** 字段标签 */
97
- label: string;
98
- /** 数据字段名 */
99
- key: string;
100
- /** 显示类型 */
101
- type?: string;
102
- /** 占据列数 */
103
- span?: number;
104
- /** 值格式化函数 */
105
- formatter?: (val: any) => string;
106
- /** 标签类型 */
107
- tagType?: string;
108
- [key: string]: any;
109
- }
110
- /**
111
- * 详情分组配置
112
- */
113
- interface DetailSection {
114
- /** 分组标题 */
115
- title: string;
116
- /** 列数 */
117
- columns: number;
118
- /** 字段列表 */
119
- items: DetailItem[];
120
- }
121
- /**
122
- * 详情配置
123
- */
124
- interface DetailConfig {
125
- /** 详情分组 */
126
- sections: DetailSection[];
127
- }
128
- /**
129
- * useTableCrud 配置选项
130
- */
131
- interface UseTableCrudConfig<T extends DataRecord> {
132
- /** API 端点配置 */
133
- api: ApiEndpoints;
134
- /** 表格列配置 */
135
- columns: TableColumn<T>[];
136
- /** 自定义操作按钮 */
137
- customActions?: CustomAction<T>[];
138
- /** 详情弹窗配置 */
139
- detail?: DetailConfig;
140
- /** ID 字段名,默认 'id' */
141
- idKey?: keyof T;
142
- /** 默认分页大小,默认 10 */
143
- defaultPageSize?: number;
144
- /** 是否默认启用分页,默认 true */
145
- defaultPaginationEnabled?: boolean;
146
- /** 创建新行的工厂函数 */
147
- createNewRow?: () => T;
148
- /** 列表数据提取函数(处理不同响应格式) */
149
- extractListData?: (response: any) => {
150
- items: T[];
151
- total: number;
152
- };
153
- /** 是否自动加载数据,默认 true */
154
- autoLoad?: boolean;
155
- }
156
- /**
157
- * 详情弹窗状态
158
- */
159
- interface DetailModal<T> {
160
- /** 弹窗可见性 */
161
- visible: Ref<boolean>;
162
- /** 详情数据 */
163
- data: Ref<T | null>;
164
- /** 弹窗标题 */
165
- title: Ref<string>;
166
- /** 显示详情 */
167
- show: (row: T) => void;
168
- /** 关闭详情 */
169
- close: () => void;
170
- }
171
- /**
172
- * useTableCrud 返回类型
173
- */
174
- interface UseTableCrudReturn<T extends DataRecord> {
175
- /** 表格数据 */
176
- data: Ref<T[]>;
177
- /** 加载状态 */
178
- loading: Ref<boolean>;
179
- /** 数据总数 */
180
- total: Ref<number>;
181
- /** 表格列配置 */
182
- columns: ComputedRef<TableColumn<T>[]>;
183
- /** 操作按钮配置 */
184
- actions: ComputedRef<any>;
185
- /** 表格引用 */
186
- tableRef: Ref<any>;
187
- /** 分页状态 */
188
- page: {
189
- current: number;
190
- size: number;
191
- };
192
- /** 分页启用状态 */
193
- paginationEnabled: Ref<boolean>;
194
- /** 分页配置(供组件使用) */
195
- pagination: ComputedRef<false | {
196
- enabled: boolean;
197
- page: number;
198
- pageSize: number;
199
- }>;
200
- /** 刷新数据 */
201
- refresh: () => Promise<void>;
202
- /** 新增数据 */
203
- create: (row: T) => Promise<void>;
204
- /** 更新数据 */
205
- save: (row: T) => Promise<void>;
206
- /** 删除数据 */
207
- remove: (row: T) => Promise<void>;
208
- /** 批量删除数据 */
209
- batchRemove: (rows: T[]) => Promise<void>;
210
- /** 获取详情 */
211
- getDetail: (row: T) => Promise<T | null>;
212
- /** 处理取消编辑 */
213
- handleCancel: () => Promise<void>;
214
- /** 处理分页变化 */
215
- handlePaginationChange: (pageNum: number, pageSize: number) => void;
216
- /** 处理行删除(UI层) */
217
- handleRowDelete: (row: T, index: number) => void;
218
- /** 详情弹窗状态 */
219
- detail: DetailModal<T>;
220
- /** 详情配置 */
221
- detailConfig?: DetailConfig;
222
- }
7
+ /** @deprecated Prefer useTableCrud from /vue or useNaiveTableCrud from /naive. */
8
+ declare const useTableCrud: typeof useNaiveTableCrud;
223
9
 
224
- /**
225
- * 表格 CRUD 组合式 API
226
- *
227
- * @description
228
- * 配置驱动的表格 CRUD 解决方案,极简使用,功能完整
229
- * 完全替代 usePageCrud,专注于表格场景
230
- *
231
- * @template T 数据行类型
232
- * @param config 配置对象
233
- * @returns 表格 CRUD 实例
234
- *
235
- * @example
236
- * ```ts
237
- * const table = useTableCrud<Employee>({
238
- * api: {
239
- * list: '/employees/list',
240
- * get: '/employees/:id',
241
- * update: '/employees/:id',
242
- * remove: '/employees/:id',
243
- * create: '/employees'
244
- * },
245
- * columns: [...],
246
- * customActions: [
247
- * {
248
- * key: 'copy',
249
- * label: '复制',
250
- * icon: 'mdi:content-copy',
251
- * handler: (row, ctx) => {
252
- * const newRow = { ...row, id: Date.now() }
253
- * ctx.data.unshift(newRow)
254
- * ctx.message.success('复制成功')
255
- * }
256
- * }
257
- * ]
258
- * })
259
- *
260
- * // 组件中使用
261
- * <c-table
262
- * v-model:data="table.data.value"
263
- * :columns="table.columns.value"
264
- * :actions="table.actions.value"
265
- * @save="table.save"
266
- * />
267
- * ```
268
- */
269
- declare function useTableCrud<T extends DataRecord>(config: UseTableCrudConfig<T>): UseTableCrudReturn<T>;
270
-
271
- export { type ActionContext, type ApiEndpoints, type CustomAction, type DataRecord, type DetailConfig, type DetailItem, type DetailModal, type DetailSection, type TableColumn, type UseTableCrudConfig, type UseTableCrudReturn, useTableCrud };
10
+ export { useNaiveTableCrud, useTableCrud };
package/dist/crud.d.ts CHANGED
@@ -1,271 +1,10 @@
1
- import { Ref, ComputedRef } from 'vue';
1
+ import { useNaiveTableCrud } from './naive.js';
2
+ export { A as ActionContext, a as ApiEndpoints, C as CustomAction, D as DataRecord, b as DetailConfig, c as DetailItem, d as DetailModal, e as DetailSection, T as TableColumn, U as UseTableCrudConfig, f as UseTableCrudReturn } from './types-CUyibJZX.js';
3
+ import 'vue';
4
+ import './types-BVJhlSuh.js';
5
+ import 'axios';
2
6
 
3
- /**
4
- * 数据记录基础类型
5
- */
6
- interface DataRecord {
7
- [key: string]: any;
8
- }
9
- /**
10
- * 表格列配置(兼容 Naive UI DataTable)
11
- */
12
- interface TableColumn<T = any> {
13
- /** 列标题 */
14
- title?: string;
15
- /** 数据字段 key */
16
- key?: string;
17
- /** 渲染函数 */
18
- render?: (row: T, index: number) => any;
19
- /** 列宽度 */
20
- width?: number | string;
21
- /** 最小宽度 */
22
- minWidth?: number | string;
23
- /** 最大宽度 */
24
- maxWidth?: number | string;
25
- /** 固定列 */
26
- fixed?: "left" | "right";
27
- /** 对齐方式 */
28
- align?: "left" | "center" | "right";
29
- /** 省略 */
30
- ellipsis?: boolean | object;
31
- /** 排序 */
32
- sorter?: boolean | ((a: T, b: T) => number) | string;
33
- /** 过滤 */
34
- filter?: boolean | ((value: string, row: T) => boolean);
35
- /** 其他属性 */
36
- [key: string]: any;
37
- }
38
- /**
39
- * API 端点配置
40
- */
41
- interface ApiEndpoints {
42
- /** 列表查询接口 */
43
- list: string;
44
- /** 详情查询接口 */
45
- get?: string;
46
- /** 新增接口 */
47
- create?: string;
48
- /** 更新接口 */
49
- update?: string;
50
- /** 删除接口 */
51
- remove?: string;
52
- /** 批量删除接口 */
53
- batchRemove?: string;
54
- }
55
- /**
56
- * 操作上下文(传递给自定义操作处理函数)
57
- */
58
- interface ActionContext<T> {
59
- /** 表格数据数组 */
60
- data: T[];
61
- /** 当前行索引 */
62
- index: number;
63
- /** 分页信息 */
64
- page: {
65
- current: number;
66
- size: number;
67
- };
68
- /** 分页是否启用 */
69
- paginationEnabled: boolean;
70
- /** 消息通知实例 */
71
- message: any;
72
- /** 对话框实例 */
73
- dialog: any;
74
- /** 刷新数据 */
75
- refresh: () => Promise<void>;
76
- }
77
- /**
78
- * 自定义操作按钮配置
79
- */
80
- interface CustomAction<T> {
81
- /** 操作唯一标识 */
82
- key: string;
83
- /** 按钮文本 */
84
- label: string;
85
- /** 图标名称 */
86
- icon: string;
87
- /** 按钮类型 */
88
- type?: "default" | "primary" | "info" | "success" | "warning" | "error";
89
- /** 操作处理函数 */
90
- handler: (row: T, context: ActionContext<T>) => void | Promise<void>;
91
- }
92
- /**
93
- * 详情项配置
94
- */
95
- interface DetailItem {
96
- /** 字段标签 */
97
- label: string;
98
- /** 数据字段名 */
99
- key: string;
100
- /** 显示类型 */
101
- type?: string;
102
- /** 占据列数 */
103
- span?: number;
104
- /** 值格式化函数 */
105
- formatter?: (val: any) => string;
106
- /** 标签类型 */
107
- tagType?: string;
108
- [key: string]: any;
109
- }
110
- /**
111
- * 详情分组配置
112
- */
113
- interface DetailSection {
114
- /** 分组标题 */
115
- title: string;
116
- /** 列数 */
117
- columns: number;
118
- /** 字段列表 */
119
- items: DetailItem[];
120
- }
121
- /**
122
- * 详情配置
123
- */
124
- interface DetailConfig {
125
- /** 详情分组 */
126
- sections: DetailSection[];
127
- }
128
- /**
129
- * useTableCrud 配置选项
130
- */
131
- interface UseTableCrudConfig<T extends DataRecord> {
132
- /** API 端点配置 */
133
- api: ApiEndpoints;
134
- /** 表格列配置 */
135
- columns: TableColumn<T>[];
136
- /** 自定义操作按钮 */
137
- customActions?: CustomAction<T>[];
138
- /** 详情弹窗配置 */
139
- detail?: DetailConfig;
140
- /** ID 字段名,默认 'id' */
141
- idKey?: keyof T;
142
- /** 默认分页大小,默认 10 */
143
- defaultPageSize?: number;
144
- /** 是否默认启用分页,默认 true */
145
- defaultPaginationEnabled?: boolean;
146
- /** 创建新行的工厂函数 */
147
- createNewRow?: () => T;
148
- /** 列表数据提取函数(处理不同响应格式) */
149
- extractListData?: (response: any) => {
150
- items: T[];
151
- total: number;
152
- };
153
- /** 是否自动加载数据,默认 true */
154
- autoLoad?: boolean;
155
- }
156
- /**
157
- * 详情弹窗状态
158
- */
159
- interface DetailModal<T> {
160
- /** 弹窗可见性 */
161
- visible: Ref<boolean>;
162
- /** 详情数据 */
163
- data: Ref<T | null>;
164
- /** 弹窗标题 */
165
- title: Ref<string>;
166
- /** 显示详情 */
167
- show: (row: T) => void;
168
- /** 关闭详情 */
169
- close: () => void;
170
- }
171
- /**
172
- * useTableCrud 返回类型
173
- */
174
- interface UseTableCrudReturn<T extends DataRecord> {
175
- /** 表格数据 */
176
- data: Ref<T[]>;
177
- /** 加载状态 */
178
- loading: Ref<boolean>;
179
- /** 数据总数 */
180
- total: Ref<number>;
181
- /** 表格列配置 */
182
- columns: ComputedRef<TableColumn<T>[]>;
183
- /** 操作按钮配置 */
184
- actions: ComputedRef<any>;
185
- /** 表格引用 */
186
- tableRef: Ref<any>;
187
- /** 分页状态 */
188
- page: {
189
- current: number;
190
- size: number;
191
- };
192
- /** 分页启用状态 */
193
- paginationEnabled: Ref<boolean>;
194
- /** 分页配置(供组件使用) */
195
- pagination: ComputedRef<false | {
196
- enabled: boolean;
197
- page: number;
198
- pageSize: number;
199
- }>;
200
- /** 刷新数据 */
201
- refresh: () => Promise<void>;
202
- /** 新增数据 */
203
- create: (row: T) => Promise<void>;
204
- /** 更新数据 */
205
- save: (row: T) => Promise<void>;
206
- /** 删除数据 */
207
- remove: (row: T) => Promise<void>;
208
- /** 批量删除数据 */
209
- batchRemove: (rows: T[]) => Promise<void>;
210
- /** 获取详情 */
211
- getDetail: (row: T) => Promise<T | null>;
212
- /** 处理取消编辑 */
213
- handleCancel: () => Promise<void>;
214
- /** 处理分页变化 */
215
- handlePaginationChange: (pageNum: number, pageSize: number) => void;
216
- /** 处理行删除(UI层) */
217
- handleRowDelete: (row: T, index: number) => void;
218
- /** 详情弹窗状态 */
219
- detail: DetailModal<T>;
220
- /** 详情配置 */
221
- detailConfig?: DetailConfig;
222
- }
7
+ /** @deprecated Prefer useTableCrud from /vue or useNaiveTableCrud from /naive. */
8
+ declare const useTableCrud: typeof useNaiveTableCrud;
223
9
 
224
- /**
225
- * 表格 CRUD 组合式 API
226
- *
227
- * @description
228
- * 配置驱动的表格 CRUD 解决方案,极简使用,功能完整
229
- * 完全替代 usePageCrud,专注于表格场景
230
- *
231
- * @template T 数据行类型
232
- * @param config 配置对象
233
- * @returns 表格 CRUD 实例
234
- *
235
- * @example
236
- * ```ts
237
- * const table = useTableCrud<Employee>({
238
- * api: {
239
- * list: '/employees/list',
240
- * get: '/employees/:id',
241
- * update: '/employees/:id',
242
- * remove: '/employees/:id',
243
- * create: '/employees'
244
- * },
245
- * columns: [...],
246
- * customActions: [
247
- * {
248
- * key: 'copy',
249
- * label: '复制',
250
- * icon: 'mdi:content-copy',
251
- * handler: (row, ctx) => {
252
- * const newRow = { ...row, id: Date.now() }
253
- * ctx.data.unshift(newRow)
254
- * ctx.message.success('复制成功')
255
- * }
256
- * }
257
- * ]
258
- * })
259
- *
260
- * // 组件中使用
261
- * <c-table
262
- * v-model:data="table.data.value"
263
- * :columns="table.columns.value"
264
- * :actions="table.actions.value"
265
- * @save="table.save"
266
- * />
267
- * ```
268
- */
269
- declare function useTableCrud<T extends DataRecord>(config: UseTableCrudConfig<T>): UseTableCrudReturn<T>;
270
-
271
- export { type ActionContext, type ApiEndpoints, type CustomAction, type DataRecord, type DetailConfig, type DetailItem, type DetailModal, type DetailSection, type TableColumn, type UseTableCrudConfig, type UseTableCrudReturn, useTableCrud };
10
+ export { useNaiveTableCrud, useTableCrud };