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 @@
+
+
+
+
+ {{ data.label }}
+
+
+ {{ data.label }}
+
+
+
+
+
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 @@
Date: Tue, 6 Aug 2024 14:54:32 +0800
Subject: [PATCH 11/40] feat(download-code): support download zip for not
support browsers (#703)
* feat(download-code): support download zip for not support browsers
* feat(download-code): support download zip for not support browsers - review
* feat(download-code): support download zip for not support browsers - review
---
packages/design-core/package.json | 1 -
packages/utils/package.json | 4 +-
packages/utils/src/fs/fszip.js | 67 +++++++++++++++++++++++++++++++
packages/utils/src/fs/index.js | 45 +++++++++++++++------
4 files changed, 102 insertions(+), 15 deletions(-)
create mode 100644 packages/utils/src/fs/fszip.js
diff --git a/packages/design-core/package.json b/packages/design-core/package.json
index 41fe12f7f..8294b9030 100644
--- a/packages/design-core/package.json
+++ b/packages/design-core/package.json
@@ -89,7 +89,6 @@
"eslint-linter-browserify": "8.57.0",
"file-saver": "^2.0.5",
"html2canvas": "^1.4.1",
- "jszip": "^3.10.1",
"monaco-editor": "0.33.0",
"prettier": "2.7.1",
"sortablejs": "^1.14.0",
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 1e19faed8..afebc991b 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -30,7 +30,9 @@
"vite": "^4.3.7",
"vitest": "^1.4.0"
},
- "dependencies": {},
+ "dependencies": {
+ "jszip": "^3.10.1"
+ },
"peerDependencies": {
"@opentiny/vue-renderless": "^3.14.0",
"vue": "^3.4.15"
diff --git a/packages/utils/src/fs/fszip.js b/packages/utils/src/fs/fszip.js
new file mode 100644
index 000000000..4efca735d
--- /dev/null
+++ b/packages/utils/src/fs/fszip.js
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2023 - present TinyEngine Authors.
+ * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
+ *
+ * Use of this source code is governed by an MIT-style license.
+ *
+ * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
+ * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
+ * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
+ *
+ */
+
+// browser File System Access API encapsulation
+import JSZIP from 'jszip'
+
+/**
+ * 下载文件到本地
+ * @param {Blob} blobData 文件二进制数据
+ * @param {string} fileName 文件名
+ */
+export function saveAs(blobData, fileName) {
+ const zipLink = document.createElement('a')
+ zipLink.download = fileName
+ zipLink.style.display = 'none'
+ zipLink.href = URL.createObjectURL(blobData)
+ document.body.appendChild(zipLink)
+ zipLink.click()
+ document.body.removeChild(zipLink)
+}
+
+/**
+ * 创建一个zip
+ */
+export const createZip = () => {
+ return new JSZIP()
+}
+
+/**
+ * 往zip里面写入文件夹和文件
+ * @param {Array} filesInfo 文件信息
+ * FileInfo.filePath 文件相对路径,以'/'相连
+ * FileInfo.fileContent 文件内容
+ * @param {ZipExtraInfo} ZipExtraInfo zip额外信息
+ * {string} zipName 打出来的zip名称
+ * {JSZIP} zipHandle 创建好的zip句柄,可以不传,不传就用新的
+ */
+export const writeZip = (filesInfo, { zipHandle, zipName } = {}) => {
+ let zip = zipHandle
+ if (!zipHandle) {
+ zip = createZip()
+ }
+ filesInfo.forEach(({ filePath, fileContent }) => {
+ const file = filePath.split('/')
+ const fileName = file.pop()
+ const path = file.join('/')
+ if (path) {
+ zip.folder(path).file(fileName, fileContent)
+ } else {
+ zip.file(fileName, fileContent)
+ }
+ })
+ // 把打包的内容异步转成blob二进制格式
+ return zip.generateAsync({ type: 'blob' }).then((content) => {
+ // content就是blob数据
+ saveAs(content, `${zipName}.zip`)
+ })
+}
diff --git a/packages/utils/src/fs/index.js b/packages/utils/src/fs/index.js
index 2cb2bf54a..26b5656ea 100644
--- a/packages/utils/src/fs/index.js
+++ b/packages/utils/src/fs/index.js
@@ -1,17 +1,23 @@
/**
-* Copyright (c) 2023 - present TinyEngine Authors.
-* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
-*
-* Use of this source code is governed by an MIT-style license.
-*
-* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
-* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
-* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
-*
-*/
+ * Copyright (c) 2023 - present TinyEngine Authors.
+ * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
+ *
+ * Use of this source code is governed by an MIT-style license.
+ *
+ * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
+ * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
+ * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
+ *
+ */
// browser File System Access API encapsulation
+import { createZip, writeZip } from './fszip'
+
+// 支持file system api的条件:存在这个方法 && 不处于iframe中
+export const isSupportFileSystemAccess =
+ Object.prototype.hasOwnProperty.call(window, 'showDirectoryPicker') && window.self === window.top
+
/**
* 获取用户选择并授权的文件夹根路径
* @param {*} options
@@ -20,7 +26,7 @@
*/
export const getUserBaseDirHandle = async (options = {}) => {
if (!window.showOpenFilePicker) {
- throw new Error('不支持的浏览器!')
+ return createZip()
}
const dirHandle = await window.showDirectoryPicker({ mode: 'readwrite', ...options })
return dirHandle
@@ -166,16 +172,29 @@ export const writeFile = async (handle, { filePath, fileContent }) => {
* @param {Array} filesInfo 文件信息
* FileInfo.filePath 文件相对路径
* FileInfo.fileContent 文件内容
+ * @param {Boolean} supportZipCache 是否支持zip缓存,zip缓存可能会导致文件不能及时更新,默认不缓存
+ *
*/
-export const writeFiles = async (baseDirHandle, filesInfo) => {
+export const writeFiles = async (
+ baseDirHandle,
+ filesInfo,
+ zipName = 'tiny-engine-generate-code',
+ supportZipCache = false
+) => {
if (!filesInfo?.length) {
return
}
+ if (!isSupportFileSystemAccess) {
+ const zipInfo = { zipName, zipHandle: supportZipCache && baseDirHandle }
+ await writeZip(filesInfo, zipInfo)
+ return
+ }
+
let directoryHandle = baseDirHandle
if (!directoryHandle) {
directoryHandle = await window.showDirectoryPicker({ mode: 'readwrite' })
}
- await Promise.all(filesInfo.map((fileInfo) => writeFile(baseDirHandle, fileInfo)))
+ await Promise.all(filesInfo.map((fileInfo) => writeFile(directoryHandle, fileInfo)))
}
From a442108e2b279a7c34f791342b2aa6afe842db36 Mon Sep 17 00:00:00 2001
From: Hexqi
Date: Wed, 7 Aug 2024 09:42:28 +0800
Subject: [PATCH 12/40] docs: update milestone (#728)
* docs: update milestone
* fix: tab
---
README.md | 6 +++---
README.zh-CN.md | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 57af470d1..37515208c 100644
--- a/README.md
+++ b/README.md
@@ -88,9 +88,9 @@ gantt
dateFormat YYYY-MM-DD
axisFormat %Y-%m-%d
- 1.0.0-beta.x version :active,2023-09-25, 2024-03-31
- 1.0.0-rc version : 2024-04-01, 2024-06-30
- 1.0.0 version : 2024-07-01, 2024-07-31
+1.0.0-beta.x version : 2023-09-25, 2024-05-20
+1.0.0-rc version(refactor version) : 2024-10-01
+1.0.0 version : 2024-11-01
```
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 747f286c8..636ad668c 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -84,13 +84,13 @@ pnpm run build:alpha 或 build:prod
## 里程碑
```mermaid
-gantt
+gantt
dateFormat YYYY-MM-DD
axisFormat %Y-%m-%d
- 1.0.0-beta.x version :active,2023-09-25, 2024-03-31
- 1.0.0-rc version : 2024-04-01, 2024-06-30
- 1.0.0 version : 2024-07-01, 2024-07-31
+1.0.0-beta.x version : 2023-09-25, 2024-05-20
+1.0.0-rc version(refactor version) : 2024-10-01
+1.0.0 version : 2024-11-01
```
From 1ed91983b0d352b0d7e23a0fd70fca45c2002939 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Tue, 13 Aug 2024 10:14:56 +0800
Subject: [PATCH 13/40] fix: abaolute canvas init inlineStyle should be string
(#730)
---
packages/canvas/src/components/container/container.js | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/packages/canvas/src/components/container/container.js b/packages/canvas/src/components/container/container.js
index 333db29a8..89e6c3c8a 100644
--- a/packages/canvas/src/components/container/container.js
+++ b/packages/canvas/src/components/container/container.js
@@ -716,11 +716,7 @@ export const onMouseUp = () => {
if (absolute) {
targetNode.node = getSchema()
data.props = data.props || {}
- data.props.style = {
- position: 'absolute',
- top: dragState.mouse.y + 'px',
- left: dragState.mouse.x + 'px'
- }
+ data.props.style = `position: absolute; top: ${dragState.mouse.y}px; left: ${dragState.mouse.x}px`
}
insertNode(targetNode, position)
From 59eaf035bbb6117c46747ac6a09aa1d18d55eac3 Mon Sep 17 00:00:00 2001
From: wenmine
Date: Fri, 16 Aug 2024 10:30:47 +0800
Subject: [PATCH 14/40] fix(download): Optimize download logic and adapt to
iframe (#739)
* fix(download): Optimize download logic and adapt to iframe
---
packages/utils/src/fs/fszip.js | 14 +++++++-------
packages/utils/src/fs/index.js | 6 +++---
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/packages/utils/src/fs/fszip.js b/packages/utils/src/fs/fszip.js
index 4efca735d..d97654081 100644
--- a/packages/utils/src/fs/fszip.js
+++ b/packages/utils/src/fs/fszip.js
@@ -19,13 +19,13 @@ import JSZIP from 'jszip'
* @param {string} fileName 文件名
*/
export function saveAs(blobData, fileName) {
- const zipLink = document.createElement('a')
- zipLink.download = fileName
- zipLink.style.display = 'none'
- zipLink.href = URL.createObjectURL(blobData)
- document.body.appendChild(zipLink)
- zipLink.click()
- document.body.removeChild(zipLink)
+ const downloadLink = document.createElement('a')
+ downloadLink.download = fileName
+ downloadLink.style.display = 'none'
+ downloadLink.href = URL.createObjectURL(blobData)
+ document.body.appendChild(downloadLink)
+ downloadLink.click()
+ document.body.removeChild(downloadLink)
}
/**
diff --git a/packages/utils/src/fs/index.js b/packages/utils/src/fs/index.js
index 26b5656ea..ecf7ecc73 100644
--- a/packages/utils/src/fs/index.js
+++ b/packages/utils/src/fs/index.js
@@ -25,7 +25,7 @@ export const isSupportFileSystemAccess =
* @returns dirHandle 目录句柄
*/
export const getUserBaseDirHandle = async (options = {}) => {
- if (!window.showOpenFilePicker) {
+ if (!isSupportFileSystemAccess) {
return createZip()
}
const dirHandle = await window.showDirectoryPicker({ mode: 'readwrite', ...options })
@@ -81,8 +81,8 @@ export async function getFileHandle(baseDirHandle, filePath, { create = false }
* @returns fileHandle 文件句柄
*/
export const getUserFileHandle = async (options = {}) => {
- if (!window.showOpenFilePicker) {
- throw new Error('不支持的浏览器!')
+ if (!isSupportFileSystemAccess) {
+ throw new Error('不支持的浏览器或处于iframe中')
}
const [fileHandle] = await window.showOpenFilePicker({ mode: 'readwrite', ...options })
return fileHandle
From 871463f1859fb922c4d63099201aec920d191055 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Sat, 24 Aug 2024 20:46:37 +0800
Subject: [PATCH 15/40] feat(cdn): change cdn from onmicrosoft to unpkg (#750)
---
.../vite.config.js | 2 +-
packages/design-core/.env.alpha | 2 +-
packages/design-core/.env.development | 2 +-
packages/design-core/.env.prod | 2 +-
packages/design-core/public/mock/bundle.json | 24 +++++++++----------
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/packages/blockToWebComponentTemplate/vite.config.js b/packages/blockToWebComponentTemplate/vite.config.js
index ddbf655c3..9ad6a1861 100644
--- a/packages/blockToWebComponentTemplate/vite.config.js
+++ b/packages/blockToWebComponentTemplate/vite.config.js
@@ -43,7 +43,7 @@ export default defineConfig(({ command, mode }) => {
}
const vuePluginConfig = {}
- const styleLinks = ['https://npm.onmicrosoft.cn/@opentiny/vue-theme@3.14/index.css']
+ const styleLinks = ['https://unpkg.com/@opentiny/vue-theme@3.14/index.css']
config.publicDir = false
diff --git a/packages/design-core/.env.alpha b/packages/design-core/.env.alpha
index 1816a0471..6cd7ceea6 100644
--- a/packages/design-core/.env.alpha
+++ b/packages/design-core/.env.alpha
@@ -1,7 +1,7 @@
# alpha mode, used by the "build:alpha" script
NODE_ENV=production
-VITE_CDN_DOMAIN=https://npm.onmicrosoft.cn
+VITE_CDN_DOMAIN=https://unpkg.com
VITE_LOCAL_IMPORT_MAPS=false
VITE_LOCAL_BUNDLE_DEPS=false
# VITE_ORIGIN=
diff --git a/packages/design-core/.env.development b/packages/design-core/.env.development
index 98c505478..e02fbee0f 100644
--- a/packages/design-core/.env.development
+++ b/packages/design-core/.env.development
@@ -1,7 +1,7 @@
# development mode, used by the "vite" command
NODE_ENV=development
-VITE_CDN_DOMAIN=https://npm.onmicrosoft.cn
+VITE_CDN_DOMAIN=https://unpkg.com
VITE_LOCAL_IMPORT_MAPS=false
VITE_LOCAL_BUNDLE_DEPS=false
# request data via alpha service
diff --git a/packages/design-core/.env.prod b/packages/design-core/.env.prod
index 04b27fbc3..8768ec32c 100644
--- a/packages/design-core/.env.prod
+++ b/packages/design-core/.env.prod
@@ -1,7 +1,7 @@
# prod mode, used by the "build:prod" script
NODE_ENV=production
-VITE_CDN_DOMAIN=https://npm.onmicrosoft.cn
+VITE_CDN_DOMAIN=https://unpkg.com
VITE_LOCAL_IMPORT_MAPS=false
VITE_LOCAL_BUNDLE_DEPS=false
#VITE_ORIGIN=
diff --git a/packages/design-core/public/mock/bundle.json b/packages/design-core/public/mock/bundle.json
index 6a45e5dd0..1405e91bd 100644
--- a/packages/design-core/public/mock/bundle.json
+++ b/packages/design-core/public/mock/bundle.json
@@ -20,8 +20,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"exportName": "ElInput",
"destructuring": true
@@ -301,8 +301,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"exportName": "ElButton",
"destructuring": true
@@ -623,8 +623,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"destructuring": true,
"exportName": "ElForm"
@@ -1081,8 +1081,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"destructuring": true,
"exportName": "ElFormItem"
@@ -1432,8 +1432,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"destructuring": true,
"exportName": "ElTable"
@@ -2671,8 +2671,8 @@
"npm": {
"package": "element-plus",
"version": "2.4.2",
- "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",
+ "script": "https://unpkg.com/element-plus@2.4.2/dist/index.full.mjs",
+ "css": "https://unpkg.com/element-plus@2.4.2/dist/index.css",
"dependencies": null,
"destructuring": true,
"exportName": "ElTableColumn"
From c2187245436bedace094f6a194d5d919a337e601 Mon Sep 17 00:00:00 2001
From: Gene
Date: Sat, 24 Aug 2024 21:43:53 +0800
Subject: [PATCH 16/40] =?UTF-8?q?fix:=20=E9=9A=90=E8=97=8F=E7=94=BB?=
=?UTF-8?q?=E5=B8=83=E6=A0=B9=E8=8A=82=E7=82=B9=E7=9A=84=E5=8C=85=E8=A3=B9?=
=?UTF-8?q?=E5=85=83=E7=B4=A0=E7=9A=84=E6=93=8D=E4=BD=9C=E9=80=89=E9=A1=B9?=
=?UTF-8?q?=20(#492)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/canvas/src/components/container/CanvasAction.vue | 5 ++++-
packages/canvas/src/components/render/RenderMain.js | 3 ++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/packages/canvas/src/components/container/CanvasAction.vue b/packages/canvas/src/components/container/CanvasAction.vue
index c5d6a66aa..ec2164da0 100644
--- a/packages/canvas/src/components/container/CanvasAction.vue
+++ b/packages/canvas/src/components/container/CanvasAction.vue
@@ -229,7 +229,10 @@ export default {
}
const showAction = computed(() => {
- const { parent } = getCurrent()
+ const { schema, parent } = getCurrent()
+ if (schema?.props?.['data-id'] === 'root-container') {
+ return false
+ }
return !props.resize && parent && parent?.type !== 'JSSlot'
})
diff --git a/packages/canvas/src/components/render/RenderMain.js b/packages/canvas/src/components/render/RenderMain.js
index 6081d487e..93a39622b 100644
--- a/packages/canvas/src/components/render/RenderMain.js
+++ b/packages/canvas/src/components/render/RenderMain.js
@@ -379,7 +379,8 @@ export default {
// 渲染画布增加根节点,与出码和预览保持一致
const rootChildrenSchema = {
componentName: 'div',
- props: schema.props,
+ // 手动添加一个唯一的属性,后续在画布选中此节点时方便处理额外的逻辑。由于没有修改schema,不会影响出码
+ props: { ...schema.props, 'data-id': 'root-container' },
children: schema.children
}
From 76c23b767b8eeb3c6880d29e47f5300f836b7a31 Mon Sep 17 00:00:00 2001
From: yaoyun8 <142570291+yaoyun8@users.noreply.github.com>
Date: Sat, 24 Aug 2024 06:46:45 -0700
Subject: [PATCH 17/40] fix(script): translate log (#549)
* fix: translate log
* Update scripts/connection.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update scripts/connection.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update scripts/connection.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---
scripts/buildMaterials.mjs | 22 +++++++++++-----------
scripts/connection.mjs | 24 ++++++++++++------------
scripts/splitMaterials.mjs | 4 ++--
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/scripts/buildMaterials.mjs b/scripts/buildMaterials.mjs
index 100636460..dd6e4e9f7 100644
--- a/scripts/buildMaterials.mjs
+++ b/scripts/buildMaterials.mjs
@@ -40,13 +40,13 @@ const validateComponent = (file, component) => {
const requiredList = requiredFields.filter((field) => !fields.includes(field))
if (requiredList.length) {
- logger.error(`组件文件 ${file} 缺少必要字段:${requiredList.join('、')}。`)
+ logger.error(`missing required fields: ${requiredList.join(',')} at ${file}.`)
return false
}
if (!component.npm) {
- logger.warn(`组件文件 ${file} 缺少 npm 字段,出码时将不能通过import语句导入组件。`)
+ logger.warn(`missing the \`npm\` field, and it cannot be imported when coding at ${file}.`)
return false
}
@@ -66,7 +66,7 @@ const validateBlock = (file, block) => {
const requiredList = requiredFields.filter((field) => !fields.includes(field))
if (requiredList.length) {
- logger.error(`区块文件 ${file} 缺少必要字段:${requiredList.join('、')}。`)
+ logger.error(`missing required fields: ${requiredList.join(',')} at ${file}.`)
return false
}
@@ -84,7 +84,7 @@ const generateComponents = () => {
try {
fg([`${materialsDir}/**/*.json`]).then((files) => {
if (!files.length) {
- logger.warn('物料文件夹为空,请先执行`pnpm splitMaterials`命令拆分物料资产包')
+ logger.warn('please execute `pnpm splitMaterials` first to split the materials.')
}
const bundle = {
@@ -108,7 +108,7 @@ const generateComponents = () => {
if (!material) {
const fileFullPath = path.join(process.cwd(), file)
- logger.error(`文件格式有误 (${fileFullPath})`)
+ logger.error(`incorrect file format at ${fileFullPath}.`)
return
}
@@ -178,9 +178,9 @@ const generateComponents = () => {
write(bundle)
})
- logger.success('物料资产包构建成功')
+ logger.success('materials built.')
} catch (error) {
- logger.error(`物料资产包构建失败:${error}`)
+ logger.error(`failed to build materials: ${error}.`)
}
}
@@ -189,13 +189,13 @@ const watcher = chokidar.watch(`${materialsDir}/**/*.json`, { ignoreInitial: tru
watcher.on('all', (event, file) => {
const eventMap = {
- add: '新增',
- change: '更新',
- unlink: '删除'
+ add: 'added',
+ change: 'changed',
+ unlink: 'deleted'
}
const fileFullPath = path.join(process.cwd(), file)
- logger.info(`${eventMap[event]}组件文件 (${fileFullPath})`)
+ logger.info(`${fileFullPath} ${eventMap[event]}, rebuilding materials...`)
// 监听物料文件变化,更新物料资产包
generateComponents()
diff --git a/scripts/connection.mjs b/scripts/connection.mjs
index 016f85689..a06c5623e 100644
--- a/scripts/connection.mjs
+++ b/scripts/connection.mjs
@@ -38,10 +38,10 @@ class MysqlConnection {
return new Promise((resolve, reject) => {
this.connection.connect((error) => {
if (error) {
- logger.warn('未能连接到数据库,请查看数据库配置是否正确')
+ logger.warn('unable to connect to the database, please check the database configuration is correct.')
reject()
} else {
- logger.success('数据库连接成功')
+ logger.success('database connected.')
this.connected = true
resolve()
}
@@ -100,11 +100,11 @@ class MysqlConnection {
* @returns boolean 校验组件字段是否失败,false-有字段出错
*/
isValid(component, file) {
- const longtextFields = ['name', 'npm', 'snippets', 'schema_fragment', 'configure', 'component_metadata']
+ const longTextFields = ['name', 'npm', 'snippets', 'schema_fragment', 'configure', 'component_metadata']
return Object.entries(component).every(([key, value]) => {
- if (longtextFields.includes(key) && value !== null && typeof value !== 'object') {
- logger.error(`"${key}" 的值不是有效的JSON (${file})`)
+ if (longTextFields.includes(key) && value !== null && typeof value !== 'object') {
+ logger.error(`the value of "${key}" is not valid JSON at ${file}.`)
return false
}
@@ -193,10 +193,10 @@ class MysqlConnection {
this.query(sqlContent, component.component)
.then(() => {
- logger.success(`组件 ${component.component} 数据更新成功`)
+ logger.success(`${component.component} updated.`)
})
.catch((error) => {
- logger.error(`组件 ${component.component} 数据更新失败 ${error}`)
+ logger.error(`failed to update ${component.component}: ${error}.`)
})
}
@@ -322,11 +322,11 @@ class MysqlConnection {
.then((result) => {
const id = result.insertId
- logger.success(`组件 ${component.component} 数据新增成功`)
+ logger.success(`${component.component} added.`)
this.relationMaterialHistory(id)
})
.catch((error) => {
- logger.success(`组件 ${component.component} 数据新增失败:${error}`)
+ logger.error(`add ${component.component} failed:${error}.`)
})
}
@@ -344,7 +344,7 @@ class MysqlConnection {
}
})
.catch((error) => {
- logger.success(`查询组件 ${component.component} 失败:${error}`)
+ logger.error(`query ${component.component} failed:${error}.`)
})
}
@@ -395,11 +395,11 @@ class MysqlConnection {
return new Promise((resolve, reject) => {
this.query(sqlContent)
.then((result) => {
- logger.success(`表 ${componentsTableName} 创建成功`)
+ logger.success(`table ${componentsTableName} created.`)
resolve(result)
})
.catch((error) => {
- logger.success(`表 ${componentsTableName} 创建失败:${error}`)
+ logger.error(`create table ${componentsTableName} failed:${error}.`)
reject(error)
})
})
diff --git a/scripts/splitMaterials.mjs b/scripts/splitMaterials.mjs
index e81143c0b..867fb73d7 100644
--- a/scripts/splitMaterials.mjs
+++ b/scripts/splitMaterials.mjs
@@ -51,9 +51,9 @@ const splitMaterials = () => {
fs.outputJsonSync(blockPath, block, { spaces: 2 })
})
- logger.success('拆分物料资产包完成')
+ logger.success('materials splitted.')
} catch (error) {
- logger.error(`拆分物料资产包失败: ${error}`)
+ logger.error(`failed to split materials: ${error}.`)
}
}
From c35c34e03672f2e6db0885e2bd0756dc5238d09e Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Tue, 3 Sep 2024 15:02:37 +0800
Subject: [PATCH 18/40] fix: reset spacing cannot generate correct source code
(#657)
---
.../styles/src/components/spacing/SpacingGroup.vue | 2 +-
.../styles/src/components/spacing/SpacingSetting.vue | 10 +++++-----
packages/settings/styles/src/js/parser.js | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/packages/settings/styles/src/components/spacing/SpacingGroup.vue b/packages/settings/styles/src/components/spacing/SpacingGroup.vue
index 9379bcee4..aee7a1792 100644
--- a/packages/settings/styles/src/components/spacing/SpacingGroup.vue
+++ b/packages/settings/styles/src/components/spacing/SpacingGroup.vue
@@ -429,7 +429,7 @@ export default {
properties[name] = {
value,
- text: value === 'auto' ? 'auto' : String(Number.parseInt(value || 0)), // 界面 box 中显示的数值
+ text: value === 'auto' ? 'auto' : String(Number.parseInt(value) || 0), // 界面 box 中显示的数值
setting: Boolean(value) // 属性是否已设置值
}
})
diff --git a/packages/settings/styles/src/components/spacing/SpacingSetting.vue b/packages/settings/styles/src/components/spacing/SpacingSetting.vue
index af11937bd..1e950ae87 100644
--- a/packages/settings/styles/src/components/spacing/SpacingSetting.vue
+++ b/packages/settings/styles/src/components/spacing/SpacingSetting.vue
@@ -61,6 +61,10 @@ export default {
props.property.value?.indexOf('px') > -1 ? Number.parseInt(props.property.value) : props.property.value
)
+ const updateStyle = (value) => {
+ emit('update', { [props.property.name]: value })
+ }
+
const sliderChange = () => {
if (sliderFlag) {
updateStyle(`${sliderValue.value}px`)
@@ -83,11 +87,7 @@ export default {
const reset = () => {
sliderFlag = false
- updateStyle('')
- }
-
- const updateStyle = (value) => {
- emit('update', { [props.property.name]: value })
+ updateStyle(null)
}
const inputChange = (property) => {
diff --git a/packages/settings/styles/src/js/parser.js b/packages/settings/styles/src/js/parser.js
index b56a9f668..ee54e7d82 100644
--- a/packages/settings/styles/src/js/parser.js
+++ b/packages/settings/styles/src/js/parser.js
@@ -231,7 +231,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
if (key.includes('comment')) {
str += `${value.value}\n`
} else {
- str += `${key}: ${value.value};\n`
+ str += `${key}: ${value.value === '' ? "''" : value.value};\n`
}
}
} else {
@@ -249,7 +249,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
// 在 styleObject 的,可能有改动,所以需要用 styleObject 拼接
for (const [key, value] of Object.entries(styleObject[item.selectors].rules)) {
if (![null, undefined].includes(value)) {
- str += `${key}: ${value};\n`
+ str += `${key}: ${value === '' ? "''" : value};\n`
}
}
}
@@ -266,7 +266,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
str += `${selector} {\n`
for (const [declKey, declValue] of Object.entries(value.rules)) {
- str += `${declKey}: ${declValue};\n`
+ str += `${declKey}: ${declValue === '' ? "''" : declValue};\n`
}
str += '}\n'
From 9ccfc9fa8a947710dc17e77485bdc0aa298fd230 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:39:49 -0700
Subject: [PATCH 19/40] fix: jsx slot modelvalue can't update value (#734)
* fix: jsx slot modelvalue can't update value
* fix: add unit test for updateModel event
---
packages/vue-generator/.eslintrc.cjs | 5 +-
.../src/generator/vue/sfc/genSetupSFC.js | 4 +-
.../generator/vue/sfc/generateAttribute.js | 25 +++
.../sfc/slotModelValue/components-map.json | 23 +++
.../expected/slotModelValueTest.vue | 96 +++++++++++
.../sfc/slotModelValue/page.schema.json | 150 ++++++++++++++++++
.../sfc/slotModelValue/slotModel.test.js | 12 ++
7 files changed, 313 insertions(+), 2 deletions(-)
create mode 100644 packages/vue-generator/test/testcases/sfc/slotModelValue/components-map.json
create mode 100644 packages/vue-generator/test/testcases/sfc/slotModelValue/expected/slotModelValueTest.vue
create mode 100644 packages/vue-generator/test/testcases/sfc/slotModelValue/page.schema.json
create mode 100644 packages/vue-generator/test/testcases/sfc/slotModelValue/slotModel.test.js
diff --git a/packages/vue-generator/.eslintrc.cjs b/packages/vue-generator/.eslintrc.cjs
index 0131b38e3..94ab4fed2 100644
--- a/packages/vue-generator/.eslintrc.cjs
+++ b/packages/vue-generator/.eslintrc.cjs
@@ -1,3 +1,5 @@
+const { rules } = require('../../.eslintrc')
+
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
@@ -17,5 +19,6 @@ module.exports = {
}
},
// 忽略 expected 中的内容
- ignorePatterns: ['**/**/expected/*', '**/**.ts']
+ ignorePatterns: ['**/**/expected/*', '**/**.ts'],
+ rules
}
diff --git a/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js b/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js
index 29d07a55d..ff8ac1a53 100644
--- a/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js
+++ b/packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js
@@ -19,7 +19,8 @@ import {
handleI18nAttrHook,
handleObjBindAttrHook,
handleEventAttrHook,
- handleTinyIconPropsHook
+ handleTinyIconPropsHook,
+ handleJsxModelValueUpdate
} from './generateAttribute'
import {
GEN_SCRIPT_HOOKS,
@@ -213,6 +214,7 @@ export const genSFCWithDefaultPlugin = (schema, componentsMap, config = {}) => {
const defaultAttributeHook = [
handleTinyGrid,
+ handleJsxModelValueUpdate,
handleConditionAttrHook,
handleLoopAttrHook,
handleSlotBindAttrHook,
diff --git a/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js b/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js
index d4d7d0aa2..9b623ca76 100644
--- a/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js
+++ b/packages/vue-generator/src/generator/vue/sfc/generateAttribute.js
@@ -515,3 +515,28 @@ export const handleBindUtilsHooks = (schemaData, globalHooks, config) => {
}
})
}
+
+/**
+ * 为 modelvalue 绑定自动生成 onUpdate:modelValue 事件绑定
+ * @param {*} schemaData
+ * @param {*} globalHooks
+ * @param {*} config
+ */
+export const handleJsxModelValueUpdate = (schemaData, globalHooks, config) => {
+ const { schema: { props = {} } = {} } = schemaData || {}
+ const isJSX = config.isJSX
+
+ if (!isJSX) {
+ return
+ }
+
+ const propsEntries = Object.entries(props)
+ const modelValue = propsEntries.find(([_key, value]) => value?.type === JS_EXPRESSION && value?.model === true)
+ const hasUpdateModelValue = propsEntries.find(([key]) => isOn(key) && key.startsWith(`onUpdate:${modelValue?.[0]}`))
+
+ // jsx 形式的 modelvalue, 如果 schema 没有声明,出码需要同时声明 onUpdate:modelValue,否则更新失效
+ if (modelValue && !hasUpdateModelValue) {
+ // 添加 onUpdate:modelKey 事件,让后续钩子生成 对应的事件声明
+ props[`onUpdate:${modelValue?.[0]}`] = { type: JS_EXPRESSION, value: `(value) => ${modelValue[1].value}=value` }
+ }
+}
diff --git a/packages/vue-generator/test/testcases/sfc/slotModelValue/components-map.json b/packages/vue-generator/test/testcases/sfc/slotModelValue/components-map.json
new file mode 100644
index 000000000..88f776526
--- /dev/null
+++ b/packages/vue-generator/test/testcases/sfc/slotModelValue/components-map.json
@@ -0,0 +1,23 @@
+[
+ {
+ "componentName": "TinyGrid",
+ "exportName": "Grid",
+ "package": "@opentiny/vue",
+ "version": "^3.10.0",
+ "destructuring": true
+ },
+ {
+ "componentName": "TinyNumeric",
+ "exportName": "Numeric",
+ "package": "@opentiny/vue",
+ "version": "^3.10.0",
+ "destructuring": true
+ },
+ {
+ "componentName": "TinyInput",
+ "exportName": "Input",
+ "package": "@opentiny/vue",
+ "version": "^3.10.0",
+ "destructuring": true
+ }
+]
diff --git a/packages/vue-generator/test/testcases/sfc/slotModelValue/expected/slotModelValueTest.vue b/packages/vue-generator/test/testcases/sfc/slotModelValue/expected/slotModelValueTest.vue
new file mode 100644
index 000000000..7d5e5f083
--- /dev/null
+++ b/packages/vue-generator/test/testcases/sfc/slotModelValue/expected/slotModelValueTest.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
+
diff --git a/packages/vue-generator/test/testcases/sfc/slotModelValue/page.schema.json b/packages/vue-generator/test/testcases/sfc/slotModelValue/page.schema.json
new file mode 100644
index 000000000..e5da94f0c
--- /dev/null
+++ b/packages/vue-generator/test/testcases/sfc/slotModelValue/page.schema.json
@@ -0,0 +1,150 @@
+{
+ "state": {},
+ "methods": {
+ "onChangeInput": {
+ "type": "JSFunction",
+ "value": "function onChangeInput(eventArgs,args0,args1,args2) {\n console.log('onChangeInput', eventArgs);\n}"
+ },
+ "onChangeNumber": {
+ "type": "JSFunction",
+ "value": "function onChangeNumber(eventArgs, args0, args1, args2) {\n console.log('onChangeNumber', eventArgs)\n}"
+ }
+ },
+ "componentName": "Page",
+ "css": "",
+ "props": {},
+ "lifeCycles": {},
+ "children": [
+ {
+ "componentName": "div",
+ "props": {},
+ "id": "85375559",
+ "children": [
+ {
+ "componentName": "TinyGrid",
+ "props": {
+ "editConfig": {
+ "trigger": "click",
+ "mode": "cell",
+ "showStatus": true
+ },
+ "columns": [
+ {
+ "type": "index",
+ "width": 60
+ },
+ {
+ "type": "selection",
+ "width": 60
+ },
+ {
+ "field": "employees",
+ "title": "员工数",
+ "slots": {
+ "default": {
+ "type": "JSSlot",
+ "value": [
+ {
+ "componentName": "div",
+ "id": "44523622",
+ "children": [
+ {
+ "componentName": "TinyNumeric",
+ "props": {
+ "allow-empty": true,
+ "placeholder": "请输入",
+ "controlsPosition": "right",
+ "step": 1,
+ "modelValue": {
+ "type": "JSExpression",
+ "value": "row.employees",
+ "model": true
+ },
+ "onChange": {
+ "type": "JSExpression",
+ "value": "this.onChangeNumber",
+ "params": ["row", "column", "rowIndex"]
+ }
+ },
+ "id": "62166343"
+ }
+ ]
+ }
+ ],
+ "params": ["row", "column", "rowIndex"]
+ }
+ }
+ },
+ {
+ "field": "created_date",
+ "title": "创建日期"
+ },
+ {
+ "field": "city",
+ "title": "城市",
+ "slots": {
+ "default": {
+ "type": "JSSlot",
+ "value": [
+ {
+ "componentName": "div",
+ "id": "66326314",
+ "children": [
+ {
+ "componentName": "TinyInput",
+ "props": {
+ "placeholder": "请输入",
+ "modelValue": {
+ "type": "JSExpression",
+ "value": "row.city",
+ "model": true
+ },
+ "onChange": {
+ "type": "JSExpression",
+ "value": "this.onChangeInput",
+ "params": ["row", "column", "rowIndex"]
+ }
+ },
+ "id": "22396a2a"
+ }
+ ]
+ }
+ ],
+ "params": ["row", "column", "rowIndex"]
+ }
+ }
+ }
+ ],
+ "data": [
+ {
+ "id": "1",
+ "name": "GFD科技有限公司",
+ "city": "福州",
+ "employees": 800,
+ "created_date": "2014-04-30 00:56:00",
+ "boole": false
+ },
+ {
+ "id": "2",
+ "name": "WWW科技有限公司",
+ "city": "深圳",
+ "employees": 300,
+ "created_date": "2016-07-08 12:36:22",
+ "boole": true
+ }
+ ]
+ },
+ "id": "63623253"
+ }
+ ]
+ }
+ ],
+ "dataSource": {
+ "list": []
+ },
+ "utils": [],
+ "bridge": [],
+ "inputs": [],
+ "outputs": [],
+ "fileName": "slotModelValueTest"
+}
diff --git a/packages/vue-generator/test/testcases/sfc/slotModelValue/slotModel.test.js b/packages/vue-generator/test/testcases/sfc/slotModelValue/slotModel.test.js
new file mode 100644
index 000000000..c1e48b6f0
--- /dev/null
+++ b/packages/vue-generator/test/testcases/sfc/slotModelValue/slotModel.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 onUpdate:modelValue event', async () => {
+ const res = genSFCWithDefaultPlugin(schema, componentsMap)
+ const formattedCode = formatCode(res, 'vue')
+
+ await expect(formattedCode).toMatchFileSnapshot('./expected/slotModelValueTest.vue')
+})
From 50f968f27dfd27c95ef95cbe005614e80d92aebd Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Mon, 9 Sep 2024 19:08:50 -0700
Subject: [PATCH 20/40] fix(canvas): absolute dnd update position to schema.
close #664 (#751)
---
.../src/components/container/container.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/packages/canvas/src/components/container/container.js b/packages/canvas/src/components/container/container.js
index 89e6c3c8a..ac9ccf8b0 100644
--- a/packages/canvas/src/components/container/container.js
+++ b/packages/canvas/src/components/container/container.js
@@ -185,6 +185,8 @@ export const dragEnd = () => {
if (element && canvasState.type === 'absolute') {
data.props = data.props || {}
data.props.style = element.style.cssText
+
+ getController().addHistory()
}
// 重置拖拽状态
@@ -541,6 +543,8 @@ const setHoverRect = (element, data) => {
return undefined
}
+let moveUpdateTimer = null
+
// 绝对布局
const absoluteMove = (event, element) => {
const { clientX, clientY } = event
@@ -572,6 +576,19 @@ const absoluteMove = (event, element) => {
element.style.height = `${clientY - y}px`
}
}
+
+ clearTimeout(moveUpdateTimer)
+
+ const { data } = dragState
+ data.props = data.props || {}
+
+ // 防抖更新位置信息到 schema
+ moveUpdateTimer = setTimeout(() => {
+ data.props.style = element.style.cssText
+
+ getController().addHistory()
+ }, 100)
+
updateRect()
}
From 603be3bdb9ba8741c8eb6299331927fc29ba3fb9 Mon Sep 17 00:00:00 2001
From: bwrong
Date: Wed, 11 Sep 2024 11:06:43 +0800
Subject: [PATCH 21/40] =?UTF-8?q?fix(generate-vue):=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E5=87=BA=E7=A0=81=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9=E7=95=8C?=
=?UTF-8?q?=E9=9D=A2=E6=89=93=E5=8C=85=E5=90=8E=E6=A0=B7=E5=BC=8F=E4=B8=A2?=
=?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98=20(#789)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: wangwenbing <11535041@qq.com>
---
packages/toolbars/generate-vue/vite.config.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/packages/toolbars/generate-vue/vite.config.js b/packages/toolbars/generate-vue/vite.config.js
index 090e11278..6cbf0ad06 100644
--- a/packages/toolbars/generate-vue/vite.config.js
+++ b/packages/toolbars/generate-vue/vite.config.js
@@ -28,6 +28,9 @@ export default defineConfig({
formats: ['es']
},
rollupOptions: {
+ output: {
+ banner: 'import "./style.css"'
+ },
external: ['vue', /@opentiny\/tiny-engine.*/, /@opentiny\/vue.*/, /^prettier.*/]
}
}
From 5fa99f8a8e1f35f4bf08345b452aa2fbf89f9155 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Fri, 13 Sep 2024 01:16:44 -0700
Subject: [PATCH 22/40] fix(stylePanel): fix setting border-radius could not
work on first time (#481)
---
.../src/components/border/BorderGroup.vue | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/packages/settings/styles/src/components/border/BorderGroup.vue b/packages/settings/styles/src/components/border/BorderGroup.vue
index 298ddc78f..901552c13 100644
--- a/packages/settings/styles/src/components/border/BorderGroup.vue
+++ b/packages/settings/styles/src/components/border/BorderGroup.vue
@@ -290,9 +290,7 @@ export default {
const state = reactive({
showModal: false,
activedRadius: RADIUS_SETTING.Single,
- activedBorder: BORDER_SETTING.All,
- // 标记是否从 props 来的更新
- isUpdateFromProps: false
+ activedBorder: BORDER_SETTING.All
})
const { setPosition } = useModal()
@@ -336,12 +334,13 @@ export default {
watch(
() => props.style,
() => {
- state.isUpdateFromProps = true
- borderRadius.BorderRadius = parseInt(props.style.borderRadius || 0)
- borderRadius.BorderTopLeftRadius = parseInt(props.style.borderTopLeftRadius || 0)
- borderRadius.BorderTopRightRadius = parseInt(props.style.borderTopRightRadius || 0)
- borderRadius.BorderBottomLeftRadius = parseInt(props.style.borderBottomLeftRadius || 0)
- borderRadius.BorderBottomRightRadius = parseInt(props.style.borderBottomRightRadius || 0)
+ borderRadius.BorderRadius = parseInt(props.style[BORDER_RADIUS_PROPERTY.BorderRadius] || 0)
+ borderRadius.BorderTopLeftRadius = parseInt(props.style[BORDER_RADIUS_PROPERTY.BorderTopLeftRadius] || 0)
+ borderRadius.BorderTopRightRadius = parseInt(props.style[BORDER_RADIUS_PROPERTY.BorderTopRightRadius] || 0)
+ borderRadius.BorderBottomLeftRadius = parseInt(props.style[BORDER_RADIUS_PROPERTY.BorderBottomLeftRadius] || 0)
+ borderRadius.BorderBottomRightRadius = parseInt(
+ props.style[BORDER_RADIUS_PROPERTY.BorderBottomRightRadius] || 0
+ )
},
{ immediate: true }
)
@@ -386,12 +385,13 @@ export default {
* 1. 用户在 monacoEditor 更新了样式 border-radius: 9px 然后保存,该组件接收并同步改值
* 2. 用户在 monacoEditor 删除了 border-radius: 9px 的样式,然后 watch 函数(props.style),重新计算得到值 0
* 3. 0 更新后,会再触发改函数更新,导致自动加上了 border-radius: 0px 的样式
- * 所以从 props 来的更新不需要再调用一遍 updateStyle(更新 props 数据)
+ * 所以从如果当前值为 0 且 props.style[BORDER_RADIUS_PROPERTY.BorderRadius] 不存在值,不需要触发更新
*/
- if (state.isUpdateFromProps) {
- state.isUpdateFromProps = false
+
+ if (!value && !props.style[BORDER_RADIUS_PROPERTY.BorderRadius]) {
return
}
+
borderRadius.BorderRadius = value
updateStyle({
From 2ce7c4a201e25baa347996afa0fcd5bc6ac11b0b Mon Sep 17 00:00:00 2001
From: Xie Jay
Date: Wed, 18 Sep 2024 11:24:11 +0800
Subject: [PATCH 23/40] fix(common): fix verify required (#787)
---
packages/common/component/ConfigItem.vue | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/packages/common/component/ConfigItem.vue b/packages/common/component/ConfigItem.vue
index c0fd195e7..1f46dc695 100644
--- a/packages/common/component/ConfigItem.vue
+++ b/packages/common/component/ConfigItem.vue
@@ -295,16 +295,13 @@ export default {
result.message = typeof message === 'string' ? message : message?.[locale.value]
}
+ const isEmptyInputValue = (value) => {
+ // 通过 value == null 做隐式类型转换
+ // 空值约定为 undefined | null | ''
+ return value == null || (typeOf(value) === TYPES.StringType && value.trim() === '')
+ }
const verifyRequired = (value) => {
- if (typeOf(value) === TYPES.BooleanType) {
- return true
- }
-
- if (typeOf(value) === TYPES.StringType) {
- return value.trim()
- }
-
- return value
+ return !isEmptyInputValue(value)
}
const verifyValue = (value = '', rules = []) => {
From 3a831bf833829f7e5de4851c4238c4e74402b769 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Mon, 23 Sep 2024 23:37:47 -0700
Subject: [PATCH 24/40] fix: mixed lifeCyclesContent when empty lifecycles
(#810)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
close #806
修复生命周期为空时,取当前页面schema生命周期值的 bug
---
packages/common/component/LifeCycles.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/common/component/LifeCycles.vue b/packages/common/component/LifeCycles.vue
index c7abdcd28..fd8404fd4 100644
--- a/packages/common/component/LifeCycles.vue
+++ b/packages/common/component/LifeCycles.vue
@@ -129,7 +129,7 @@ export default {
})
watchEffect(() => {
- state.bindLifeCycles = props.bindLifeCycles || useCanvas().canvasApi.value?.getSchema()?.lifeCycles || {}
+ state.bindLifeCycles = props.bindLifeCycles || {}
})
const searchLifeCyclesList = (value) => {
From e828de2970ee1858d93b1b6d2e2f430721e47ef6 Mon Sep 17 00:00:00 2001
From: chilingling <26962197+chilingling@users.noreply.github.com>
Date: Tue, 24 Sep 2024 20:03:34 -0700
Subject: [PATCH 25/40] fix: switch selected component event name list still
show the origin one (#757)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: switch selected component event name list still show the origin one
修复画布切换选择组件后,高级面板事件列表仍然显示原组件事件列表的bug
close #747
* fix: handle potential undefined values in renderEventList
* fix: use locale instead of zh_CN attr
---
.../events/src/components/BindEvents.vue | 22 +++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/packages/settings/events/src/components/BindEvents.vue b/packages/settings/events/src/components/BindEvents.vue
index aa8550f25..49ac91904 100644
--- a/packages/settings/events/src/components/BindEvents.vue
+++ b/packages/settings/events/src/components/BindEvents.vue
@@ -28,12 +28,12 @@
@@ -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 @@