From d71b62a2951a2cf6dded317f117fcbb653f6fe80 Mon Sep 17 00:00:00 2001 From: betterdancing Date: Wed, 15 Oct 2025 19:15:07 -0700 Subject: [PATCH 1/2] fix(app-preview-importMap): fix importmap missing element-plus when app preview --- designer-demo/public/mock/bundle.json | 637 +++++++++++++++ .../mock/get/app-center/v1/apps/schema/1.json | 21 + .../canvas/DesignCanvas/src/DesignCanvas.vue | 7 +- .../container/src/components/CanvasAction.vue | 7 +- packages/canvas/container/src/container.ts | 35 +- .../toolbar-built-in/ToolbarBaseIcon.vue | 2 +- packages/common/js/import-map.json | 1 + .../HtmlAttributesConfigurator.vue | 66 +- .../slot-configurator/SlotConfigurator.vue | 2 +- .../VariableConfigurator.vue | 736 ------------------ .../src/preview/src/preview/usePreviewData.ts | 8 +- .../materials/src/composable/useResource.ts | 32 +- packages/plugins/tree/src/Main.vue | 19 +- packages/toolbars/preview/src/Main.vue | 2 +- 14 files changed, 794 insertions(+), 781 deletions(-) delete mode 100644 packages/configurator/src/variable-configurator/VariableConfigurator.vue diff --git a/designer-demo/public/mock/bundle.json b/designer-demo/public/mock/bundle.json index 3d03b34252..abb90ede46 100644 --- a/designer-demo/public/mock/bundle.json +++ b/designer-demo/public/mock/bundle.json @@ -3,6 +3,507 @@ "framework": "Vue", "materials": { "components": [ + { + "version": "3.22.0", + "name": { + "zh_CN": "折线图" + }, + "component": "TinyHuichartsLine", + "icon": "line", + "description": "折线图", + "docUrl": "", + "screenshot": "", + "tags": "", + "keywords": "", + "devMode": "proCode", + "npm": { + "destructuring": true, + "exportName": "TinyHuichartsLine", + "name": "TinyVueHuicharts组件库", + "package": "@opentiny/vue-huicharts", + "version": "3.22.0", + "script": "https://registry.npmmirror.com/@opentiny/vue-runtime/3.22/files/dist3/tiny-vue-huicharts.mjs" + }, + "group": "chart", + "category": "图表组件", + "priority": 2, + "schema": { + "properties": [ + { + "label": { + "zh_CN": "基础信息" + }, + "description": { + "zh_CN": "基础信息" + }, + "content": [ + { + "property": "options", + "label": { + "text": { + "zh_CN": "图表配置" + } + }, + "required": true, + "readOnly": false, + "disabled": false, + "cols": 12, + "widget": { + "component": "CodeConfigurator", + "props": { + "language": "json" + } + }, + "description": { + "zh_CN": "折线图配置" + }, + "labelPosition": "left" + } + ] + } + ], + "events": { + "onChange": { + "label": { + "zh_CN": "值改变时触发" + }, + "description": { + "zh_CN": "在 Input 值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框改变后的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onInput": { + "label": { + "zh_CN": "输入值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框输入的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onUpdate:modelValue": { + "label": { + "zh_CN": "双向绑定的值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "双向绑定的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + } + }, + "slots": { + "prefix": { + "label": { + "zh_CN": "前置内容" + } + }, + "suffix": { + "label": { + "zh_CN": "后置内容" + } + } + } + }, + "configure": { + "loop": true, + "condition": true, + "styles": true, + "isContainer": false, + "isModal": false, + "nestingRule": { + "childWhitelist": "", + "parentWhitelist": "", + "descendantBlacklist": "", + "ancestorWhitelist": "" + }, + "isNullNode": false, + "isLayout": false, + "rootSelector": "", + "shortcuts": { + "properties": [] + }, + "contextMenu": { + "actions": ["create symbol"], + "disable": ["copy", "remove"] + } + } + }, + { + "version": "3.22.0", + "name": { + "zh_CN": "柱状图" + }, + "component": "TinyHuichartsHistogram", + "icon": "bar", + "description": "柱状图", + "docUrl": "", + "screenshot": "", + "tags": "", + "keywords": "", + "devMode": "proCode", + "npm": { + "destructuring": true, + "exportName": "TinyHuichartsHistogram", + "name": "TinyVueHuicharts组件库", + "package": "@opentiny/vue-huicharts", + "version": "3.22.0", + "script": "https://registry.npmmirror.com/@opentiny/vue-runtime/3.22/files/dist3/tiny-vue-huicharts.mjs" + }, + "group": "chart", + "category": "图表组件", + "priority": 2, + "schema": { + "properties": [ + { + "label": { + "zh_CN": "基础信息" + }, + "description": { + "zh_CN": "基础信息" + }, + "content": [ + { + "property": "options", + "label": { + "text": { + "zh_CN": "图表配置" + } + }, + "required": true, + "readOnly": false, + "disabled": false, + "cols": 12, + "widget": { + "component": "CodeConfigurator", + "props": { + "language": "json" + } + }, + "description": { + "zh_CN": "柱状图配置" + }, + "labelPosition": "left" + } + ] + } + ], + "events": { + "onChange": { + "label": { + "zh_CN": "值改变时触发" + }, + "description": { + "zh_CN": "在 Input 值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框改变后的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onInput": { + "label": { + "zh_CN": "输入值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框输入的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onUpdate:modelValue": { + "label": { + "zh_CN": "双向绑定的值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "双向绑定的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + } + }, + "slots": { + "prefix": { + "label": { + "zh_CN": "前置内容" + } + }, + "suffix": { + "label": { + "zh_CN": "后置内容" + } + } + } + }, + "configure": { + "loop": true, + "condition": true, + "styles": true, + "isContainer": false, + "isModal": false, + "nestingRule": { + "childWhitelist": "", + "parentWhitelist": "", + "descendantBlacklist": "", + "ancestorWhitelist": "" + }, + "isNullNode": false, + "isLayout": false, + "rootSelector": "", + "shortcuts": { + "properties": [] + }, + "contextMenu": { + "actions": ["create symbol"], + "disable": ["copy", "remove"] + } + } + }, + { + "version": "3.22.0", + "name": { + "zh_CN": "圆盘图" + }, + "component": "TinyHuichartsPie", + "icon": "pie", + "description": "圆盘图", + "docUrl": "", + "screenshot": "", + "tags": "", + "keywords": "", + "devMode": "proCode", + "npm": { + "destructuring": true, + "exportName": "TinyHuichartsPie", + "name": "TinyVueHuicharts组件库", + "package": "@opentiny/vue-huicharts", + "version": "3.22.0", + "script": "https://registry.npmmirror.com/@opentiny/vue-runtime/3.22/files/dist3/tiny-vue-huicharts.mjs" + }, + "group": "chart", + "category": "图表组件", + "priority": 2, + "schema": { + "properties": [ + { + "label": { + "zh_CN": "基础信息" + }, + "description": { + "zh_CN": "基础信息" + }, + "content": [ + { + "property": "options", + "label": { + "text": { + "zh_CN": "图表配置" + } + }, + "required": true, + "readOnly": false, + "disabled": false, + "cols": 12, + "widget": { + "component": "CodeConfigurator", + "props": { + "language": "json" + } + }, + "description": { + "zh_CN": "圆盘图配置" + }, + "labelPosition": "left" + } + ] + } + ], + "events": { + "onChange": { + "label": { + "zh_CN": "值改变时触发" + }, + "description": { + "zh_CN": "在 Input 值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框改变后的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onInput": { + "label": { + "zh_CN": "输入值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "输入框输入的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + }, + "onUpdate:modelValue": { + "label": { + "zh_CN": "双向绑定的值改变时触发" + }, + "description": { + "zh_CN": "在 Input 输入值改变时触发" + }, + "type": "event", + "functionInfo": { + "params": [ + { + "name": "value", + "type": "string", + "defaultValue": "", + "description": { + "zh_CN": "双向绑定的值" + } + } + ], + "returns": {} + }, + "defaultValue": "" + } + }, + "slots": { + "prefix": { + "label": { + "zh_CN": "前置内容" + } + }, + "suffix": { + "label": { + "zh_CN": "后置内容" + } + } + } + }, + "configure": { + "loop": true, + "condition": true, + "styles": true, + "isContainer": false, + "isModal": false, + "nestingRule": { + "childWhitelist": "", + "parentWhitelist": "", + "descendantBlacklist": "", + "ancestorWhitelist": "" + }, + "isNullNode": false, + "isLayout": false, + "rootSelector": "", + "shortcuts": { + "properties": [] + }, + "contextMenu": { + "actions": ["create symbol"], + "disable": ["copy", "remove"] + } + } + }, { "id": 1, "version": "2.4.2", @@ -14743,6 +15244,135 @@ } ] }, + { + "group": "chart", + "label": { + "zh_CN": "图表类型" + }, + "children": [ + { + "name": { + "zh_CN": "折线图" + }, + "icon": "line", + "screenshot": "", + "snippetName": "TinyHuichartsLine", + "schema": { + "componentName": "TinyHuichartsLine", + "props": { + "options": { + "theme": "hdesign-light", + "padding": [50, 30, 50, 20], + "legend": { + "show": true, + "icon": "line" + }, + "data": [ + { "Month": "Jan", "Domestics": 33, "Abroad": 37 }, + { "Month": "Feb", "Domestics": 27, "Abroad": 39 }, + { "Month": "Mar", "Domestics": 31, "Abroad": 20 }, + { "Month": "Apr", "Domestics": 30, "Abroad": 15 }, + { "Month": "May", "Domestics": 37, "Abroad": 13 }, + { "Month": "Jun", "Domestics": 36, "Abroad": 17 }, + { "Month": "Jul", "Domestics": 42, "Abroad": 22 }, + { "Month": "Aug", "Domestics": 22, "Abroad": 12 }, + { "Month": "Sep", "Domestics": 17, "Abroad": 30 }, + { "Month": "Oct", "Domestics": 40, "Abroad": 33 }, + { "Month": "Nov", "Domestics": 42, "Abroad": 22 }, + { "Month": "Dec", "Domestics": 32, "Abroad": 11 } + ], + "xAxis": { + "data": "Month" + }, + "yAxis": { + "name": "Percentage(%)" + } + } + } + } + }, + { + "name": { + "zh_CN": "柱状图" + }, + "icon": "bar", + "screenshot": "", + "snippetName": "TinyHuichartsHistogram", + "schema": { + "componentName": "TinyHuichartsHistogram", + "props": { + "options": { + "theme": "hdesign-light", + "padding": [50, 30, 50, 20], + "data": [ + { "Month": "Jan", "Domestic": 33, "Abroad": 1 }, + { "Month": "Feb", "Domestic": 27, "Abroad": 39 }, + { "Month": "Mar", "Domestic": 31, "Abroad": 20 }, + { "Month": "Apr", "Domestic": 30, "Abroad": 15 }, + { "Month": "May", "Domestic": 37, "Abroad": 1 }, + { "Month": "Jun", "Domestic": 36, "Abroad": 17 }, + { "Month": "Jul", "Domestic": 42, "Abroad": 22 }, + { "Month": "Aug", "Domestic": 22, "Abroad": 12 }, + { "Month": "Sep", "Domestic": 17, "Abroad": 30 }, + { "Month": "Oct", "Domestic": 40, "Abroad": 33 }, + { "Month": "Nov", "Domestic": 42, "Abroad": 22 }, + { "Month": "Dec", "Domestic": 32, "Abroad": 1 } + ], + "xAxis": { + "data": "Month" + }, + "yAxis": { + "name": "Percentage(%)" + } + } + } + } + }, + { + "name": { + "zh_CN": "圆盘图" + }, + "icon": "pie", + "screenshot": "", + "snippetName": "TinyHuichartsPie", + "schema": { + "componentName": "TinyHuichartsPie", + "props": { + "options": { + "theme": "hdesign-light", + "label": { + "show": true, + "line": true, + "labelHtml": "{a|}{b|{b}:}{c|{d}%}", + "rich": { + "a": { + "width": 12, + "height": 12, + "backgroundColor": { + "image": "./image/charts/pie/ic_jiantou_hong.svg" + } + }, + "b": { + "padding": [2, 4, 0, 0] + }, + "c": { + "fontWeight": "bold", + "padding": [2, 0, 0, 0] + } + } + }, + "data": [ + { "value": 100, "name": "VPC" }, + { "value": 90, "name": "IM" }, + { "value": 49, "name": "EIP" }, + { "value": 14, "name": "SG" } + ] + } + } + } + } + ] + }, { "group": "element-plus", "label": { @@ -14920,6 +15550,13 @@ } ], "packages": [ + { + "name": "TinyVueHuicharts组件库", + "package": "@opentiny/vue-huicharts", + "version": "3.22.0", + "destructuring": true, + "script": "https://registry.npmmirror.com/@opentiny/vue-runtime/3.22/files/dist3/tiny-vue-huicharts.mjs" + }, { "name": "TinyVue组件库", "package": "@opentiny/vue", 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 96b7617b9b..870bd4326c 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 @@ -2057,6 +2057,27 @@ "destructuring": true, "version": "2.4.2" }, + { + "componentName": "TinyHuichartsLine", + "package": "@opentiny/vue-huicharts", + "exportName": "TinyHuichartsLine", + "destructuring": true, + "version": "3.22.0" + }, + { + "componentName": "TinyHuichartsHistogram", + "package": "@opentiny/vue-huicharts", + "exportName": "TinyHuichartsHistogram", + "destructuring": true, + "version": "3.22.0" + }, + { + "componentName": "TinyHuichartsPie", + "package": "@opentiny/vue-huicharts", + "exportName": "TinyHuichartsPie", + "destructuring": true, + "version": "3.22.0" + }, { "componentName": "PortalHome", "main": "common/components/home", diff --git a/packages/canvas/DesignCanvas/src/DesignCanvas.vue b/packages/canvas/DesignCanvas/src/DesignCanvas.vue index 9a112f672e..d865509252 100644 --- a/packages/canvas/DesignCanvas/src/DesignCanvas.vue +++ b/packages/canvas/DesignCanvas/src/DesignCanvas.vue @@ -87,6 +87,9 @@ export default { footData.value = useCanvas().getNodePath(node?.id) pageState.currentSchema = {} pageState.properties = null + // 删除节点后,重置pageState中组件的属性 + // 后续需要改造 + useProperties().getProps(null, null) } const isBlock = useCanvas().isBlock @@ -106,9 +109,9 @@ export default { empty: () => '应用下暂无页面,需新建页面后体验画布功能', release: (type) => `当前${componentType[type]}未锁定,点击右上角 “锁定” 图标后编辑${componentType[type]}`, lock: (type) => - `当前${componentType[type]}被 ${pageInfo?.username || ''} 锁定,如需编辑请先联系他解锁文件,然后再锁定该${ + `当前${componentType[type]}被 ${pageInfo?.username || ''} 锁定,您可以创建新页面,如需编辑请先联系他解锁${ componentType[type] - }后编辑!` + },然后再锁定该${componentType[type]}后编辑!` } const renderMsg = message[pageStatus.state](pageSchema.componentName) diff --git a/packages/canvas/container/src/components/CanvasAction.vue b/packages/canvas/container/src/components/CanvasAction.vue index d8fd76ce71..9df3bc0cac 100644 --- a/packages/canvas/container/src/components/CanvasAction.vue +++ b/packages/canvas/container/src/components/CanvasAction.vue @@ -251,7 +251,12 @@ export default { } const hide = () => { - getRenderer().setCondition(getCurrent().schema?.id, false) + if (getCurrent().schema?.id) { + const { clearSelect } = useCanvas().canvasApi.value + getRenderer().setCondition(getCurrent().schema.id, false) + useCanvas().pageState.nodesStatus[getCurrent().schema.id] = false + clearSelect() + } updateRect() } diff --git a/packages/canvas/container/src/container.ts b/packages/canvas/container/src/container.ts index f81e18444a..fecf997f32 100644 --- a/packages/canvas/container/src/container.ts +++ b/packages/canvas/container/src/container.ts @@ -466,6 +466,34 @@ const setSelectRect = ( ) } +const getElementDurationTime = (elementId?: string) => { + const element = elementId ? querySelectById(elementId) : getDocument().body + const transitionDuration = window.getComputedStyle(element).getPropertyValue('transition-duration') + const transitionDelay = window.getComputedStyle(element).getPropertyValue('transition-delay') + let delayTime = 0 + const getMaxMillisecondNumber = (arr: string[]) => { + const millisecondNumber = arr.map((item) => { + if (item.endsWith('ms')) { + return parseFloat(item) + } else { + return parseFloat(item) * 1000 + } + }) + return millisecondNumber.length ? Math.max(...millisecondNumber) : 0 + } + if (transitionDuration) { + const transitionDurations = transitionDuration.split(',') + delayTime += getMaxMillisecondNumber(transitionDurations) + } + + if (transitionDelay) { + const transitionDelays = transitionDelay.split(',') + delayTime += getMaxMillisecondNumber(transitionDelays) + } + + return delayTime +} + export const updateRect = (id?: string) => { id = (typeof id === 'string' && id) || getCurrent().schema?.id clearHover() @@ -481,7 +509,9 @@ export const updateRect = (id?: string) => { const isBodySelected = !selectState.componentName && selectState.width > 0 if (id || isBodySelected) { - setTimeout(() => setSelectRect(id)) + // 获取元素动画持续时间 + const waitTime = getElementDurationTime(id) + setTimeout(() => setSelectRect(id), waitTime) } else { clearSelect() } @@ -816,7 +846,6 @@ export const dragMove = (event: DragEvent, isHover: boolean) => { // type == clickTree, 为点击大纲; type == loop-id=xxx ,为点击循环数据 export const selectNode = async (id: string, type?: string, isMultiple = false) => { const { node } = useCanvas().getNodeWithParentById(id) || {} - let element = querySelectById(id) if (element && node) { @@ -825,7 +854,6 @@ export const selectNode = async (id: string, type?: string, isMultiple = false) } const nodeIsSelected = setSelectRect(id, element, { isMultiple, type, schema: node }) - // 执行setSelectRect之后再去判断multiSelectedStates的长度 if (multiSelectedStates.value.length === 1) { const { schema: node, parent, type } = multiSelectedStates.value[0] @@ -851,6 +879,7 @@ export const selectNode = async (id: string, type?: string, isMultiple = false) if (multiSelectedStates.value.length === 1) { const { schema: node, parent, type, id } = multiSelectedStates.value[0] canvasState.emit('selected', node, parent, type, id) + return node } else { canvasState.emit('selected') diff --git a/packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue b/packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue index c50a8d1488..489892c7a2 100644 --- a/packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue +++ b/packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue @@ -1,7 +1,7 @@