Skip to content

Commit f0fe95c

Browse files
yaoyun8hexqi
authored andcommitted
feat: UniBuy画布渲染 (#2)
* feat: unibuy-render * fix:eslint报错
1 parent 857939a commit f0fe95c

File tree

3 files changed

+10
-90
lines changed

3 files changed

+10
-90
lines changed

mockServer/src/mock/get/app-center/v1/apps/schema/918.json

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,90 +2048,7 @@
20482048
}
20492049
],
20502050
"bridge": [],
2051-
"utils": [
2052-
{
2053-
"name": "axios",
2054-
"type": "npm",
2055-
"content": {
2056-
"type": "JSFunction",
2057-
"value": "",
2058-
"package": "axios",
2059-
"destructuring": false,
2060-
"exportName": "axios"
2061-
}
2062-
},
2063-
{
2064-
"name": "Button",
2065-
"type": "npm",
2066-
"content": {
2067-
"package": "@opentiny/vue",
2068-
"version": "",
2069-
"exportName": "Button",
2070-
"subName": "",
2071-
"destructuring": true,
2072-
"main": ""
2073-
}
2074-
},
2075-
{
2076-
"name": "Menu",
2077-
"type": "npm",
2078-
"content": {
2079-
"type": "JSFunction",
2080-
"value": "",
2081-
"package": "@opentiny/vue",
2082-
"exportName": "NavMenu",
2083-
"destructuring": true
2084-
}
2085-
},
2086-
{
2087-
"name": "Modal ",
2088-
"type": "npm",
2089-
"content": {
2090-
"package": "@opentiny/vue",
2091-
"version": "",
2092-
"exportName": "Modal ",
2093-
"subName": "",
2094-
"destructuring": true,
2095-
"main": ""
2096-
}
2097-
},
2098-
{
2099-
"name": "npm",
2100-
"type": "function",
2101-
"content": {
2102-
"type": "JSFunction",
2103-
"value": "''"
2104-
}
2105-
},
2106-
{
2107-
"name": "Pager",
2108-
"type": "npm",
2109-
"content": {
2110-
"package": "@opentiny/vue",
2111-
"version": "",
2112-
"exportName": "Pager",
2113-
"subName": "",
2114-
"destructuring": true,
2115-
"main": ""
2116-
}
2117-
},
2118-
{
2119-
"name": "test",
2120-
"type": "function",
2121-
"content": {
2122-
"type": "JSFunction",
2123-
"value": "function test() {\r\n return 'test'\r\n}"
2124-
}
2125-
},
2126-
{
2127-
"name": "util",
2128-
"type": "function",
2129-
"content": {
2130-
"type": "JSFunction",
2131-
"value": "function util () {\r\n console.log(321)\r\n}"
2132-
}
2133-
}
2134-
],
2051+
"utils": [],
21352052
"config": {
21362053
"sdkVersion": "1.0.3",
21372054
"historyMode": "hash",

packages/canvas/render/src/RenderMain.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import * as TinyVueIcon from '@opentiny/vue-icon'
1717
import { useBroadcastChannel } from '@vueuse/core'
1818
import { constants, utils as commonUtils } from '@opentiny/tiny-engine-utils'
1919
import renderer, { parseData, setConfigure, setController, globalNotify, isStateAccessor } from './render'
20-
import { getNode as getNodeById, clearNodes, getRoot, setContext, getContext, setCondition, context } from './context'
20+
import { getNode as getNodeById, clearNodes, getRoot, setContext, getContext, setCondition, context, setNode } from './context'
2121
import CanvasEmpty from './CanvasEmpty.vue'
2222

2323
const { BROADCAST_CHANNEL } = constants
@@ -424,5 +424,6 @@ export const api = {
424424
getGlobalState,
425425
getDataSourceMap,
426426
setDataSourceMap,
427-
setGlobalState
427+
setGlobalState,
428+
setNode,
428429
}

packages/canvas/render/src/runner.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*/
1212

13-
import { createApp } from 'vue'
13+
import { createApp, h } from 'vue'
1414
import { addScript, addStyle, dynamicImportComponents, updateDependencies } from '../../common'
1515
import TinyI18nHost, { I18nInjectionKey } from '@opentiny/tiny-engine-common/js/i18n'
1616
import Main, { api } from './RenderMain'
@@ -49,7 +49,7 @@ const renderer = {
4949
const create = async (config) => {
5050
const { beforeAppCreate, appCreated } = config.lifeCycles || {}
5151
if (typeof beforeAppCreate === 'function') {
52-
await beforeAppCreate()
52+
await beforeAppCreate({ Vue: { h }, canvasWin: window, api })
5353
}
5454
App && App.unmount()
5555
App = null
@@ -63,12 +63,14 @@ const create = async (config) => {
6363
dispatch('canvasReady', { detail: renderer })
6464

6565
App = createApp(Main).use(TinyI18nHost).provide(I18nInjectionKey, TinyI18nHost)
66-
App.config.globalProperties.lowcodeConfig = window.parent.TinyGlobalConfig
67-
App.mount(document.querySelector('#app'))
66+
6867
if (typeof appCreated === 'function') {
6968
await appCreated(App)
7069
}
7170

71+
App.config.globalProperties.lowcodeConfig = window.parent.TinyGlobalConfig
72+
App.mount(document.querySelector('#app'))
73+
7274
new ResizeObserver(() => {
7375
dispatch('canvasResize')
7476
}).observe(document.body)

0 commit comments

Comments
 (0)