-{{props.data}}
+
+
组件选择
+
+
+
+
属性列表:
+
+
+ {{ (item.label || item.key.slice(1)) + ': ' }}
+
+
+ {{ (item.label || item.key) + ': ' }}
+
+
\ No newline at end of file
diff --git a/activity-page-editor/src/components/Render.vue b/activity-page-editor/src/components/Render.vue
index c13acc3..50ae5ea 100644
--- a/activity-page-editor/src/components/Render.vue
+++ b/activity-page-editor/src/components/Render.vue
@@ -27,19 +27,30 @@ export default {
components: {
Blank
},
- mounted: function () {
- let js = factory(this.schema)
- .replace(/\"vue\"/g, '"/node_modules/.vite/deps/vue.js"')
- // TODO:找了2个小时,没找到更优化的办法办法~
- js += `;\n window.__render__(__default__)`
- const script = document.createElement('script')
- script.type = 'module'
- script.innerHTML = js
- window.__render__ = (Component) => {
- this.$.components.Current = Component
- this.current = 'Current'
+ watch: {
+ schema: {
+ handler(value) {
+ if (this.script) {
+ document.body.removeChild(this.script)
+ this.script = null
+ this.current = 'Blank'
+ }
+
+ let js = factory(value)
+ .replace(/\"vue\"/g, '"/node_modules/.vite/deps/vue.js"')
+ // TODO:找了2个小时,没找到更优化的办法办法~
+ js += `;\n window.__render__(__default__)`
+ const script = this.script = document.createElement('script')
+ script.type = 'module'
+ script.innerHTML = js
+ window.__render__ = (Component) => {
+ this.$.components.Current = Component
+ this.current = 'Current'
+ }
+ document.body.appendChild(script)
+ },
+ immediate: true
}
- document.body.appendChild(script)
}
}
diff --git a/activity-page-editor/yarn.lock b/activity-page-editor/yarn.lock
index 613f7f2..03bb004 100644
--- a/activity-page-editor/yarn.lock
+++ b/activity-page-editor/yarn.lock
@@ -7,6 +7,50 @@
"resolved" "https://registry.npmjs.org/@babel/parser/-/parser-7.18.11.tgz"
"version" "7.18.11"
+"@ctrl/tinycolor@^3.4.1":
+ "integrity" "sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw=="
+ "resolved" "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz"
+ "version" "3.4.1"
+
+"@element-plus/icons-vue@^2.0.6":
+ "integrity" "sha512-okdrwiVeKBmW41Hkl0eMrXDjzJwhQMuKiBOu17rOszqM+LS/yBYpNQNV5Jvoh06Wc+89fMmb/uhzf8NZuDuUaQ=="
+ "resolved" "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.0.9.tgz"
+ "version" "2.0.9"
+
+"@floating-ui/core@^0.7.3":
+ "integrity" "sha512-buc8BXHmG9l82+OQXOFU3Kr2XQx9ys01U/Q9HMIrZ300iLc8HLMgh7dcCqgYzAzf4BkoQvDcXf5Y+CuEZ5JBYg=="
+ "resolved" "https://registry.npmjs.org/@floating-ui/core/-/core-0.7.3.tgz"
+ "version" "0.7.3"
+
+"@floating-ui/dom@^0.5.4":
+ "integrity" "sha512-419BMceRLq0RrmTSDxn8hf9R3VCJv2K9PUfugh5JyEFmdjzDo+e8U5EdR8nzKq8Yj1htzLm3b6eQEEam3/rrtg=="
+ "resolved" "https://registry.npmjs.org/@floating-ui/dom/-/dom-0.5.4.tgz"
+ "version" "0.5.4"
+ dependencies:
+ "@floating-ui/core" "^0.7.3"
+
+"@popperjs/core@npm:@sxzz/popperjs-es@^2.11.7":
+ "integrity" "sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ=="
+ "resolved" "https://registry.npmjs.org/@sxzz/popperjs-es/-/popperjs-es-2.11.7.tgz"
+ "version" "2.11.7"
+
+"@types/lodash-es@*", "@types/lodash-es@^4.17.6":
+ "integrity" "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg=="
+ "resolved" "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz"
+ "version" "4.17.6"
+ dependencies:
+ "@types/lodash" "*"
+
+"@types/lodash@*", "@types/lodash@^4.14.182":
+ "integrity" "sha512-RoZphVtHbxPZizt4IcILciSWiC6dcn+eZ8oX9IWEYfDMcocdd42f7NPI6fQj+6zI8y4E0L7gu2pcZKLGTRaV9Q=="
+ "resolved" "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.184.tgz"
+ "version" "4.14.184"
+
+"@types/web-bluetooth@^0.0.15":
+ "integrity" "sha512-w7hEHXnPMEZ+4nGKl/KDRVpxkwYxYExuHOYXyzIzCDzEZ9ZCGMAewulr9IqJu2LR4N37fcnb1XVeuZ09qgOxhA=="
+ "resolved" "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.15.tgz"
+ "version" "0.0.15"
+
"@vitejs/plugin-vue@^3.0.1":
"integrity" "sha512-U4zNBlz9mg+TA+i+5QPc3N5lQvdUXENZLO2h0Wdzp56gI1MWhqJOv+6R+d4kOzoaSSq6TnGPBdZAXKOe4lXy6g=="
"resolved" "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-3.0.3.tgz"
@@ -102,17 +146,70 @@
"resolved" "https://registry.npmjs.org/@vue/shared/-/shared-3.2.37.tgz"
"version" "3.2.37"
+"@vueuse/core@^9.1.0":
+ "integrity" "sha512-BIroqvXEqt826aE9r3K5cox1zobuPuAzdYJ36kouC2TVhlXvFKIILgFVWrpp9HZPwB3aLzasmG3K87q7TSyXZg=="
+ "resolved" "https://registry.npmjs.org/@vueuse/core/-/core-9.1.0.tgz"
+ "version" "9.1.0"
+ dependencies:
+ "@types/web-bluetooth" "^0.0.15"
+ "@vueuse/metadata" "9.1.0"
+ "@vueuse/shared" "9.1.0"
+ "vue-demi" "*"
+
+"@vueuse/metadata@9.1.0":
+ "integrity" "sha512-8OEhlog1iaAGTD3LICZ8oBGQdYeMwByvXetOtAOZCJOzyCRSwqwdggTsmVZZ1rkgYIEqgUBk942AsAPwM21s6A=="
+ "resolved" "https://registry.npmjs.org/@vueuse/metadata/-/metadata-9.1.0.tgz"
+ "version" "9.1.0"
+
+"@vueuse/shared@9.1.0":
+ "integrity" "sha512-pB/3njQu4tfJJ78ajELNda0yMG6lKfpToQW7Soe09CprF1k3QuyoNi1tBNvo75wBDJWD+LOnr+c4B5HZ39jY/Q=="
+ "resolved" "https://registry.npmjs.org/@vueuse/shared/-/shared-9.1.0.tgz"
+ "version" "9.1.0"
+ dependencies:
+ "vue-demi" "*"
+
+"async-validator@^4.2.5":
+ "integrity" "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
+ "resolved" "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz"
+ "version" "4.2.5"
+
"csstype@^2.6.8":
"integrity" "sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA=="
"resolved" "https://registry.npmjs.org/csstype/-/csstype-2.6.20.tgz"
"version" "2.6.20"
+"dayjs@^1.11.3":
+ "integrity" "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA=="
+ "resolved" "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz"
+ "version" "1.11.5"
+
"element-factory@../element-factory/":
"resolved" "file:../element-factory"
"version" "0.0.1"
dependencies:
"@vue/compiler-sfc" "^3.2.37"
+"element-plus@^2.2.14":
+ "integrity" "sha512-V5Pis0OHhePg1RgVogZrcefaVl8vjVn4Pn9Qsh/t2CbFgjg9kKOYFqf/tuP3ObSXGm3X89hpe0W+nLVAsaFnpw=="
+ "resolved" "https://registry.npmjs.org/element-plus/-/element-plus-2.2.14.tgz"
+ "version" "2.2.14"
+ dependencies:
+ "@ctrl/tinycolor" "^3.4.1"
+ "@element-plus/icons-vue" "^2.0.6"
+ "@floating-ui/dom" "^0.5.4"
+ "@popperjs/core" "npm:@sxzz/popperjs-es@^2.11.7"
+ "@types/lodash" "^4.14.182"
+ "@types/lodash-es" "^4.17.6"
+ "@vueuse/core" "^9.1.0"
+ "async-validator" "^4.2.5"
+ "dayjs" "^1.11.3"
+ "escape-html" "^1.0.3"
+ "lodash" "^4.17.21"
+ "lodash-es" "^4.17.21"
+ "lodash-unified" "^1.0.2"
+ "memoize-one" "^6.0.0"
+ "normalize-wheel-es" "^1.2.0"
+
"esbuild-darwin-64@0.14.54":
"integrity" "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug=="
"resolved" "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz"
@@ -145,6 +242,11 @@
"esbuild-windows-64" "0.14.54"
"esbuild-windows-arm64" "0.14.54"
+"escape-html@^1.0.3":
+ "integrity" "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
+ "resolved" "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz"
+ "version" "1.0.3"
+
"estree-walker@^2.0.2":
"integrity" "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
"resolved" "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz"
@@ -174,6 +276,21 @@
dependencies:
"has" "^1.0.3"
+"lodash-es@*", "lodash-es@^4.17.21":
+ "integrity" "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
+ "resolved" "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz"
+ "version" "4.17.21"
+
+"lodash-unified@^1.0.2":
+ "integrity" "sha512-OGbEy+1P+UT26CYi4opY4gebD8cWRDxAT6MAObIVQMiqYdxZr1g3QHWCToVsm31x2NkLS4K3+MC2qInaRMa39g=="
+ "resolved" "https://registry.npmjs.org/lodash-unified/-/lodash-unified-1.0.2.tgz"
+ "version" "1.0.2"
+
+"lodash@*", "lodash@^4.17.21":
+ "integrity" "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ "resolved" "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
+ "version" "4.17.21"
+
"magic-string@^0.25.7":
"integrity" "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ=="
"resolved" "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz"
@@ -181,11 +298,21 @@
dependencies:
"sourcemap-codec" "^1.4.8"
+"memoize-one@^6.0.0":
+ "integrity" "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw=="
+ "resolved" "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz"
+ "version" "6.0.0"
+
"nanoid@^3.3.4":
"integrity" "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw=="
"resolved" "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz"
"version" "3.3.4"
+"normalize-wheel-es@^1.2.0":
+ "integrity" "sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw=="
+ "resolved" "https://registry.npmjs.org/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz"
+ "version" "1.2.0"
+
"path-parse@^1.0.7":
"integrity" "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
"resolved" "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz"
@@ -253,7 +380,12 @@
optionalDependencies:
"fsevents" "~2.3.2"
-"vue@^3.2.25", "vue@^3.2.37", "vue@3.2.37":
+"vue-demi@*":
+ "integrity" "sha512-Vy1zbZhCOdsmvGR6tJhAvO5vhP7eiS8xkbYQSoVa7o6KlIy3W8Rc53ED4qI4qpeRDjv3mLfXSEpYU6Yq4pgXRg=="
+ "resolved" "https://registry.npmjs.org/vue-demi/-/vue-demi-0.13.8.tgz"
+ "version" "0.13.8"
+
+"vue@^3.0.0-0 || ^2.6.0", "vue@^3.2.0", "vue@^3.2.25", "vue@^3.2.37", "vue@3.2.37":
"integrity" "sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ=="
"resolved" "https://registry.npmjs.org/vue/-/vue-3.2.37.tgz"
"version" "3.2.37"
diff --git a/element-factory/src/index.mjs b/element-factory/src/index.mjs
index 325e71e..cc0da3c 100644
--- a/element-factory/src/index.mjs
+++ b/element-factory/src/index.mjs
@@ -1,12 +1,12 @@
import { parse, compileScript, compileTemplate } from '@vue/compiler-sfc'
import Generator from './generator.mjs'
-export default (code, options = {}) => {
+export function sfc(code, options = {}) {
const parsed = parse(`
${code}`)
// console.log(parsed)
const ast = parsed.descriptor.template.ast
const generator = new Generator(ast, options)
- const newParsed = parse(`
+ return `
@@ -21,7 +21,10 @@ export default {
${code}
-`)
+`
+}
+export default (code, options = {}) => {
+ const newParsed = parse(sfc(code, options))
const ret = compileScript(newParsed.descriptor, {
id: 'abc',
inlineTemplate: true