phinix 0.2.1 → 0.2.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/dist/index.js +0 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_action.d.ts +2 -3
- package/dist/plugins/AutoTable/tools/get_auto_table_action.d.ts.map +1 -1
- package/dist/plugins/AutoTable/tools/get_auto_table_action.js +41 -27
- package/dist/plugins/AutoTable/tools/get_auto_table_action.js.map +1 -1
- package/dist/plugins/AutoTable/tools/get_auto_table_batchAction.d.ts +4 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_batchAction.d.ts.map +1 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_batchAction.js +63 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_batchAction.js.map +1 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_column.d.ts +2 -3
- package/dist/plugins/AutoTable/tools/get_auto_table_column.d.ts.map +1 -1
- package/dist/plugins/AutoTable/tools/get_auto_table_column.js +44 -20
- package/dist/plugins/AutoTable/tools/get_auto_table_column.js.map +1 -1
- package/dist/plugins/AutoTable/tools/get_auto_table_demo.d.ts +2 -3
- package/dist/plugins/AutoTable/tools/get_auto_table_demo.d.ts.map +1 -1
- package/dist/plugins/AutoTable/tools/get_auto_table_demo.js +1 -0
- package/dist/plugins/AutoTable/tools/get_auto_table_demo.js.map +1 -1
- package/dist/plugins/AutoTable/tools/index.d.ts +1 -2
- package/dist/plugins/AutoTable/tools/index.d.ts.map +1 -1
- package/dist/plugins/AutoTable/tools/index.js +2 -1
- package/dist/plugins/AutoTable/tools/index.js.map +1 -1
- package/dist/plugins/AutoTable/utils/getColInfo.d.ts +1 -1
- package/dist/plugins/AutoTable/utils/getColInfo.d.ts.map +1 -1
- package/dist/plugins/AutoTable/utils/getColInfo.js +2 -2
- package/dist/plugins/AutoTable/utils/getColInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/AutoTable/tools/get_auto_table_action.js +84 -0
- package/src/plugins/AutoTable/tools/get_auto_table_batchAction.js +75 -0
- package/src/plugins/AutoTable/tools/get_auto_table_column.js +83 -0
- package/src/plugins/AutoTable/tools/get_auto_table_demo.js +66 -0
- package/src/plugins/AutoTable/tools/index.js +10 -0
- package/src/resources/components-info.json +0 -12
- package/src/rules/instruction-components.md +14 -19
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
3
|
-
declare const registryTool: (server: McpServer) => void;
|
|
4
1
|
export default registryTool;
|
|
2
|
+
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
3
|
+
declare function registryTool(server: any): void;
|
|
5
4
|
//# sourceMappingURL=get_auto_table_action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_action.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_action.
|
|
1
|
+
{"version":3,"file":"get_auto_table_action.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_action.js"],"names":[],"mappings":";AA2CA,uDAAuD;AACvD,iDAqCC"}
|
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const componentDescription = `
|
|
3
|
+
### Feature: 生成AutoTable操作列
|
|
4
|
+
|
|
5
|
+
### Description: 根据操作列按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列
|
|
6
|
+
|
|
7
|
+
### When to Use:
|
|
8
|
+
1. 已拿到操作列按钮(标题/图标/优先级)但不想手写ActionGroup结构。
|
|
9
|
+
2. 需要按照设计稿/截图还原操作列,并确保符合AutoTable规范。
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
1.
|
|
11
|
-
2.
|
|
12
|
-
3.
|
|
11
|
+
### How to use the result:
|
|
12
|
+
1. 将返回的ActionGroup JSX粘贴到AutoTable columns中操作列的render字段中
|
|
13
|
+
2. 仅在onClick中补充业务逻辑,其他结构勿改为Antd Table格式。
|
|
14
|
+
3. 属性需完整保留,若需二次加工请基于原输出扩展。
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
1.
|
|
16
|
-
2.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
### Limit:
|
|
17
|
+
1. ActionGroup只能从src/components/AutoTable引入。
|
|
18
|
+
2. 只能使用真实存在的按钮属性,禁止虚构。
|
|
19
|
+
|
|
20
|
+
### Trigger Example:
|
|
21
|
+
1. 生成或优化操作列
|
|
22
|
+
2. 统一ActionGroup配置
|
|
23
|
+
3. 根据视觉稿构建操作列
|
|
24
|
+
`;
|
|
25
|
+
const componentDefineSchema = {
|
|
26
|
+
actions: z
|
|
27
|
+
.array(z.object({
|
|
28
|
+
title: z.string().describe("操作按钮名称"),
|
|
29
|
+
icon: z.string().describe("操作按钮图标"),
|
|
30
|
+
isMore: z
|
|
31
|
+
.boolean()
|
|
32
|
+
.describe("是否是更多按钮(竖着排列的三个点即为更多)"),
|
|
33
|
+
}))
|
|
34
|
+
.describe("操作列的按钮信息列表"),
|
|
35
|
+
actionCount: z
|
|
36
|
+
.number()
|
|
37
|
+
.describe("除了Dropdown中及更多按钮外剩余展示的按钮数量"),
|
|
38
|
+
};
|
|
39
|
+
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
40
|
+
const registryTool = (server) => {
|
|
41
|
+
server.tool("get_auto_table_action", componentDescription, componentDefineSchema, async ({ actions, actionCount }) => {
|
|
30
42
|
const generateActionGroup = (actions ?? [])
|
|
31
43
|
.filter((action) => !action.isMore)
|
|
32
44
|
.map((action) => {
|
|
@@ -39,7 +51,9 @@ const registryTool = (server) => {
|
|
|
39
51
|
},
|
|
40
52
|
};
|
|
41
53
|
});
|
|
42
|
-
const titleLimit = (actions ?? []).some(i => i.isMore)
|
|
54
|
+
const titleLimit = (actions ?? []).some((i) => i.isMore)
|
|
55
|
+
? `tileLimit=${actionCount}` // 这里因为ActionGroup历史原因titleLimit拼写错误成tileLimit,所以只能将错就错这里也写tileLimit
|
|
56
|
+
: ``;
|
|
43
57
|
return {
|
|
44
58
|
content: [
|
|
45
59
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_action.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_action.
|
|
1
|
+
{"version":3,"file":"get_auto_table_action.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_action.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsB5B,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,OAAO,EAAE,CAAC;SACP,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACnC,MAAM,EAAE,CAAC;aACN,OAAO,EAAE;aACT,QAAQ,CAAC,uBAAuB,CAAC;KACrC,CAAC,CACH;SACA,QAAQ,CAAC,YAAY,CAAC;IACzB,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,CAAC,4BAA4B,CAAC;CAC1C,CAAC;AAEF,uDAAuD;AACvD,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE;IAC9B,MAAM,CAAC,IAAI,CACT,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;QACjC,MAAM,mBAAmB,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;aACxC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;aAClC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO;gBACT,CAAC;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,MAAM,UAAU,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YACtD,CAAC,CAAC,aAAa,WAAW,EAAE,CAAC,oEAAoE;YACjG,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,2BAA2B;oBACxC,IAAI,EAAE;sBACI,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC;cACpD,UAAU;eACT;iBACJ;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_auto_table_batchAction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_batchAction.js"],"names":[],"mappings":";AAiCA,uDAAuD;AACvD,iDAsCC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const componentDescription = `
|
|
3
|
+
### Feature: 生成AutoTable的batchAction属性
|
|
4
|
+
|
|
5
|
+
### Description: 根据底部批量操作按钮信息生成符合AutoTable组件规范的batchAction属性
|
|
6
|
+
|
|
7
|
+
### When to Use:
|
|
8
|
+
1. 根据用户描述的批量操作按钮信息,生成符合AutoTable组件规范的batchAction属性
|
|
9
|
+
2. 需要按照设计稿/截图还原底部批量操作,并确保符合AutoTable规范。
|
|
10
|
+
|
|
11
|
+
### How to use the result:
|
|
12
|
+
1. 将返回的结果作为AutoTable的batchAction属性使用
|
|
13
|
+
2. 仅在onClick中补充业务逻辑,其他结构勿改为Antd Table格式。
|
|
14
|
+
3. 属性需完整保留,若需二次加工请基于原输出扩展。
|
|
15
|
+
|
|
16
|
+
### Trigger Example:
|
|
17
|
+
1. 生成或优化表格的批量操作
|
|
18
|
+
2. 统一batchAction配置
|
|
19
|
+
3. 根据视觉稿构建表格的批量操作
|
|
20
|
+
`;
|
|
21
|
+
const componentDefineSchema = {
|
|
22
|
+
actions: z
|
|
23
|
+
.array(z.object({
|
|
24
|
+
title: z.string().describe("操作按钮名称"),
|
|
25
|
+
icon: z.string().describe("操作按钮图标"),
|
|
26
|
+
}))
|
|
27
|
+
.describe("操作列的按钮信息列表"),
|
|
28
|
+
};
|
|
29
|
+
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
30
|
+
const registryTool = (server) => {
|
|
31
|
+
server.tool("get_auto_table_batchAction", componentDescription, componentDefineSchema, async ({ actions }) => {
|
|
32
|
+
const generateActionGroup = (actions ?? [])
|
|
33
|
+
.map((action) => {
|
|
34
|
+
return {
|
|
35
|
+
title: action.title,
|
|
36
|
+
icon: action.icon,
|
|
37
|
+
rules: [],
|
|
38
|
+
onClick: () => {
|
|
39
|
+
// TODO
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const batchActions = `{
|
|
44
|
+
showCount: true,
|
|
45
|
+
checkedText: I18N.common.pageSelect.pageAll,
|
|
46
|
+
onSelectAll: (checked: boolean, selectedRowKeys?: React.Key[]) => {
|
|
47
|
+
// setSelectedRowKeys(selectedRows);
|
|
48
|
+
},
|
|
49
|
+
actions: ${JSON.stringify(generateActionGroup, null, 2)},
|
|
50
|
+
}`;
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
description: "AutoTable组件所使用到的batchAction定义",
|
|
56
|
+
text: batchActions.replace(/[\r\n]+/g, ''),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export default registryTool;
|
|
63
|
+
//# sourceMappingURL=get_auto_table_batchAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_auto_table_batchAction.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_batchAction.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;CAkB5B,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,OAAO,EAAE,CAAC;SACP,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;KACpC,CAAC,CACH;SACA,QAAQ,CAAC,YAAY,CAAC;CAC1B,CAAC;AAEF,uDAAuD;AACvD,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE;IAC9B,MAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,MAAM,mBAAmB,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;aACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO;gBACT,CAAC;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,MAAM,YAAY,GAAG;;;;;;mBAMR,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QAEH,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,+BAA+B;oBAC5C,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;iBAC3C;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/** 根据列信息生成符合 AutoTable 组件规范的columns属性 */
|
|
3
|
-
declare const registryTool: (server: McpServer) => void;
|
|
4
1
|
export default registryTool;
|
|
2
|
+
/** 根据列信息生成符合 AutoTable 组件规范的columns属性 */
|
|
3
|
+
declare function registryTool(server: any): void;
|
|
5
4
|
//# sourceMappingURL=get_auto_table_column.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_column.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_column.
|
|
1
|
+
{"version":3,"file":"get_auto_table_column.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_column.js"],"names":[],"mappings":";AAgDA,yCAAyC;AACzC,iDA+BC"}
|
|
@@ -1,27 +1,51 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getFixedColInfo } from
|
|
2
|
+
import { getFixedColInfo } from "../utils/getColInfo.js";
|
|
3
|
+
const componentDescription = `
|
|
4
|
+
### Feature: 构建表格的columns属性
|
|
5
|
+
|
|
6
|
+
### Description: 输入列字段配置,产出完全符合 AutoTable 规范的 columns 属性定义,可直接粘贴到页面或组件中使用
|
|
7
|
+
|
|
8
|
+
### When to Use:
|
|
9
|
+
1. 需要生成表格相关代码
|
|
10
|
+
2. 从产品文档或原型中整理出表头信息,需快速得到 AutoTable 可用的 columns
|
|
11
|
+
3. 需要基于现有列配置做格式校正(宽度、操作列标记等),避免手写出错
|
|
12
|
+
4. 将图片/表格内容结构化后,希望快速转成 AutoTable columns
|
|
13
|
+
|
|
14
|
+
### How to use the result:
|
|
15
|
+
1. 以当前tool返回的结果构建AutoTable组件的columns属性
|
|
16
|
+
2. 不要篡改返回结果, 不要将其转化为标准的Antd Table格式
|
|
17
|
+
3. 属性尽可能的保留, 并以此为参考构建更适合的columns属性
|
|
18
|
+
|
|
19
|
+
### Input Requirements:
|
|
20
|
+
1. 每列需提供 title、dataIndex、width、actionNum 四个字段
|
|
21
|
+
2. 宽度请使用数字(px),操作列请正确设置 actionNum 的值
|
|
22
|
+
3. 若包含固定列、操作列等特殊需求,可在列信息中如实描述
|
|
23
|
+
|
|
24
|
+
### Output Specs:
|
|
25
|
+
1. 结果为 const columns = [...] 形式,字段顺序、名称符合 AutoTable 预期
|
|
26
|
+
2. 不需要再手动转换为 Antd Table 格式
|
|
27
|
+
3. 可直接作为 AutoTable 的 columns 属性引用
|
|
28
|
+
|
|
29
|
+
### Trigger Example:
|
|
30
|
+
1. 生成/更新表格
|
|
31
|
+
2. 优化表格的columns
|
|
32
|
+
3. 根据视觉稿/图片生成表格
|
|
33
|
+
`;
|
|
34
|
+
const componentDefineSchema = {
|
|
35
|
+
columns: z
|
|
36
|
+
.array(z.object({
|
|
37
|
+
title: z.string().describe("列标题"),
|
|
38
|
+
dataIndex: z.string().describe("列对应的字段名"),
|
|
39
|
+
width: z.number().describe("列的宽度"),
|
|
40
|
+
actionNum: z.number().describe("操作列的操作数量"),
|
|
41
|
+
}))
|
|
42
|
+
.describe("表格的列信息列表"),
|
|
43
|
+
};
|
|
3
44
|
/** 根据列信息生成符合 AutoTable 组件规范的columns属性 */
|
|
4
45
|
const registryTool = (server) => {
|
|
5
|
-
server.tool("get_auto_table_column",
|
|
6
|
-
适用场景:
|
|
7
|
-
1. 用户给出表格列的信息, 根据列信息生成符合AutoTable组件规范的columns属性
|
|
8
|
-
2. 用户通过上传图片, 根据图片解析出表格列的信息并生成columns属性
|
|
9
|
-
|
|
10
|
-
如何使用返回结果
|
|
11
|
-
1. 以当前tool返回的结果构建AutoTable组件的columns属性
|
|
12
|
-
2. 不要篡改返回结果, 不要将其转化为标准的Antd Table格式
|
|
13
|
-
3. 属性尽可能的保留, 并以此为参考构建更适合的columns属性`, {
|
|
14
|
-
columns: z
|
|
15
|
-
.array(z.object({
|
|
16
|
-
title: z.string().describe("列标题"),
|
|
17
|
-
dataIndex: z.string().describe("列对应的字段名"),
|
|
18
|
-
width: z.number().describe("列的宽度"),
|
|
19
|
-
isAction: z.boolean().describe("是否为操作列"),
|
|
20
|
-
}))
|
|
21
|
-
.describe("表格的列信息列表"),
|
|
22
|
-
}, async ({ columns }) => {
|
|
46
|
+
server.tool("get_auto_table_column", componentDescription, componentDefineSchema, async ({ columns }) => {
|
|
23
47
|
const generateColumns = (columns ?? []).map((column) => {
|
|
24
|
-
const res = getFixedColInfo(column.title, column.dataIndex, column.width);
|
|
48
|
+
const res = getFixedColInfo(column.title, column.dataIndex, column.width, column.actionNum);
|
|
25
49
|
return res;
|
|
26
50
|
});
|
|
27
51
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_column.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_column.
|
|
1
|
+
{"version":3,"file":"get_auto_table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AA2B;oBACxC,IAAI,EAAE,uCAAuC,IAAI,CAAC,SAAS,CACzD,eAAe,EACf,IAAI,EACJ,CAAC,CACF,EAAE;iBACJ;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/** 根据关键词匹配AutoTable示例 */
|
|
3
|
-
declare const registryTool: (server: McpServer) => void;
|
|
4
1
|
export default registryTool;
|
|
2
|
+
/** 根据关键词匹配AutoTable示例 */
|
|
3
|
+
declare function registryTool(server: any): void;
|
|
5
4
|
//# sourceMappingURL=get_auto_table_demo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_demo.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_demo.
|
|
1
|
+
{"version":3,"file":"get_auto_table_demo.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_demo.js"],"names":[],"mappings":";AAIA,yBAAyB;AACzB,iDA0DC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_auto_table_demo.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_demo.
|
|
1
|
+
{"version":3,"file":"get_auto_table_demo.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/get_auto_table_demo.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,yBAAyB;AACzB,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE;IAC9B,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,EAAE;QACrC,MAAM,eAAe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file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/index.js"],"names":[],"mappings":"AAKA,yDAIC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import getAutoTableExample from './get_auto_table_demo.js';
|
|
2
2
|
import generateAutoTableColumn from './get_auto_table_column.js';
|
|
3
3
|
import generateAutoTableAction from './get_auto_table_action.js';
|
|
4
|
+
import generateAutoTableBatchAction from './get_auto_table_batchAction.js';
|
|
4
5
|
export default function registryTools(server) {
|
|
5
|
-
[generateAutoTableColumn, generateAutoTableAction, getAutoTableExample].forEach((registryFn) => {
|
|
6
|
+
[generateAutoTableColumn, generateAutoTableAction, getAutoTableExample, generateAutoTableBatchAction].forEach((registryFn) => {
|
|
6
7
|
registryFn(server);
|
|
7
8
|
});
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/tools/index.js"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AACjE,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AACjE,OAAO,4BAA4B,MAAM,iCAAiC,CAAC;AAE3E,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,MAAM;IAC1C,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,4BAA4B,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAC3H,UAAU,CAAC,MAAM,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @description 根据列标题名称或dataIndex结合业务含义给出列宽相关的属性定义
|
|
3
3
|
* @author 千旌
|
|
4
4
|
*/
|
|
5
|
-
export declare const getFixedColInfo: (title: string, dataIndex: string, width: number) => {
|
|
5
|
+
export declare const getFixedColInfo: (title: string, dataIndex: string, width: number, actionNum: number) => {
|
|
6
6
|
title: string;
|
|
7
7
|
dataIndex: string;
|
|
8
8
|
time: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getColInfo.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/utils/getColInfo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getColInfo.d.ts","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/utils/getColInfo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiElB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @description 根据列标题名称或dataIndex结合业务含义给出列宽相关的属性定义
|
|
3
3
|
* @author 千旌
|
|
4
4
|
*/
|
|
5
|
-
export const getFixedColInfo = (title, dataIndex, width) => {
|
|
5
|
+
export const getFixedColInfo = (title, dataIndex, width, actionNum) => {
|
|
6
6
|
// 时间列
|
|
7
7
|
if (title.includes("时间")) {
|
|
8
8
|
return {
|
|
@@ -47,7 +47,7 @@ export const getFixedColInfo = (title, dataIndex, width) => {
|
|
|
47
47
|
return {
|
|
48
48
|
title,
|
|
49
49
|
dataIndex,
|
|
50
|
-
iconNumber:
|
|
50
|
+
iconNumber: actionNum,
|
|
51
51
|
fixed: 'right',
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getColInfo.js","sourceRoot":"","sources":["../../../../src/plugins/AutoTable/utils/getColInfo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAa,EACb,SAAiB,EACjB,KAAa,EACb,EAAE;IACF,MAAM;IACN,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,KAAK;YACL,SAAS;YACT,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;IAED,MAAM;IACN,IACE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACnB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpB,CAAC;QACD,OAAO;YACL,KAAK;YACL,SAAS;YACT,MAAM,EAAE,CAAC;SACV,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,OAAO;YACL,KAAK;YACL,SAAS;YACT,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IAED,QAAQ;IACR,IACE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpB,CAAC;QACD,OAAO;YACL,KAAK;YACL,SAAS;YACT,KAAK,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AAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpB,CAAC;QACD,OAAO;YACL,KAAK;YACL,SAAS;YACT,KAAK,EAAE,GAAG;SACX,CAAC;IACJ,CAAC;IAEF,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO;YACN,KAAK;YACL,SAAS;YACT,UAAU,EAAE,SAAS;YACrB,KAAK,EAAE,OAAO;SACd,CAAA;IACF,CAAC;IAED,OAAO;QACN,KAAK;QACL,SAAS;QACT,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC;KACP,CAAA;AACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const componentDescription = `
|
|
4
|
+
### Feature: 生成AutoTable操作列
|
|
5
|
+
|
|
6
|
+
### Description: 根据操作列按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列
|
|
7
|
+
|
|
8
|
+
### When to Use:
|
|
9
|
+
1. 已拿到操作列按钮(标题/图标/优先级)但不想手写ActionGroup结构。
|
|
10
|
+
2. 需要按照设计稿/截图还原操作列,并确保符合AutoTable规范。
|
|
11
|
+
|
|
12
|
+
### How to use the result:
|
|
13
|
+
1. 将返回的ActionGroup JSX粘贴到AutoTable columns中操作列的render字段中
|
|
14
|
+
2. 仅在onClick中补充业务逻辑,其他结构勿改为Antd Table格式。
|
|
15
|
+
3. 属性需完整保留,若需二次加工请基于原输出扩展。
|
|
16
|
+
|
|
17
|
+
### Limit:
|
|
18
|
+
1. ActionGroup只能从src/components/AutoTable引入。
|
|
19
|
+
2. 只能使用真实存在的按钮属性,禁止虚构。
|
|
20
|
+
|
|
21
|
+
### Trigger Example:
|
|
22
|
+
1. 生成或优化操作列
|
|
23
|
+
2. 统一ActionGroup配置
|
|
24
|
+
3. 根据视觉稿构建操作列
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const componentDefineSchema = {
|
|
28
|
+
actions: z
|
|
29
|
+
.array(
|
|
30
|
+
z.object({
|
|
31
|
+
title: z.string().describe("操作按钮名称"),
|
|
32
|
+
icon: z.string().describe("操作按钮图标"),
|
|
33
|
+
isMore: z
|
|
34
|
+
.boolean()
|
|
35
|
+
.describe("是否是更多按钮(竖着排列的三个点即为更多)"),
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
.describe("操作列的按钮信息列表"),
|
|
39
|
+
actionCount: z
|
|
40
|
+
.number()
|
|
41
|
+
.describe("除了Dropdown中及更多按钮外剩余展示的按钮数量"),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
45
|
+
const registryTool = (server) => {
|
|
46
|
+
server.tool(
|
|
47
|
+
"get_auto_table_action",
|
|
48
|
+
componentDescription,
|
|
49
|
+
componentDefineSchema,
|
|
50
|
+
async ({ actions, actionCount }) => {
|
|
51
|
+
const generateActionGroup = (actions ?? [])
|
|
52
|
+
.filter((action) => !action.isMore)
|
|
53
|
+
.map((action) => {
|
|
54
|
+
return {
|
|
55
|
+
title: action.title,
|
|
56
|
+
icon: action.icon,
|
|
57
|
+
rules: [],
|
|
58
|
+
onClick: () => {
|
|
59
|
+
// TODO
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const titleLimit = (actions ?? []).some((i) => i.isMore)
|
|
65
|
+
? `tileLimit=${actionCount}` // 这里因为ActionGroup历史原因titleLimit拼写错误成tileLimit,所以只能将错就错这里也写tileLimit
|
|
66
|
+
: ``;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
content: [
|
|
70
|
+
{
|
|
71
|
+
type: "text",
|
|
72
|
+
description: "AutoTable组件所使用到的columns定义",
|
|
73
|
+
text: `return <ActionGroup
|
|
74
|
+
actions=${JSON.stringify(generateActionGroup, null, 2)}
|
|
75
|
+
${titleLimit}
|
|
76
|
+
/>`,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default registryTool;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const componentDescription = `
|
|
4
|
+
### Feature: 生成AutoTable的batchAction属性
|
|
5
|
+
|
|
6
|
+
### Description: 根据底部批量操作按钮信息生成符合AutoTable组件规范的batchAction属性
|
|
7
|
+
|
|
8
|
+
### When to Use:
|
|
9
|
+
1. 根据用户描述的批量操作按钮信息,生成符合AutoTable组件规范的batchAction属性
|
|
10
|
+
2. 需要按照设计稿/截图还原底部批量操作,并确保符合AutoTable规范。
|
|
11
|
+
|
|
12
|
+
### How to use the result:
|
|
13
|
+
1. 将返回的结果作为AutoTable的batchAction属性使用
|
|
14
|
+
2. 仅在onClick中补充业务逻辑,其他结构勿改为Antd Table格式。
|
|
15
|
+
3. 属性需完整保留,若需二次加工请基于原输出扩展。
|
|
16
|
+
|
|
17
|
+
### Trigger Example:
|
|
18
|
+
1. 生成或优化表格的批量操作
|
|
19
|
+
2. 统一batchAction配置
|
|
20
|
+
3. 根据视觉稿构建表格的批量操作
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const componentDefineSchema = {
|
|
24
|
+
actions: z
|
|
25
|
+
.array(
|
|
26
|
+
z.object({
|
|
27
|
+
title: z.string().describe("操作按钮名称"),
|
|
28
|
+
icon: z.string().describe("操作按钮图标"),
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
.describe("操作列的按钮信息列表"),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** 根据操作列的按钮信息使用ActionGroup组件生成符合 AutoTable 组件规范的操作列 */
|
|
35
|
+
const registryTool = (server) => {
|
|
36
|
+
server.tool(
|
|
37
|
+
"get_auto_table_batchAction",
|
|
38
|
+
componentDescription,
|
|
39
|
+
componentDefineSchema,
|
|
40
|
+
async ({ actions }) => {
|
|
41
|
+
const generateActionGroup = (actions ?? [])
|
|
42
|
+
.map((action) => {
|
|
43
|
+
return {
|
|
44
|
+
title: action.title,
|
|
45
|
+
icon: action.icon,
|
|
46
|
+
rules: [],
|
|
47
|
+
onClick: () => {
|
|
48
|
+
// TODO
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const batchActions = `{
|
|
54
|
+
showCount: true,
|
|
55
|
+
checkedText: I18N.common.pageSelect.pageAll,
|
|
56
|
+
onSelectAll: (checked: boolean, selectedRowKeys?: React.Key[]) => {
|
|
57
|
+
// setSelectedRowKeys(selectedRows);
|
|
58
|
+
},
|
|
59
|
+
actions: ${JSON.stringify(generateActionGroup, null, 2)},
|
|
60
|
+
}`;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: "text",
|
|
66
|
+
description: "AutoTable组件所使用到的batchAction定义",
|
|
67
|
+
text: batchActions.replace(/[\r\n]+/g, ''),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default registryTool;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getFixedColInfo } from "../utils/getColInfo.js";
|
|
3
|
+
|
|
4
|
+
const componentDescription = `
|
|
5
|
+
### Feature: 构建表格的columns属性
|
|
6
|
+
|
|
7
|
+
### Description: 输入列字段配置,产出完全符合 AutoTable 规范的 columns 属性定义,可直接粘贴到页面或组件中使用
|
|
8
|
+
|
|
9
|
+
### When to Use:
|
|
10
|
+
1. 需要生成表格相关代码
|
|
11
|
+
2. 从产品文档或原型中整理出表头信息,需快速得到 AutoTable 可用的 columns
|
|
12
|
+
3. 需要基于现有列配置做格式校正(宽度、操作列标记等),避免手写出错
|
|
13
|
+
4. 将图片/表格内容结构化后,希望快速转成 AutoTable columns
|
|
14
|
+
|
|
15
|
+
### How to use the result:
|
|
16
|
+
1. 以当前tool返回的结果构建AutoTable组件的columns属性
|
|
17
|
+
2. 不要篡改返回结果, 不要将其转化为标准的Antd Table格式
|
|
18
|
+
3. 属性尽可能的保留, 并以此为参考构建更适合的columns属性
|
|
19
|
+
|
|
20
|
+
### Input Requirements:
|
|
21
|
+
1. 每列需提供 title、dataIndex、width、actionNum 四个字段
|
|
22
|
+
2. 宽度请使用数字(px),操作列请正确设置 actionNum 的值
|
|
23
|
+
3. 若包含固定列、操作列等特殊需求,可在列信息中如实描述
|
|
24
|
+
|
|
25
|
+
### Output Specs:
|
|
26
|
+
1. 结果为 const columns = [...] 形式,字段顺序、名称符合 AutoTable 预期
|
|
27
|
+
2. 不需要再手动转换为 Antd Table 格式
|
|
28
|
+
3. 可直接作为 AutoTable 的 columns 属性引用
|
|
29
|
+
|
|
30
|
+
### Trigger Example:
|
|
31
|
+
1. 生成/更新表格
|
|
32
|
+
2. 优化表格的columns
|
|
33
|
+
3. 根据视觉稿/图片生成表格
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const componentDefineSchema = {
|
|
37
|
+
columns: z
|
|
38
|
+
.array(
|
|
39
|
+
z.object({
|
|
40
|
+
title: z.string().describe("列标题"),
|
|
41
|
+
dataIndex: z.string().describe("列对应的字段名"),
|
|
42
|
+
width: z.number().describe("列的宽度"),
|
|
43
|
+
actionNum: z.number().describe("操作列的操作数量"),
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
.describe("表格的列信息列表"),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** 根据列信息生成符合 AutoTable 组件规范的columns属性 */
|
|
50
|
+
const registryTool = (server) => {
|
|
51
|
+
server.tool(
|
|
52
|
+
"get_auto_table_column",
|
|
53
|
+
componentDescription,
|
|
54
|
+
componentDefineSchema,
|
|
55
|
+
async ({ columns }) => {
|
|
56
|
+
const generateColumns = (columns ?? []).map((column) => {
|
|
57
|
+
const res = getFixedColInfo(
|
|
58
|
+
column.title,
|
|
59
|
+
column.dataIndex,
|
|
60
|
+
column.width,
|
|
61
|
+
column.actionNum
|
|
62
|
+
);
|
|
63
|
+
return res;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: "text",
|
|
70
|
+
description: "AutoTable组件所使用到的columns定义",
|
|
71
|
+
text: `const columns: ColumnProps<any>[] = ${JSON.stringify(
|
|
72
|
+
generateColumns,
|
|
73
|
+
null,
|
|
74
|
+
2
|
|
75
|
+
)}`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default registryTool;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tableDemos } from "../examples/index.js";
|
|
3
|
+
import { registerDemo } from '../../../pluginUtils/index.js';
|
|
4
|
+
|
|
5
|
+
/** 根据关键词匹配AutoTable示例 */
|
|
6
|
+
const registryTool = (server) => {
|
|
7
|
+
const getDemoByKeywords = (keywords) => {
|
|
8
|
+
const matchedExamples = {};
|
|
9
|
+
|
|
10
|
+
// 遍历所有示例,查找匹配关键词的示例
|
|
11
|
+
for (const [demoName, demo] of Object.entries(tableDemos)) {
|
|
12
|
+
const { title, keywords: demoKeywords, description } = demo;
|
|
13
|
+
|
|
14
|
+
// 检查关键词是否匹配title、description或keywords数组
|
|
15
|
+
const isMatch = keywords.some(
|
|
16
|
+
(keyword) =>
|
|
17
|
+
title.includes(keyword) ||
|
|
18
|
+
description.includes(keyword) ||
|
|
19
|
+
demoKeywords.some((demoKeyword) =>
|
|
20
|
+
demoKeyword.includes(keyword)
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (isMatch) {
|
|
25
|
+
matchedExamples[demoName] = demo;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: JSON.stringify(matchedExamples),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
registerDemo('AutoTable', getDemoByKeywords)
|
|
40
|
+
|
|
41
|
+
// server.tool(
|
|
42
|
+
// "get_auto_table_demo",
|
|
43
|
+
// `根据关键词匹配 AutoTable 及其派生组件 ( GroupTable, ShrinkableTable, TableForm ) 组件示例
|
|
44
|
+
// 适用场景:
|
|
45
|
+
// 1. 用户提供关键词查询相关示例
|
|
46
|
+
// 2. 用户想要查找具有特定功能的AutoTable示例
|
|
47
|
+
// 3. 需要基于功能需求推荐合适的示例代码
|
|
48
|
+
// 4. 用户询问AutoTable及其派生组件的代码示例
|
|
49
|
+
// 5. 用户希望帮助生成AutoTable组件及其派生组件的代码
|
|
50
|
+
// 6. 用户希望结合视觉稿图片根据图片中的内容与数据生成对应的AutoTable及其派生组件的代码示例
|
|
51
|
+
// 7. 用户已经明确要使用具体某个的AutoTable示例
|
|
52
|
+
// 8. 用户询问如何改造AutoTable及其派生组件以满足要求
|
|
53
|
+
// 9. 用户询问在AutoTable及其派生组件使用过程中报错该如何处理
|
|
54
|
+
|
|
55
|
+
// 能力:
|
|
56
|
+
// 1. 根据用户提供的关键词在示例的title、keywords、description中进行匹配
|
|
57
|
+
// 2. 返回匹配度最高的示例或多个相关示例
|
|
58
|
+
// 3. 提供示例的完整信息,包括代码、说明和使用提示`,
|
|
59
|
+
// { keywords: z.array(z.string()).describe("关键词列表") },
|
|
60
|
+
// async ({ keywords }) => {
|
|
61
|
+
// return getDemoByKeywords(keywords)
|
|
62
|
+
// }
|
|
63
|
+
// );
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default registryTool;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import getAutoTableExample from './get_auto_table_demo.js';
|
|
2
|
+
import generateAutoTableColumn from './get_auto_table_column.js';
|
|
3
|
+
import generateAutoTableAction from './get_auto_table_action.js';
|
|
4
|
+
import generateAutoTableBatchAction from './get_auto_table_batchAction.js';
|
|
5
|
+
|
|
6
|
+
export default function registryTools(server) {
|
|
7
|
+
[generateAutoTableColumn, generateAutoTableAction, getAutoTableExample, generateAutoTableBatchAction].forEach((registryFn) => {
|
|
8
|
+
registryFn(server)
|
|
9
|
+
})
|
|
10
|
+
}
|
|
@@ -34,10 +34,6 @@
|
|
|
34
34
|
"name": "BasicCalendar",
|
|
35
35
|
"whenToUse": "需要使用的日历组件的时候使用"
|
|
36
36
|
},
|
|
37
|
-
{
|
|
38
|
-
"name": "BlueInfoTip",
|
|
39
|
-
"whenToUse": "基础使用, 往往在弹框底部, 或抽屉中展示提示信息"
|
|
40
|
-
},
|
|
41
37
|
{
|
|
42
38
|
"name": "BottomOperationBar",
|
|
43
39
|
"whenToUse": "底部固定操作栏"
|
|
@@ -114,10 +110,6 @@
|
|
|
114
110
|
"name": "DataTypeSelect",
|
|
115
111
|
"whenToUse": "数据类型选择器\n1. 有类型选择的需求时\n2. 建模所有选择数据类型的地方已在使用"
|
|
116
112
|
},
|
|
117
|
-
{
|
|
118
|
-
"name": "DebounceSearchInput",
|
|
119
|
-
"whenToUse": "debounce处理后的search,常用于search的场景,减少搜索时的频繁请求"
|
|
120
|
-
},
|
|
121
113
|
{
|
|
122
114
|
"name": "DeleteModal",
|
|
123
115
|
"whenToUse": "删除/下线/下线并删除或者任何需要二次确认时的交互弹窗"
|
|
@@ -258,10 +250,6 @@
|
|
|
258
250
|
"name": "RenderWhenActive",
|
|
259
251
|
"whenToUse": "用于首屏不需要展示,通过 active 等字段控制的组件 HOC,如 Modal、Drawer 等组件"
|
|
260
252
|
},
|
|
261
|
-
{
|
|
262
|
-
"name": "RightDrawer",
|
|
263
|
-
"whenToUse": "从屏幕右侧边缘滑出的抽屉。可自定义抽屉的头部、底部内容。"
|
|
264
|
-
},
|
|
265
253
|
{
|
|
266
254
|
"name": "RoleIconText",
|
|
267
255
|
"whenToUse": "需要展示权限角色icon时, 角色icon 和 名称对应如下图展示;"
|
|
@@ -254,7 +254,7 @@ const AdvancedForm: React.FC = () => {
|
|
|
254
254
|
|
|
255
255
|
#### AutoTable Usage
|
|
256
256
|
```tsx
|
|
257
|
-
import AutoTable from 'src/components/AutoTable';
|
|
257
|
+
import AutoTable, { ColumnProps, ActionGroup } from 'src/components/AutoTable';
|
|
258
258
|
import { getUserList, deleteUser } from 'src/services/userService';
|
|
259
259
|
|
|
260
260
|
interface User {
|
|
@@ -299,7 +299,7 @@ const UserTable: React.FC = () => {
|
|
|
299
299
|
}, [loadUsers]);
|
|
300
300
|
|
|
301
301
|
// Table columns
|
|
302
|
-
const columns = useMemo(() => [
|
|
302
|
+
const columns: ColumnProps<any>[] = useMemo(() => [
|
|
303
303
|
{
|
|
304
304
|
title: '姓名',
|
|
305
305
|
dataIndex: 'name',
|
|
@@ -346,23 +346,18 @@ const UserTable: React.FC = () => {
|
|
|
346
346
|
key: 'actions',
|
|
347
347
|
width: 120,
|
|
348
348
|
render: (_, record: User) => (
|
|
349
|
-
<
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
onClick
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
onClick={() => handleDelete(record.id)}
|
|
362
|
-
>
|
|
363
|
-
删除
|
|
364
|
-
</Button>
|
|
365
|
-
</div>
|
|
349
|
+
<ActionGroup actions={[
|
|
350
|
+
{
|
|
351
|
+
icon: 'icon-edit',
|
|
352
|
+
title: '编辑',
|
|
353
|
+
onClick: () => navigate(`/users/${record.id}/edit`)
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
icon: 'icon-delete',
|
|
357
|
+
title: '删除',
|
|
358
|
+
onClick: () => handleDelete(record.id)
|
|
359
|
+
}
|
|
360
|
+
]} />
|
|
366
361
|
)
|
|
367
362
|
}
|
|
368
363
|
], [navigate]);
|