From 277be2f11e0ca4ba8df9b7d60b20fa7598d1f7f3 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:06:11 -0700 Subject: [PATCH 01/40] fix(vue-generator): fix globalstate codegen error (#547) --- packages/vue-generator/package.json | 2 +- .../src/plugins/genGlobalState.js | 10 ++--- .../expected/appdemo01/src/stores/index.js | 1 + .../appdemo01/src/stores/testState.js | 27 +++++++++++++ .../test/testcases/generator/mockData.js | 38 ++++++++++++++++++- 5 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/testState.js diff --git a/packages/vue-generator/package.json b/packages/vue-generator/package.json index 427979437..8db5f80a9 100644 --- a/packages/vue-generator/package.json +++ b/packages/vue-generator/package.json @@ -47,7 +47,7 @@ "fs-extra": "^10.0.1", "prettier": "^2.6.1", "vite": "^4.3.7", - "vite-plugin-static-copy": "^1.0.4", + "vite-plugin-static-copy": "^0.16.0", "vitest": "^1.4.0", "winston": "^3.10.0" }, diff --git a/packages/vue-generator/src/plugins/genGlobalState.js b/packages/vue-generator/src/plugins/genGlobalState.js index 4c640d6a4..324f698a7 100644 --- a/packages/vue-generator/src/plugins/genGlobalState.js +++ b/packages/vue-generator/src/plugins/genGlobalState.js @@ -44,8 +44,8 @@ function genDependenciesPlugin(options = {}) { .map((item) => { let [key, value] = item - if (value === '') { - value = "''" + if (typeof value === 'string') { + value = `'${value}'` } if (value && typeof value === 'object') { @@ -57,19 +57,19 @@ function genDependenciesPlugin(options = {}) { .join(',')} })` const getterExpression = Object.entries(getters) - .filter((item) => item.value?.type === 'JSFunction') + .filter((item) => item[1]?.type === 'JSFunction') .map(([key, value]) => `${key}: ${value.value}`) .join(',') const actionExpressions = Object.entries(actions) - .filter((item) => item.value?.type === 'JSFunction') + .filter((item) => item[1]?.type === 'JSFunction') .map(([key, value]) => `${key}: ${value.value}`) .join(',') const storeFiles = ` ${importStatement} export const ${id} = defineStore({ - id: ${id}, + id: '${id}', state: ${stateExpression}, getters: { ${getterExpression} }, actions: { ${actionExpressions} } diff --git a/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/index.js b/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/index.js index e69de29bb..380fa26bf 100644 --- a/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/index.js +++ b/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/index.js @@ -0,0 +1 @@ +export { testState } from './testState' diff --git a/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/testState.js b/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/testState.js new file mode 100644 index 000000000..c2312435e --- /dev/null +++ b/packages/vue-generator/test/testcases/generator/expected/appdemo01/src/stores/testState.js @@ -0,0 +1,27 @@ +import { defineStore } from 'pinia' +export const testState = defineStore({ + id: 'testState', + state: () => ({ + name: 'testName', + license: '', + age: 18, + food: ['apple', 'orange', 'banana', 19], + desc: { description: 'hello world', money: 100, other: '', rest: ['a', 'b', 'c', 20] } + }), + getters: { + getAge: function getAge() { + return this.age + }, + getName: function getName() { + return this.name + } + }, + actions: { + setAge: function setAge(age) { + this.age = age + }, + setName: function setName(name) { + this.name = name + } + } +}) diff --git a/packages/vue-generator/test/testcases/generator/mockData.js b/packages/vue-generator/test/testcases/generator/mockData.js index 6067bbb55..71bdd356f 100644 --- a/packages/vue-generator/test/testcases/generator/mockData.js +++ b/packages/vue-generator/test/testcases/generator/mockData.js @@ -676,7 +676,43 @@ export const appSchemaDemo01 = { value: 'function dataHanlder(res){\n return res;\n}' } }, - globalState: [], + globalState: [ + { + id: 'testState', + state: { + name: 'testName', + license: '', + age: 18, + food: ['apple', 'orange', 'banana', 19], + desc: { + description: 'hello world', + money: 100, + other: '', + rest: ['a', 'b', 'c', 20] + } + }, + getters: { + getAge: { + type: 'JSFunction', + value: 'function getAge() {\n return this.age \n}' + }, + getName: { + type: 'JSFunction', + value: 'function getName() {\n return this.name \n}' + } + }, + actions: { + setAge: { + type: 'JSFunction', + value: 'function setAge(age) {\n this.age = age; \n}' + }, + setName: { + type: 'JSFunction', + value: 'function setName(name) {\n this.name = name; \n}' + } + } + } + ], utils: [ { name: 'axios', From 91d3ae108c90fc4071ee381105eac6cc0af07b0e Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:03:32 -0700 Subject: [PATCH 02/40] fix(material): add componentsMap to app Schema after material build (#527) --- scripts/buildMaterials.mjs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/buildMaterials.mjs b/scripts/buildMaterials.mjs index 01e768b19..100636460 100644 --- a/scripts/buildMaterials.mjs +++ b/scripts/buildMaterials.mjs @@ -12,7 +12,10 @@ const materialsDir = 'materials' const bundlePath = path.join(process.cwd(), '/packages/design-core/public/mock/bundle.json') // mockServer应用数据 const appInfoPath = path.join(process.cwd(), '/mockServer/src/services/appinfo.json') +const appSchemaPath = path.join(process.cwd(), 'mockServer/src/mock/get/app-center/v1/apps/schema/918.json') + const appInfo = fsExtra.readJSONSync(appInfoPath) +const appSchema = fsExtra.readJSONSync(appSchemaPath) const connection = new MysqlConnection() @@ -22,6 +25,7 @@ const connection = new MysqlConnection() const write = (bundle) => { fsExtra.outputJSONSync(bundlePath, bundle, { spaces: 2 }) fsExtra.outputJSONSync(appInfoPath, appInfo, { spaces: 2 }) + fsExtra.outputJSONSync(appSchemaPath, appSchema, { spaces: 2 }) } /** @@ -95,6 +99,7 @@ const generateComponents = () => { } const { components = [], snippets = [], blocks = [] } = bundle.data.materials const componentsMap = [] + const packagesMap = [] const appInfoBlocksLabels = appInfo.blockHistories.map((item) => item.label) files.forEach((file) => { @@ -151,8 +156,26 @@ const generateComponents = () => { appInfo.materialHistory.components = componentsMap - write(bundle) + const { package: packageName = '', version = '', exportName = '' } = npm || {} + + const mapItem = { + componentName: component, + package: packageName, + version, + exportName + } + + if (typeof npm.destructuring === 'boolean') { + mapItem.destructuring = npm.destructuring + } + + if (npm.package) { + packagesMap.push(mapItem) + } }) + + appSchema.data.componentsMap = packagesMap + write(bundle) }) logger.success('物料资产包构建成功') From e651dffa2b654ff652405ae5f57cba06b75fe6bd Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Fri, 5 Jul 2024 02:36:09 -0700 Subject: [PATCH 03/40] fix: slot params missing double quote (#605) * fix: slot params missing double quote * fix: exclude nodemodule test case --- .../generator/vue/sfc/generateAttribute.js | 2 +- .../test/testcases/sfc/case06/case06.test.js | 12 ++ .../testcases/sfc/case06/components-map.json | 9 ++ .../sfc/case06/expected/slotTest.vue | 54 +++++++ .../testcases/sfc/case06/page.schema.json | 143 ++++++++++++++++++ packages/vue-generator/vite.config.mjs | 2 +- 6 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 packages/vue-generator/test/testcases/sfc/case06/case06.test.js create mode 100644 packages/vue-generator/test/testcases/sfc/case06/components-map.json create mode 100644 packages/vue-generator/test/testcases/sfc/case06/expected/slotTest.vue create mode 100644 packages/vue-generator/test/testcases/sfc/case06/page.schema.json diff --git a/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js b/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js index 91af6b922..d4d7d0aa2 100644 --- a/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js +++ b/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js @@ -229,7 +229,7 @@ export const handleSlotBindAttrHook = (schemaData) => { let paramsValue = '' if (Array.isArray(params)) { - paramsValue = `={ ${params.join(',')} }` + paramsValue = `="{ ${params.join(',')} }"` } else if (typeof params === 'string') { paramsValue = `="${params}"` } diff --git a/packages/vue-generator/test/testcases/sfc/case06/case06.test.js b/packages/vue-generator/test/testcases/sfc/case06/case06.test.js new file mode 100644 index 000000000..f3df325d0 --- /dev/null +++ b/packages/vue-generator/test/testcases/sfc/case06/case06.test.js @@ -0,0 +1,12 @@ +import { expect, test } from 'vitest' +import { genSFCWithDefaultPlugin } from '@/generator/vue/sfc' +import schema from './page.schema.json' +import componentsMap from './components-map.json' +import { formatCode } from '@/utils/formatCode' + +test('should generate slot declaration correctly', async () => { + const res = genSFCWithDefaultPlugin(schema, componentsMap) + const formattedCode = formatCode(res, 'vue') + + await expect(formattedCode).toMatchFileSnapshot('./expected/slotTest.vue') +}) diff --git a/packages/vue-generator/test/testcases/sfc/case06/components-map.json b/packages/vue-generator/test/testcases/sfc/case06/components-map.json new file mode 100644 index 000000000..eda806752 --- /dev/null +++ b/packages/vue-generator/test/testcases/sfc/case06/components-map.json @@ -0,0 +1,9 @@ +[ + { + "componentName": "TinyTree", + "exportName": "Tree", + "package": "@opentiny/vue", + "version": "^3.10.0", + "destructuring": true + } +] diff --git a/packages/vue-generator/test/testcases/sfc/case06/expected/slotTest.vue b/packages/vue-generator/test/testcases/sfc/case06/expected/slotTest.vue new file mode 100644 index 000000000..a0ce30ad3 --- /dev/null +++ b/packages/vue-generator/test/testcases/sfc/case06/expected/slotTest.vue @@ -0,0 +1,54 @@ + + + + diff --git a/packages/vue-generator/test/testcases/sfc/case06/page.schema.json b/packages/vue-generator/test/testcases/sfc/case06/page.schema.json new file mode 100644 index 000000000..7b5ec4ff0 --- /dev/null +++ b/packages/vue-generator/test/testcases/sfc/case06/page.schema.json @@ -0,0 +1,143 @@ +{ + "state": {}, + "methods": {}, + "componentName": "Page", + "fileName": "createVm", + "css": "", + "props": {}, + "lifeCycles": {}, + "children": [ + { + "componentName": "TinyTree", + "props": { + "data": [ + { + "label": "一级 1", + "children": [ + { + "label": "二级 1-1", + "children": [ + { + "label": "三级 1-1-1" + } + ] + } + ] + }, + { + "label": "一级 2", + "children": [ + { + "label": "二级 2-1", + "children": [ + { + "label": "三级 2-1-1" + } + ] + }, + { + "label": "二级 2-2", + "children": [ + { + "label": "三级 2-2-1" + } + ] + } + ] + } + ] + }, + "id": "33f52342", + "children": [ + { + "componentName": "Template", + "props": { + "slot": { + "name": "default", + "params": ["data"] + } + }, + "children": [ + { + "componentName": "Text", + "props": { + "text": { + "type": "JSExpression", + "value": "data.label" + } + }, + "id": "c225d165" + } + ], + "id": "415d5f65" + } + ] + }, + { + "componentName": "TinyTree", + "props": { + "data": [ + { + "label": "一级 1", + "children": [ + { + "label": "二级 1-1", + "children": [ + { + "label": "三级 1-1-1" + } + ] + } + ] + }, + { + "label": "一级 2", + "children": [ + { + "label": "二级 2-1", + "children": [ + { + "label": "三级 2-1-1" + } + ] + }, + { + "label": "二级 2-2", + "children": [ + { + "label": "三级 2-2-1" + } + ] + } + ] + } + ] + }, + "id": "33f52342", + "children": [ + { + "componentName": "Template", + "props": { + "slot": { + "name": "default", + "params": "data" + } + }, + "children": [ + { + "componentName": "Text", + "props": { + "text": { + "type": "JSExpression", + "value": "data.label" + } + }, + "id": "c225d165" + } + ], + "id": "415d5f65" + } + ] + } + ] +} diff --git a/packages/vue-generator/vite.config.mjs b/packages/vue-generator/vite.config.mjs index 60005cb53..3c1256679 100644 --- a/packages/vue-generator/vite.config.mjs +++ b/packages/vue-generator/vite.config.mjs @@ -17,7 +17,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy' // https://vitejs.dev/config/ export default defineConfig({ test: { - exclude: ['**/result/**'], + exclude: ['**/result/**', 'node_modules'], watchExclude: ['**/result/**'] }, resolve: { From 66268d3ec36d03018c00232df8b9c98cd24834ac Mon Sep 17 00:00:00 2001 From: yeser <631300329@qq.com> Date: Fri, 19 Jul 2024 17:45:52 +0800 Subject: [PATCH 04/40] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DonMouseover?= =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF=20(#662)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/canvas/src/components/render/render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/canvas/src/components/render/render.js b/packages/canvas/src/components/render/render.js index 0dbcf8b12..4277f059b 100644 --- a/packages/canvas/src/components/render/render.js +++ b/packages/canvas/src/components/render/render.js @@ -558,7 +558,7 @@ const getBindProps = (schema, scope) => { ...parseData(schema.props, scope), [DESIGN_UIDKEY]: id, [DESIGN_TAGKEY]: componentName, - onMoseover: stopEvent, + onMouseover: stopEvent, onFocus: stopEvent } if (scope) { From 2c27f9141a9aec2246278912b302ba6746b65161 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Sun, 21 Jul 2024 19:55:37 -0700 Subject: [PATCH 05/40] fix: esbuild install failed on node v16 (#668) * fix: esbuild install failed on nodev16 * fix: esbuild install failed on nodev16 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8586040b0..228895296 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "buildMaterials": "node ./scripts/buildMaterials.mjs" }, "devDependencies": { + "esbuild": "^0.21.5", "@babel/eslint-parser": "^7.21.3", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@esbuild-plugins/node-modules-polyfill": "^0.2.2", From 732bed97955c0db8ba5aa8c1d117ef2132929a53 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:17:17 -0700 Subject: [PATCH 06/40] fix: builtin components can't generate import statement with genSFCWithDefaultPlugin method (#656) --- packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js b/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js index 2e04f7b13..29d07a55d 100644 --- a/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js +++ b/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js @@ -1,3 +1,4 @@ +import { BUILTIN_COMPONENTS_MAP } from '@/constant' import { getImportMap } from './parseImport' import { genTemplateByHook, @@ -259,7 +260,10 @@ export const genSFCWithDefaultPlugin = (schema, componentsMap, config = {}) => { } } - return generateSFCFile(schema, componentsMap, newConfig) + // 兼容单独调用的场景,单独调用时,这里会默认加上 builtInComponents + const compsMapWithBuiltIn = [...componentsMap, ...BUILTIN_COMPONENTS_MAP] + + return generateSFCFile(schema, compsMapWithBuiltIn, newConfig) } export default generateSFCFile From fec563dda35c416b0001a72149937add50874027 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Mon, 22 Jul 2024 01:14:26 -0700 Subject: [PATCH 07/40] fix: esbuild install failed on nodev16 (#671) * fix: esbuild install failed on nodev16 * fix: esbuild install failed on nodev16 * fix: remove deps on root pkg.json --- package.json | 3 --- packages/design-core/package.json | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 228895296..87392ddb0 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,7 @@ "buildMaterials": "node ./scripts/buildMaterials.mjs" }, "devDependencies": { - "esbuild": "^0.21.5", "@babel/eslint-parser": "^7.21.3", - "@esbuild-plugins/node-globals-polyfill": "^0.2.3", - "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "@types/node": "^18.0.0", "@vitejs/plugin-vue": "^4.2.3", "@vitejs/plugin-vue-jsx": "^3.1.0", diff --git a/packages/design-core/package.json b/packages/design-core/package.json index 0c6a1234d..41fe12f7f 100644 --- a/packages/design-core/package.json +++ b/packages/design-core/package.json @@ -107,6 +107,7 @@ "assert": "^2.0.0", "buffer": "^6.0.3", "cross-env": "^7.0.3", + "esbuild": "^0.21.5", "esbuild-plugin-copy": "^2.1.1", "eslint": "^8.38.0", "eslint-plugin-vue": "^8.0.0", From fd164a1cd22bb4f60ca988ccc553639f3f0524b6 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Mon, 22 Jul 2024 01:28:30 -0700 Subject: [PATCH 08/40] fix(preview): multiple nested blocks cannot preview #663 (#665) --- .../design-core/src/preview/src/preview/Preview.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/design-core/src/preview/src/preview/Preview.vue b/packages/design-core/src/preview/src/preview/Preview.vue index 04f797bb0..3a16bb278 100644 --- a/packages/design-core/src/preview/src/preview/Preview.vue +++ b/packages/design-core/src/preview/src/preview/Preview.vue @@ -86,11 +86,17 @@ export default { .map((name) => fetchBlockSchema(name)) const schemaList = await Promise.allSettled(promiseList) + const extraList = [] schemaList.forEach((item) => { if (item.status === 'fulfilled' && item.value?.[0]?.content) { res.push(item.value[0].content) - res.push(...getBlocksSchema(item.value[0].content, blockSet)) + extraList.push(getBlocksSchema(item.value[0].content, blockSet)) + } + }) + ;(await Promise.allSettled(extraList)).forEach((item) => { + if (item.status === 'fulfilled' && item.value) { + res.push(...item.value) } }) @@ -136,11 +142,10 @@ export default { }, ...(blocks || []).map((blockSchema) => { return { - panelName: blockSchema.fileName, + panelName: `${blockSchema.fileName}.vue`, panelValue: genSFCWithDefaultPlugin(blockSchema, appData?.componentsMap || [], { blockRelativePath: './' }) || '', - panelType: 'vue', - index: true + panelType: 'vue' } }) ] From a383421c38498c7f78e49343c69e4db689bf615c Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Tue, 23 Jul 2024 04:10:35 -0700 Subject: [PATCH 09/40] fix(material): add missing componentsMap to mockServer (#701) --- .../get/app-center/v1/apps/schema/918.json | 35 +++++++++++++++++++ packages/design-core/public/mock/bundle.json | 32 ++++++++--------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/mockServer/src/mock/get/app-center/v1/apps/schema/918.json b/mockServer/src/mock/get/app-center/v1/apps/schema/918.json index e5351b18e..17656258e 100644 --- a/mockServer/src/mock/get/app-center/v1/apps/schema/918.json +++ b/mockServer/src/mock/get/app-center/v1/apps/schema/918.json @@ -1918,6 +1918,13 @@ "destructuring": true, "version": "0.1.17" }, + { + "componentName": "TinyCheckbox", + "package": "@opentiny/vue", + "exportName": "Checkbox", + "destructuring": true, + "version": "3.14.0" + }, { "componentName": "TinySelect", "package": "@opentiny/vue", @@ -1974,6 +1981,34 @@ "destructuring": true, "version": "0.1.16" }, + { + "componentName": "TinyCollapse", + "package": "@opentiny/vue", + "exportName": "Collapse", + "destructuring": true, + "version": "3.14.0" + }, + { + "componentName": "TinyCollapseItem", + "package": "@opentiny/vue", + "exportName": "CollapseItem", + "destructuring": true, + "version": "3.14.0" + }, + { + "componentName": "TinyBreadcrumb", + "package": "@opentiny/vue", + "exportName": "Breadcrumb", + "destructuring": true, + "version": "3.14.0" + }, + { + "componentName": "TinyBreadcrumbItem", + "package": "@opentiny/vue", + "exportName": "BreadcrumbItem", + "destructuring": true, + "version": "3.14.0" + }, { "componentName": "ElInput", "package": "element-plus", diff --git a/packages/design-core/public/mock/bundle.json b/packages/design-core/public/mock/bundle.json index 2fa58678f..6a45e5dd0 100644 --- a/packages/design-core/public/mock/bundle.json +++ b/packages/design-core/public/mock/bundle.json @@ -23,7 +23,8 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, - "exportName": "ElInput" + "exportName": "ElInput", + "destructuring": true }, "group": "表单组件", "category": "element-plus", @@ -303,7 +304,8 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, - "exportName": "ElButton" + "exportName": "ElButton", + "destructuring": true }, "group": "基础组件", "category": "element-plus", @@ -624,6 +626,7 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, + "destructuring": true, "exportName": "ElForm" }, "group": "表单组件", @@ -1081,6 +1084,7 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, + "destructuring": true, "exportName": "ElFormItem" }, "group": "表单组件", @@ -1431,6 +1435,7 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, + "destructuring": true, "exportName": "ElTable" }, "group": "数据展示", @@ -2669,6 +2674,7 @@ "script": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.full.mjs", "css": "https://npm.onmicrosoft.cn/element-plus@2.4.2/dist/index.css", "dependencies": null, + "destructuring": true, "exportName": "ElTableColumn" }, "group": "表单组件", @@ -8901,7 +8907,7 @@ "devMode": "proCode", "npm": { "package": "@opentiny/vue", - "exportName": "Select", + "exportName": "Breadcrumb", "version": "", "destructuring": true }, @@ -14007,20 +14013,10 @@ "schema": { "componentName": "TinyBreadcrumb", "props": { - "options": [ - { - "to": "{ path: '/' }", - "label": "首页" - }, - { - "to": "{ path: '/breadcrumb' }", - "label": "产品" - }, - { - "replace": "true", - "label": "软件" - } - ] + "options": { + "type": "JSExpression", + "value": "[{to: { path: '/' },label: '首页'},{to: { path: '/breadcrumb' },label: '产品'},{'replace': true,'label': '软件'}]" + } } } }, @@ -14275,7 +14271,7 @@ "schema": { "componentName": "TinyTimeLine", "props": { - "active": "2", + "active": 2, "data": [ { "name": "已下单" From 0d36f2d34409173731a8a1a7620ca91cc94eea83 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Sun, 28 Jul 2024 23:36:18 -0700 Subject: [PATCH 10/40] fix(setting): fix bindEvent dialog visible can't work on tinyvue 3.17 (#715) --- packages/settings/events/src/components/BindEventsDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/settings/events/src/components/BindEventsDialog.vue b/packages/settings/events/src/components/BindEventsDialog.vue index e7fbc838e..079f2e8d2 100644 --- a/packages/settings/events/src/components/BindEventsDialog.vue +++ b/packages/settings/events/src/components/BindEventsDialog.vue @@ -1,6 +1,6 @@ @@ -43,7 +43,7 @@
- {{ action.eventName }}{{ state.componentEvents[action.eventName].label.zh_CN }} + {{ action.eventName }}{{ renderEventList[action.eventName]?.label?.[locale] }}
{{ action.linkedEventName }}
{{ action.ref }} @@ -78,7 +78,7 @@ @@ -88,6 +88,7 @@ import { computed, reactive, watchEffect } from 'vue' import { Popover, Button } from '@opentiny/vue' import { useCanvas, useModal, useLayout, useBlock, useResource } from '@opentiny/tiny-engine-controller' +import i18n from '@opentiny/tiny-engine-controller/js/i18n' import { BlockLinkEvent, SvgButton } from '@opentiny/tiny-engine-common' import { iconHelpQuery, iconChevronDown } from '@opentiny/vue-icon' import BindEventsDialog, { open as openDialog } from './BindEventsDialog.vue' @@ -112,6 +113,7 @@ export default { const { getBlockEvents, getCurrentBlock, removeEventLink } = useBlock() const { getMaterial } = useResource() const { confirm } = useModal() + const locale = i18n.global.locale.value const { highlightMethod } = getPluginApi(PLUGIN_NAME.PageController) @@ -119,25 +121,25 @@ export default { eventName: '', // 事件名称 eventBinding: null, // 事件绑定的处理方法对象 componentEvent: {}, - componentEvents: commonEvents, + customEvents: commonEvents, bindActions: {}, showBindEventDialog: false }) const isBlock = computed(() => Boolean(pageState.isBlock)) const isEmpty = computed(() => Object.keys(state.bindActions).length === 0) + const renderEventList = computed(() => ({ ...state.componentEvent, ...state.customEvents })) watchEffect(() => { const componentName = pageState?.currentSchema?.componentName const componentSchema = getMaterial(componentName) state.componentEvent = componentSchema?.content?.schema?.events || componentSchema?.schema?.events || {} - Object.assign(state.componentEvents, state.componentEvent) const props = pageState?.currentSchema?.props || {} const keys = Object.keys(props) state.bindActions = {} // 遍历组件事件元数据 - Object.entries(state.componentEvents).forEach(([eventName, componentEvent]) => { + Object.entries(renderEventList.value).forEach(([eventName, componentEvent]) => { // 查找组件已添加的事件 if (keys.indexOf(eventName) > -1) { const event = props[eventName] @@ -225,7 +227,7 @@ export default { const handleAddEvent = (params) => { const { eventName, eventDescription } = params - Object.assign(state.componentEvents, { + Object.assign(state.customEvents, { [eventName]: { label: { zh_CN: eventDescription @@ -253,7 +255,9 @@ export default { openCodePanel, openActionDialog, handleAddEvent, - handleToggleAddEventDialog + handleToggleAddEventDialog, + renderEventList, + locale } } } From eda10e58c847d571282889888e79b9b2a607ffcb Mon Sep 17 00:00:00 2001 From: tianxin <146069396+ianxinnew@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:37:06 +0800 Subject: [PATCH 26/40] fix:batch delete unintelligent (#795) --- packages/plugins/datasource/src/DataSourceRecordList.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugins/datasource/src/DataSourceRecordList.vue b/packages/plugins/datasource/src/DataSourceRecordList.vue index 90685d17d..88f46960c 100644 --- a/packages/plugins/datasource/src/DataSourceRecordList.vue +++ b/packages/plugins/datasource/src/DataSourceRecordList.vue @@ -489,6 +489,7 @@ export default { grid.value.removeSelecteds() state.totalData = state.totalData.filter(({ _id }) => !selectedData.includes(_id)) fetchData() + state.isBatchDeleteDisable = true } }) } From 0935220b77fef1a5d46e4f7f0f585a4ab33f93ba Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Fri, 27 Sep 2024 23:42:09 -0700 Subject: [PATCH 27/40] fix: mock block data response data missing data attribute (#818) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 mockService 区块详情缺失 data 嵌套结构导致无法正确加载的 bug --- mockServer/src/services/block.js | 3 ++- packages/controller/src/useResource.js | 2 +- packages/plugins/block/src/Main.vue | 7 ++++--- packages/plugins/block/src/js/blockSetting.jsx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mockServer/src/services/block.js b/mockServer/src/services/block.js index c8071fe10..f29c00ad6 100644 --- a/mockServer/src/services/block.js +++ b/mockServer/src/services/block.js @@ -72,7 +72,8 @@ export default class BlockService { async detail(blockId) { const result = await this.db.findOneAsync({ _id: blockId }) - return result + + return getResponseData(result) } async delete(blockId) { diff --git a/packages/controller/src/useResource.js b/packages/controller/src/useResource.js index 5df4dfa8d..b3d3afd98 100644 --- a/packages/controller/src/useResource.js +++ b/packages/controller/src/useResource.js @@ -293,7 +293,7 @@ const initBlock = async (blockId) => { const blockApi = getPluginApi(PLUGIN_NAME.BlockManage) const blockContent = await blockApi.getBlockById(blockId) - if (blockContent.public_scope_tenants.length) { + if (blockContent?.public_scope_tenants?.length) { blockContent.public_scope_tenants = blockContent.public_scope_tenants.map((e) => e.id) } diff --git a/packages/plugins/block/src/Main.vue b/packages/plugins/block/src/Main.vue index 337f756f1..f9b5cc35d 100644 --- a/packages/plugins/block/src/Main.vue +++ b/packages/plugins/block/src/Main.vue @@ -276,10 +276,11 @@ export default { boxVisibility.value = false } const editBlock = async (block) => { - const isEdite = true + const isEdit = true + if (isSaved()) { await refreshBlockData(block) - useBlock().initBlock(block, {}, isEdite) + useBlock().initBlock(block, {}, isEdit) useLayout().closePlugin() closePanel() const url = new URL(window.location) @@ -291,7 +292,7 @@ export default { message: '当前画布内容尚未保存,是否要继续切换?', exec: async () => { await refreshBlockData(block) - useBlock().initBlock(block, {}, isEdite) + useBlock().initBlock(block, {}, isEdit) useLayout().closePlugin() closePanel() } diff --git a/packages/plugins/block/src/js/blockSetting.jsx b/packages/plugins/block/src/js/blockSetting.jsx index 98680f88c..230072c1f 100644 --- a/packages/plugins/block/src/js/blockSetting.jsx +++ b/packages/plugins/block/src/js/blockSetting.jsx @@ -432,7 +432,7 @@ export const refreshBlockData = async (block = {}) => { const newBlock = await fetchBlockContent(block.id) if (newBlock) { - if (newBlock.public_scope_tenants.length) { + if (newBlock?.public_scope_tenants?.length) { newBlock.public_scope_tenants = newBlock.public_scope_tenants.map((e) => e.id) } Object.assign(block, newBlock) From b72e7ea5e79f06bdf27619bc5bdc25a387b1b335 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Fri, 27 Sep 2024 23:59:30 -0700 Subject: [PATCH 28/40] fix: page or block save update breadcrumb incorrectly (#820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: page or block save update breadcrumb uncorrectly 1. 修复页面名称更新时,面包屑页名称没有同步更新的 bug 2. 修复区块保存更新时,强行切换当前画布到正在编辑区块的 bug 3. 修复区块保存更新时,如果画布不是当前编辑的区块,仍取截图的 bug * fix: add handlePageUpdate mehtod missing params --- packages/controller/js/http.js | 13 +++++++++---- packages/plugins/block/src/BlockSetting.vue | 9 ++++++--- packages/plugins/block/src/js/blockSetting.jsx | 9 ++++++++- packages/plugins/page/src/PageSetting.vue | 3 ++- packages/toolbars/save/src/js/index.js | 2 +- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/controller/js/http.js b/packages/controller/js/http.js index c3315a066..2ca39fe30 100644 --- a/packages/controller/js/http.js +++ b/packages/controller/js/http.js @@ -14,6 +14,7 @@ import { useHttp } from '@opentiny/tiny-engine-http' import usePage from '../src/usePage' import useCanvas from '../src/useCanvas' import useNotify from '../src/useNotify' +import useBreadcrumb from '../src/useBreadcrumb' import { isVsCodeEnv } from './environments' import { generateRouter, generatePage } from './vscodeGenerateFile' @@ -39,7 +40,7 @@ export const requestEvent = (url, params) => { * @returns { Promise } * */ -export const handlePageUpdate = (pageId, params, routerChange) => { +export const handlePageUpdate = (pageId, params, routerChange, isCurEditPage) => { return http .post(`/app-center/api/pages/update/${pageId}`, params) .then((res) => { @@ -60,14 +61,18 @@ export const handlePageUpdate = (pageId, params, routerChange) => { } } - if (routerChange) { - pageSettingState.updateTreeData() - } + pageSettingState.updateTreeData() pageSettingState.isNew = false useNotify({ message: '保存成功!', type: 'success' }) // 更新 页面状态 标志 setSaved(true) + + if (isCurEditPage) { + const { setBreadcrumbPage } = useBreadcrumb() + setBreadcrumbPage([params.name]) + } + return res }) .catch((err) => { diff --git a/packages/plugins/block/src/BlockSetting.vue b/packages/plugins/block/src/BlockSetting.vue index 3dc43e94b..8180127b9 100644 --- a/packages/plugins/block/src/BlockSetting.vue +++ b/packages/plugins/block/src/BlockSetting.vue @@ -78,7 +78,7 @@