Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
e651dffa2b | |
![]() |
91d3ae108c | |
![]() |
277be2f11e | |
![]() |
2c478ce391 | |
![]() |
c341f4c2c5 | |
![]() |
858e178af6 |
|
@ -1974,6 +1974,48 @@
|
|||
"destructuring": true,
|
||||
"version": "0.1.16"
|
||||
},
|
||||
{
|
||||
"componentName": "ElInput",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElInput",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "ElButton",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElButton",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "ElForm",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElForm",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "ElFormItem",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElFormItem",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "ElTable",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElTable",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "ElTableColumn",
|
||||
"package": "element-plus",
|
||||
"exportName": "ElTableColumn",
|
||||
"destructuring": true,
|
||||
"version": "2.4.2"
|
||||
},
|
||||
{
|
||||
"componentName": "PortalHome",
|
||||
"main": "common/components/home",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="head-content">
|
||||
<meta-input v-model="state.text" type="textarea" @change="change"></meta-input>
|
||||
<meta-input v-model="state.text" type="textarea" @update:modelValue="change"></meta-input>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
|
|
@ -69,7 +69,6 @@ import { ref, watch } from 'vue'
|
|||
import { Collapse, CollapseItem, Input } from '@opentiny/vue'
|
||||
import { useHistory, useCanvas, useProperties } from '@opentiny/tiny-engine-controller'
|
||||
import { MetaCodeEditor, MetaBindVariable } from '@opentiny/tiny-engine-common'
|
||||
import { formatString } from '@opentiny/tiny-engine-controller/js/ast'
|
||||
import {
|
||||
SizeGroup,
|
||||
LayoutGroup,
|
||||
|
@ -128,7 +127,7 @@ export default {
|
|||
const { getSchema: getCanvasPageSchema, updateRect } = useCanvas().canvasApi.value
|
||||
const pageSchema = getCanvasPageSchema()
|
||||
const schema = getSchema() || pageSchema
|
||||
const styleString = formatString(styleStrRemoveRoot(content), 'css')
|
||||
const styleString = styleStrRemoveRoot(content)
|
||||
const currentSchema = getCurrentSchema() || pageSchema
|
||||
|
||||
state.styleContent = content
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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}"`
|
||||
}
|
||||
|
|
|
@ -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} }
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export { testState } from './testState'
|
|
@ -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
|
||||
}
|
||||
}
|
||||
})
|
|
@ -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',
|
||||
|
|
|
@ -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')
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"componentName": "TinyTree",
|
||||
"exportName": "Tree",
|
||||
"package": "@opentiny/vue",
|
||||
"version": "^3.10.0",
|
||||
"destructuring": true
|
||||
}
|
||||
]
|
|
@ -0,0 +1,54 @@
|
|||
<template>
|
||||
<div>
|
||||
<tiny-tree
|
||||
: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' }] }
|
||||
]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<template #default="{ data }">
|
||||
<span>{{ data.label }}</span></template
|
||||
></tiny-tree
|
||||
>
|
||||
<tiny-tree
|
||||
: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' }] }
|
||||
]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<template #default="data">
|
||||
<span>{{ data.label }}</span></template
|
||||
></tiny-tree
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Tree as TinyTree } from '@opentiny/vue'
|
||||
import * as vue from 'vue'
|
||||
import { defineProps, defineEmits } from 'vue'
|
||||
import { I18nInjectionKey } from 'vue-i18n'
|
||||
|
||||
const props = defineProps({})
|
||||
|
||||
const emit = defineEmits([])
|
||||
const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode()
|
||||
const wrap = lowcodeWrap(props, { emit })
|
||||
wrap({ stores })
|
||||
|
||||
const state = vue.reactive({})
|
||||
wrap({ state })
|
||||
</script>
|
||||
<style scoped></style>
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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: {
|
||||
|
|
|
@ -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('物料资产包构建成功')
|
||||
|
|
Loading…
Reference in New Issue