diff --git a/designer-demo/public/mock/bundle.json b/designer-demo/public/mock/bundle.json index abb90ede46..21027e21f3 100644 --- a/designer-demo/public/mock/bundle.json +++ b/designer-demo/public/mock/bundle.json @@ -10970,6 +10970,38 @@ "labelPosition": "top" } ] + }, + { + "label": { + "zh_CN": "MCP 配置" + }, + "description": { + "zh_CN": "MCP 配置" + }, + "content": [ + { + "property": "tiny_mcp_config", + "label": { + "text": { + "zh_CN": "组件MCP化配置" + } + }, + "required": true, + "readOnly": false, + "disabled": false, + "cols": 12, + "widget": { + "component": "CodeConfigurator", + "props": { + "language": "json" + } + }, + "description": { + "zh_CN": "设置表格的基础 mcp 信息" + }, + "labelPosition": "top" + } + ] } ], "events": { diff --git a/mockServer/src/mock/get/app-center/v1/apps/schema/1.json b/mockServer/src/mock/get/app-center/v1/apps/schema/1.json index 870bd4326c..71211ce19a 100644 --- a/mockServer/src/mock/get/app-center/v1/apps/schema/1.json +++ b/mockServer/src/mock/get/app-center/v1/apps/schema/1.json @@ -1726,7 +1726,7 @@ "package": "@opentiny/vue", "exportName": "CarouselItem", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyCheckboxButton", @@ -1740,14 +1740,14 @@ "package": "@opentiny/vue", "exportName": "Tree", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyPopover", "package": "@opentiny/vue", "exportName": "Popover", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyTooltip", @@ -1761,21 +1761,21 @@ "package": "@opentiny/vue", "exportName": "Col", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyDropdownItem", "package": "@opentiny/vue", "exportName": "DropdownItem", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyPager", "package": "@opentiny/vue", "exportName": "Pager", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyPlusAccessdeclined", @@ -1817,14 +1817,14 @@ "package": "@opentiny/vue", "exportName": "Row", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyFormItem", "package": "@opentiny/vue", "exportName": "FormItem", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyAlert", @@ -1838,21 +1838,21 @@ "package": "@opentiny/vue", "exportName": "Input", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyTabs", "package": "@opentiny/vue", "exportName": "Tabs", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyDropdownMenu", "package": "@opentiny/vue", "exportName": "DropdownMenu", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyDialogBox", @@ -1866,56 +1866,56 @@ "package": "@opentiny/vue", "exportName": "Switch", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyTimeLine", "package": "@opentiny/vue", "exportName": "TimeLine", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyTabItem", "package": "@opentiny/vue", "exportName": "TabItem", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyRadio", "package": "@opentiny/vue", "exportName": "Radio", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyForm", "package": "@opentiny/vue", "exportName": "Form", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyGrid", "package": "@opentiny/vue", "exportName": "Grid", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyGridColumn", "package": "@opentiny/vue", "exportName": "TinyGridColumn", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyNumeric", "package": "@opentiny/vue", "exportName": "Numeric", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyCheckboxGroup", @@ -1929,49 +1929,49 @@ "package": "@opentiny/vue", "exportName": "Checkbox", "destructuring": true, - "version": "3.20.0" + "version": "3.26.0" }, { "componentName": "TinySelect", "package": "@opentiny/vue", "exportName": "Select", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyButton", "package": "@opentiny/vue", "exportName": "Button", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyButtonGroup", "package": "@opentiny/vue", "exportName": "ButtonGroup", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyCarousel", "package": "@opentiny/vue", "exportName": "Carousel", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyPopeditor", "package": "@opentiny/vue", "exportName": "Popeditor", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyDatePicker", "package": "@opentiny/vue", "exportName": "DatePicker", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyDropdown", @@ -1985,35 +1985,35 @@ "package": "@opentiny/vue", "exportName": "ChartHistogram", "destructuring": true, - "version": "0.1.16" + "version": "3.26.0" }, { "componentName": "TinyCollapse", "package": "@opentiny/vue", "exportName": "Collapse", "destructuring": true, - "version": "3.20.0" + "version": "3.26.0" }, { "componentName": "TinyCollapseItem", "package": "@opentiny/vue", "exportName": "CollapseItem", "destructuring": true, - "version": "3.20.0" + "version": "3.26.0" }, { "componentName": "TinyBreadcrumb", "package": "@opentiny/vue", "exportName": "Breadcrumb", "destructuring": true, - "version": "3.20.0" + "version": "3.26.0" }, { "componentName": "TinyBreadcrumbItem", "package": "@opentiny/vue", "exportName": "BreadcrumbItem", "destructuring": true, - "version": "3.20.0" + "version": "3.26.0" }, { "componentName": "ElInput", diff --git a/packages/toolbars/generate-code/src/FileSelector.vue b/packages/toolbars/generate-code/src/FileSelector.vue index 9158c85ce6..b4c72d0164 100644 --- a/packages/toolbars/generate-code/src/FileSelector.vue +++ b/packages/toolbars/generate-code/src/FileSelector.vue @@ -9,6 +9,11 @@ @close="$emit('cancel')" @open="openDialog" > +
+ 启用 MCP 集成: + + (开启后将生成 MCP 相关配置和工具代码) +
/* metaService: engine.toolbars.generate-code.FileSelector */ -import { DialogBox, Button, Grid, GridColumn } from '@opentiny/vue' -import { reactive, computed, ref, nextTick } from 'vue' +import { DialogBox, Button, Grid, GridColumn, Switch } from '@opentiny/vue' +import { computed, ref, nextTick, watch, reactive } from 'vue' import { useNotify } from '@opentiny/tiny-engine-meta-register' export default { @@ -44,16 +49,18 @@ export default { TinyDialogBox: DialogBox, TinyButton: Button, TinyGrid: Grid, - TinyGridColumn: GridColumn + TinyGridColumn: GridColumn, + TinySwitch: Switch }, props: { visible: { type: Boolean, default: false }, data: { type: Array, default: () => [] - } + }, + enableMcp: { type: Boolean, default: false } }, - emits: ['cancel', 'confirm'], + emits: ['cancel', 'confirm', 'update:enableMcp'], setup(props, { emit }) { const getTableTreeData = (data: any[]) => { const res: any[] = [] @@ -86,6 +93,33 @@ export default { const gridRef = ref(null) const state = reactive({}) + const mcpEnabled = ref(props.enableMcp) + + // 监听 props.enableMcp 的变化,同步到本地状态 + watch( + () => props.enableMcp, + (newVal) => { + mcpEnabled.value = newVal + } + ) + + // 监听 props.data 的变化,重新选中所有项 + watch( + () => props.data, + () => { + nextTick(() => { + if (gridRef.value) { + gridRef.value.setAllTreeExpansion(true) + gridRef.value.setAllSelection(true) + } + }) + }, + { deep: true } + ) + + const handleMcpChange = (value: boolean) => { + emit('update:enableMcp', value) + } const confirm = () => { const selectedData = gridRef.value.getSelectRecords().filter((item: { children: any }) => !item.children) @@ -102,9 +136,14 @@ export default { } const openDialog = () => { + // 同步 props 到本地状态 + mcpEnabled.value = props.enableMcp + nextTick(() => { - gridRef.value.setAllTreeExpansion(true) - gridRef.value.setAllSelection(true) + if (gridRef.value) { + gridRef.value.setAllTreeExpansion(true) + gridRef.value.setAllSelection(true) + } }) } @@ -112,14 +151,36 @@ export default { state, tableData, gridRef, + mcpEnabled, confirm, - openDialog + openDialog, + handleMcpChange } } } `) + } else { + content += `\n\n` + } + return content +} + +/** + * 辅助函数:创建新的 script setup + * @param {string} originalContent 原始内容 + * @param {string} mcpImports MCP imports + * @param {string} mcpSetup MCP setup 代码 + * @param {string} mcpTemplate MCP 模板 + * @param {string} mcpStyle MCP 样式 + * @param {string} mcpOnMountedCode MCP onMounted 代码 + * @returns {string} 修改后的内容 + */ +function createNewScriptSetup(originalContent, mcpImports, mcpSetup, mcpTemplate, mcpStyle, mcpOnMountedCode) { + const mcpScript = `` + + let modifiedContent = originalContent.replace(/