11<template >
2- <tiny-config-provider : design =" designSmbConfig " >
2+ <component :is = " configProvider " : design =" configProviderDesign " >
33 <div id =" tiny-engine" >
44 <design-toolbars :toolbars =" registry.toolbars" ></design-toolbars >
55 <div class =" tiny-engine-main" >
2222 </div >
2323 </div >
2424 </div >
25- </tiny-config-provider >
25+ </component >
2626</template >
2727
2828<script >
29- import { reactive , watch , onUnmounted } from ' vue'
30- import { ConfigProvider as TinyConfigProvider } from ' @opentiny/vue'
31- import designSmbConfig from ' @opentiny/vue-design-smb'
32- import {
33- useResource ,
34- useLayout ,
35- useEditorInfo ,
36- useModal ,
37- useApp ,
38- useNotify ,
39- useCanvas
40- } from ' @opentiny/tiny-engine-meta-register'
29+ import { reactive } from ' vue'
30+ import { useLayout , getMergeRegistry } from ' @opentiny/tiny-engine-meta-register'
4131import AppManage from ' @opentiny/tiny-engine-plugin-page'
42- import { isVsCodeEnv } from ' @opentiny/tiny-engine-common/js/environments'
4332import DesignToolbars from ' ./DesignToolbars.vue'
4433import DesignPlugins from ' ./DesignPlugins.vue'
4534import DesignSettings from ' ./DesignSettings.vue'
46- import blockPlugin from ' @opentiny/tiny-engine-plugin-block'
47- import materials from ' @opentiny/tiny-engine-plugin-materials'
48- import { useBroadcastChannel } from ' @vueuse/core'
49- import { constants } from ' @opentiny/tiny-engine-utils'
50-
51- const { message } = useModal ()
52- const { requestInitBlocks } = blockPlugin .api
53- const { fetchGroups } = materials .apis
54- const { BROADCAST_CHANNEL } = constants
35+ import meta from ' ../meta'
5536
5637export default {
5738 name: ' TinyLowCode' ,
5839 components: {
5940 DesignToolbars,
6041 DesignPlugins,
61- DesignSettings,
62- TinyConfigProvider
42+ DesignSettings
6343 },
6444 provide () {
6545 return {
@@ -72,31 +52,17 @@ export default {
7252 }
7353 },
7454 setup () {
55+ const layoutRegistry = getMergeRegistry (meta .type )
56+ const configProvider = layoutRegistry .options .configProvider
57+ const configProviderDesign = layoutRegistry .options .configProviderDesign
58+
7559 const state = reactive ({
76- globalClass: ' ' ,
77- rightWidth: ' ' ,
78- leftWidfth: ' ' ,
79- preNode: AppManage,
80- jsClose: null
60+ preNode: AppManage
8161 })
8262
8363 const { layoutState } = useLayout ()
8464 const { plugins } = layoutState
8565
86- // 此处接收画布内部的错误和警告提示
87- const { data } = useBroadcastChannel ({ name: BROADCAST_CHANNEL .Notify })
88-
89- watch (data, (options ) => useNotify (options))
90-
91- watch (
92- () => state .jsClose ,
93- () => {
94- if (state .preNode ) {
95- plugins .render = state .preNode .id
96- }
97- }
98- )
99-
10066 const toggleNav = ({ item, navLists }) => {
10167 if (navLists) state .preNode = navLists
10268
@@ -105,51 +71,13 @@ export default {
10571 plugins .render = plugins .render === item .id ? null : item .id
10672 }
10773
108- useEditorInfo ().getUserInfo ()
109-
110- watch (
111- useCanvas ().isCanvasApiReady ,
112- (ready ) => {
113- if (ready) {
114- useResource ().fetchResource ()
115- }
116- },
117- {
118- immediate: true
119- }
120- )
121-
122- const handlePopStateEvent = () => {
123- useResource ().handlePopStateEvent ()
124- }
125-
126- window .addEventListener (' popstate' , handlePopStateEvent)
127-
128- if (isVsCodeEnv) {
129- const appId = useApp ().appInfoState .selectedId
130- fetchGroups (appId)
131- .then ((groups ) => {
132- const blocks = []
133- groups .forEach ((group ) => {
134- blocks .push (... group .blocks )
135- })
136- requestInitBlocks (blocks)
137- })
138- .catch ((error ) => {
139- message ({ message: error .message , status: ' error' })
140- })
141- }
142-
143- onUnmounted (() => {
144- window .removeEventListener (' popstate' , handlePopStateEvent)
145- })
146-
14774 return {
75+ configProvider,
76+ configProviderDesign,
14877 state,
14978 plugins,
15079 toggleNav,
151- layoutState,
152- designSmbConfig
80+ layoutState
15381 }
15482 }
15583}
0 commit comments