Skip to content

Commit

Permalink
fix: README
Browse files Browse the repository at this point in the history
  • Loading branch information
yy-wow committed Nov 11, 2024
1 parent c370fbf commit 0097246
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
41 changes: 29 additions & 12 deletions packages/renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@ A Vue3 renderer for tiny-engine.

```javascript
// xxx.vue
import { h, reactive } from 'vue'
import Main from '@opentiny/tiny-engine-renderer'
import { h } from 'vue'
import Main, { api } from '@opentiny/tiny-engine-renderer'

const getSchema = () => {
return newPromise((resolve) => {
setTimeout(() => {
const data = {
state: {},
children: [
{
componentName: 'Text',
props: {
text: 'Title'
}
}
]
}
resolve(data)
}, 100)
})
}

export default {
render() {
// utils
const utils = reactive({})
// globalState
const globalState = reactive([])
// dataSource
const dataSourceMap = reactive({})
// schema
const schema = reactive({})
setup() {
onMounted(async () => {
const schema = await getSchema()

return schema.children.length ? h(Main, { schema, utils, globalState, dataSourceList }) : null
api.setSchema(schema)
})
},
render() {
return h(Main)
}
}
```
41 changes: 29 additions & 12 deletions packages/renderer/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@

```javascript
// xxx.vue
import { h, reactive } from 'vue'
import Main from '@opentiny/tiny-engine-renderer'
import { h } from 'vue'
import Main, { api } from '@opentiny/tiny-engine-renderer'

const getSchema = () => {
return newPromise((resolve) => {
setTimeout(() => {
const data = {
state: {},
children: [
{
componentName: 'Text',
props: {
text: '标题'
}
}
]
}
resolve(data)
}, 100)
})
}

export default {
render() {
// 页面schema
const schema = reactive({})
// 工具类
const utils = reactive({})
// 全局状态
const globalState = reactive([])
// 数据源
const dataSourceMap = reactive({})
setup() {
onMounted(async () => {
const schema = await getSchema()

return schema.children.length ? h(Main, { schema, utils, globalState, dataSourceList }) : null
api.setSchema(schema)
})
},
render() {
return h(Main)
}
}
```

0 comments on commit 0097246

Please sign in to comment.