@cloudbase/framework-plugin-low-code 0.5.17 → 0.5.21-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,OAAO,EACL,SAAS,EAET,cAAc,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWvD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAM7D,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,2BAA2B,IAAK,CAAC;AAoB9C,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;CAqBnB,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAM5C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAMhB,OAAO,CAAC,EAAE,OAAO,CAAC;IAIlB,KAAK,EAAE,MAAM,CAAC;IAId,oBAAoB,EAAE,GAAG,CAAC;IAI1B,uBAAuB,CAAC,EAAE,GAAG,EAAE,CAAC;IAIhC,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAK/B,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAK5B,cAAc,CAAC,EAAE,cAAc,CAAC;IAIhC,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IAIpB,kBAA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AC,mBAAmB,MAAC;IAC9B,SAAS,CAAC,UAAU,MAAC;IACrB,SAAS,CAAC,eAAe,MAAC;IAC1B,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACpC,SAAS,CAAC,QAAQ,KAAM;IACxB,SAAS,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAM;IAC9B,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;IACxB,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;IACtB,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC;gBAEtB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,6BAA6B;IA8I9C,QAAQ;IAMR,qBAAqB,CAAC,aAAa,EAAE,cAAc;IAgGnD,eAAe;IAUf,KAAK,CAAC,KAAK,KAAA;IASX,QAAQ,CAAC,KAAK,KAAA;IAWR,IAAI;IAKJ,GAAG;IAKH,MAAM;IAKN,OAAO;IAKP,KAAK;IAkPL,OAAO;IA2FP,MAAM;IAsGN,mBAAmB,CAAC,KAAK,KAAA,EAAE,KAAK,GAAE,OAAe;IAgBjD,eAAe,CAAC,KAAK,KAAA,EAAE,KAAK,GAAE,OAAe;IAqBnD,eAAe,CAAC,OAAO,KAAA;IAIjB,gBAAgB;IA4HhB,2BAA2B;IA6E3B,UAAU;IAwBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;IAejB,uBAAuB;IAuCvB,yBAAyB;CA8EhC;AAgCD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -231,9 +231,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
231
231
|
privateKeyPath: `./private.${deployOptions.mpAppId}.key`,
|
|
232
232
|
localPath: exports.DIST_PATH,
|
|
233
233
|
ignores: ['node_modules/**/*', LOG_FILE].concat(cloudfunctionRoot ? [path_1.default.join(cloudfunctionRoot, '**/*')] : []),
|
|
234
|
-
deployMode: deployOptions.
|
|
235
|
-
? deployOptions.mode
|
|
236
|
-
: types_1.DEPLOY_MODE.UPLOAD,
|
|
234
|
+
deployMode: deployOptions.mode,
|
|
237
235
|
uploadOptions: {
|
|
238
236
|
version: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.version) || '1.0.0',
|
|
239
237
|
desc: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.description) || '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21-alpha.0",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -10,106 +10,7 @@ import { checkVisible } from '../../utils/index';
|
|
|
10
10
|
|
|
11
11
|
export const ForContext = createContext({});
|
|
12
12
|
|
|
13
|
-
export function
|
|
14
|
-
// For循环渲染
|
|
15
|
-
let forList;
|
|
16
|
-
try {
|
|
17
|
-
// 绑定了 for 变量,但计算值错误时,应当空数组兜底
|
|
18
|
-
forList =
|
|
19
|
-
dataBinds && dataBinds._waFor && (dataBinds._waFor(parentForItems) || []);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
// 计算值出错则使用空数组兜底
|
|
22
|
-
forList = [];
|
|
23
|
-
console.warn('_waFor data', e);
|
|
24
|
-
}
|
|
25
|
-
if (forList && !Array.isArray(forList)) {
|
|
26
|
-
console.warn(`${compId}循环绑定非数组值:`, forList);
|
|
27
|
-
forList = [];
|
|
28
|
-
}
|
|
29
|
-
return forList;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getSafeComponentProps({
|
|
33
|
-
style,
|
|
34
|
-
classNameList,
|
|
35
|
-
staticResourceAttribute,
|
|
36
|
-
}) {
|
|
37
|
-
const componentProps = {};
|
|
38
|
-
if (classNameList.length) {
|
|
39
|
-
componentProps.className = classNameList.join(' ');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (style && Object.keys(style).length) {
|
|
43
|
-
componentProps.style = style;
|
|
44
|
-
}
|
|
45
|
-
if (staticResourceAttribute && staticResourceAttribute.length > 0) {
|
|
46
|
-
componentProps.staticResourceAttribute = staticResourceAttribute;
|
|
47
|
-
}
|
|
48
|
-
return componentProps;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// TODO: 需要不断移除 dataBinds(style/classList)
|
|
52
|
-
function getBindData({
|
|
53
|
-
forItems,
|
|
54
|
-
scopeContext,
|
|
55
|
-
wData,
|
|
56
|
-
commonStyle,
|
|
57
|
-
isInComposite,
|
|
58
|
-
codeContext,
|
|
59
|
-
classNameList,
|
|
60
|
-
}) {
|
|
61
|
-
// bindData
|
|
62
|
-
if (Array.isArray(wData)) {
|
|
63
|
-
wData =
|
|
64
|
-
forItems.forIndexes === void 0 || wData.length === 0
|
|
65
|
-
? {}
|
|
66
|
-
: get(wData, getForIndexes(forItems, wData));
|
|
67
|
-
}
|
|
68
|
-
wData = wData || {};
|
|
69
|
-
const fieldData = { ...wData };
|
|
70
|
-
|
|
71
|
-
// 再次计算 scope value
|
|
72
|
-
for (let key in fieldData) {
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(fieldData, key)) {
|
|
74
|
-
const value = fieldData[key];
|
|
75
|
-
if (value && value.__type === 'scopedValue') {
|
|
76
|
-
try {
|
|
77
|
-
fieldData[key] = value.getValue(scopeContext);
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.warn(`Error computing data bind '${key}' error:`, e);
|
|
80
|
-
fieldData[key] = '';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// bindStyle
|
|
87
|
-
let bindStyle = fieldData.style || {};
|
|
88
|
-
// 复合组件第一层需要将最外层样式 style 挂到节点上
|
|
89
|
-
let cssStyle = commonStyle;
|
|
90
|
-
if (isInComposite && wData && !wData.parent) {
|
|
91
|
-
cssStyle = {
|
|
92
|
-
...cssStyle,
|
|
93
|
-
...(codeContext.$WEAPPS_COMP.props?.style || {}),
|
|
94
|
-
};
|
|
95
|
-
bindStyle = {
|
|
96
|
-
...bindStyle,
|
|
97
|
-
...(codeContext.$WEAPPS_COMP.props?.style || {}),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const finalStyle = getFinalStyle(cssStyle, bindStyle);
|
|
101
|
-
|
|
102
|
-
// bindClassList
|
|
103
|
-
const bindClassList = fieldData.classList || [];
|
|
104
|
-
const finalClassNameList = getFinalClassNameList(
|
|
105
|
-
classNameList,
|
|
106
|
-
bindClassList
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
return { fieldData, finalStyle, finalClassNameList };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export const getRenderList = function (props) {
|
|
13
|
+
export const CompRenderer = observer(function (props) {
|
|
113
14
|
const {
|
|
114
15
|
id: compId,
|
|
115
16
|
xProps,
|
|
@@ -126,7 +27,24 @@ export const getRenderList = function (props) {
|
|
|
126
27
|
? $page.widgets[compId]
|
|
127
28
|
: codeContext.$WEAPPS_COMP.widgets[compId];
|
|
128
29
|
|
|
30
|
+
if (!xProps) {
|
|
31
|
+
return props.children;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
commonStyle = {},
|
|
36
|
+
sourceKey,
|
|
37
|
+
data = {},
|
|
38
|
+
dataBinds,
|
|
39
|
+
listenerInstances,
|
|
40
|
+
styleBind,
|
|
41
|
+
classNameList = [],
|
|
42
|
+
classNameListBind,
|
|
43
|
+
staticResourceAttribute = [],
|
|
44
|
+
} = xProps;
|
|
45
|
+
const Field = virtualFields[sourceKey];
|
|
129
46
|
const parentForItems = useContext(ForContext);
|
|
47
|
+
|
|
130
48
|
const emit = useCallback(
|
|
131
49
|
(trigger, event, forItems, scopeContext) => {
|
|
132
50
|
const listeners = listenerInstances;
|
|
@@ -149,23 +67,41 @@ export const getRenderList = function (props) {
|
|
|
149
67
|
[props]
|
|
150
68
|
);
|
|
151
69
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
70
|
+
function getSafeComponentProps({
|
|
71
|
+
style,
|
|
72
|
+
classNameList,
|
|
73
|
+
staticResourceAttribute,
|
|
74
|
+
}) {
|
|
75
|
+
const componentProps = {};
|
|
76
|
+
if (classNameList.length) {
|
|
77
|
+
componentProps.className = classNameList.join(' ');
|
|
78
|
+
}
|
|
155
79
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
const Field = virtualFields[sourceKey];
|
|
80
|
+
if (style && Object.keys(style).length) {
|
|
81
|
+
componentProps.style = style;
|
|
82
|
+
}
|
|
83
|
+
if (staticResourceAttribute && staticResourceAttribute.length > 0) {
|
|
84
|
+
componentProps.staticResourceAttribute = staticResourceAttribute;
|
|
85
|
+
}
|
|
86
|
+
return componentProps;
|
|
87
|
+
}
|
|
165
88
|
|
|
166
89
|
// For循环渲染
|
|
167
|
-
let forList
|
|
90
|
+
let forList;
|
|
91
|
+
try {
|
|
92
|
+
// 绑定了 for 变量,但计算值错误时,应当空数组兜底
|
|
93
|
+
forList =
|
|
94
|
+
dataBinds && dataBinds._waFor && (dataBinds._waFor(parentForItems) || []);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// 计算值出错则使用空数组兜底
|
|
97
|
+
forList = [];
|
|
98
|
+
console.warn('_waFor data', e);
|
|
99
|
+
}
|
|
168
100
|
if (forList) {
|
|
101
|
+
if (!Array.isArray(forList)) {
|
|
102
|
+
console.warn(`${compId}循环绑定非数组值:`, forList);
|
|
103
|
+
forList = [];
|
|
104
|
+
}
|
|
169
105
|
return forList.map((item, index) => {
|
|
170
106
|
const forItemsIndexes = (parentForItems.forIndexes || []).concat(index);
|
|
171
107
|
const forItems = {
|
|
@@ -177,15 +113,7 @@ export const getRenderList = function (props) {
|
|
|
177
113
|
fieldData: forItemData,
|
|
178
114
|
finalStyle: forItemStyle,
|
|
179
115
|
finalClassNameList: forItemClassNameList,
|
|
180
|
-
} = getBindData(
|
|
181
|
-
forItems,
|
|
182
|
-
scopeContext,
|
|
183
|
-
wData: widgetsData,
|
|
184
|
-
classNameList,
|
|
185
|
-
commonStyle,
|
|
186
|
-
isInComposite,
|
|
187
|
-
codeContext,
|
|
188
|
-
});
|
|
116
|
+
} = getBindData(forItems, scopeContext);
|
|
189
117
|
if (!checkVisible(forItemData)) {
|
|
190
118
|
return null;
|
|
191
119
|
}
|
|
@@ -229,19 +157,16 @@ export const getRenderList = function (props) {
|
|
|
229
157
|
}
|
|
230
158
|
|
|
231
159
|
// 单节点渲染
|
|
232
|
-
const { fieldData, finalClassNameList, finalStyle } = getBindData(
|
|
160
|
+
const { fieldData, finalClassNameList, finalStyle } = getBindData(
|
|
233
161
|
parentForItems,
|
|
234
|
-
scopeContext
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
isInComposite,
|
|
239
|
-
codeContext,
|
|
240
|
-
});
|
|
162
|
+
scopeContext
|
|
163
|
+
);
|
|
164
|
+
const emitWithForItems = (trigger, evt) =>
|
|
165
|
+
emit(trigger, evt, parentForItems, scopeContext);
|
|
241
166
|
|
|
242
167
|
// false 或空字符串时
|
|
243
168
|
if (!checkVisible(fieldData)) {
|
|
244
|
-
return
|
|
169
|
+
return null;
|
|
245
170
|
}
|
|
246
171
|
|
|
247
172
|
// 单个组件的 slot 属性
|
|
@@ -266,12 +191,12 @@ export const getRenderList = function (props) {
|
|
|
266
191
|
classNameList: finalClassNameList,
|
|
267
192
|
staticResourceAttribute,
|
|
268
193
|
});
|
|
269
|
-
return
|
|
194
|
+
return (
|
|
270
195
|
<Field
|
|
271
196
|
data={fieldData}
|
|
272
197
|
id={compId}
|
|
273
198
|
{...componentProps}
|
|
274
|
-
emit={
|
|
199
|
+
emit={emitWithForItems}
|
|
275
200
|
events={emitEvents}
|
|
276
201
|
compositeParent={codeContext}
|
|
277
202
|
forIndexes={forIndexes}
|
|
@@ -279,12 +204,62 @@ export const getRenderList = function (props) {
|
|
|
279
204
|
domRef={domRef}
|
|
280
205
|
>
|
|
281
206
|
{props.children}
|
|
282
|
-
</Field
|
|
283
|
-
|
|
284
|
-
};
|
|
207
|
+
</Field>
|
|
208
|
+
);
|
|
285
209
|
|
|
286
|
-
|
|
287
|
-
|
|
210
|
+
// TODO: 需要不断移除 dataBinds(style/classList)
|
|
211
|
+
function getBindData(forItems, scopeContext) {
|
|
212
|
+
// bindData
|
|
213
|
+
let wData = widgetsData;
|
|
214
|
+
if (Array.isArray(wData)) {
|
|
215
|
+
wData =
|
|
216
|
+
forItems.forIndexes === void 0 || wData.length === 0
|
|
217
|
+
? {}
|
|
218
|
+
: get(wData, getForIndexes(forItems, wData));
|
|
219
|
+
}
|
|
220
|
+
wData = wData || {};
|
|
221
|
+
const fieldData = { ...wData };
|
|
222
|
+
|
|
223
|
+
// 再次计算 scope value
|
|
224
|
+
for (let key in fieldData) {
|
|
225
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, key)) {
|
|
226
|
+
const value = fieldData[key];
|
|
227
|
+
if (value && value.__type === 'scopedValue') {
|
|
228
|
+
try {
|
|
229
|
+
fieldData[key] = value.getValue(scopeContext);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.warn(`Error computing data bind '${key}' error:`, e);
|
|
232
|
+
fieldData[key] = '';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// bindStyle
|
|
239
|
+
let bindStyle = fieldData.style || {};
|
|
240
|
+
// 复合组件第一层需要将最外层样式 style 挂到节点上
|
|
241
|
+
let cssStyle = commonStyle;
|
|
242
|
+
if (isInComposite && wData && !wData.parent) {
|
|
243
|
+
cssStyle = {
|
|
244
|
+
...cssStyle,
|
|
245
|
+
...(codeContext.$WEAPPS_COMP.props?.style || {}),
|
|
246
|
+
};
|
|
247
|
+
bindStyle = {
|
|
248
|
+
...bindStyle,
|
|
249
|
+
...(codeContext.$WEAPPS_COMP.props?.style || {}),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const finalStyle = getFinalStyle(cssStyle, bindStyle);
|
|
253
|
+
|
|
254
|
+
// bindClassList
|
|
255
|
+
const bindClassList = fieldData.classList || [];
|
|
256
|
+
const finalClassNameList = getFinalClassNameList(
|
|
257
|
+
classNameList,
|
|
258
|
+
bindClassList
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return { fieldData, finalStyle, finalClassNameList };
|
|
262
|
+
}
|
|
288
263
|
});
|
|
289
264
|
|
|
290
265
|
export function getFinalStyle(
|
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
-
import {
|
|
4
|
+
import { CompRenderer } from './FieldMiddleware/renderer';
|
|
5
5
|
import { isScopeSlot } from '../utils/index';
|
|
6
|
-
import { observer } from 'mobx-react-lite';
|
|
7
6
|
|
|
8
|
-
function
|
|
9
|
-
return isSlot && !(renderSlot || rootNode);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getComponentChildren(
|
|
13
|
-
component,
|
|
14
|
-
{ virtualFields, codeContext, scopeContext }
|
|
15
|
-
) {
|
|
7
|
+
function getComponentChildren(component) {
|
|
16
8
|
const { properties } = component;
|
|
17
9
|
if (!properties) {
|
|
18
10
|
return [];
|
|
19
11
|
}
|
|
20
|
-
|
|
12
|
+
return Object.values(properties).sort(
|
|
21
13
|
(a, b) => (a['x-index'] || 0) - (b['x-index'] || 0)
|
|
22
14
|
);
|
|
23
|
-
|
|
24
|
-
const componentChildren = [];
|
|
25
|
-
const rootNode = false;
|
|
26
|
-
const renderSlot = false;
|
|
27
|
-
for (const schema of list) {
|
|
28
|
-
const children = getRenderList({
|
|
29
|
-
key: schema.key,
|
|
30
|
-
componentSchema: schema,
|
|
31
|
-
rootNode,
|
|
32
|
-
renderSlot,
|
|
33
|
-
virtualFields,
|
|
34
|
-
codeContext,
|
|
35
|
-
scopeContext,
|
|
36
|
-
});
|
|
37
|
-
componentChildren.push(children);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return componentChildren;
|
|
41
15
|
}
|
|
42
16
|
|
|
43
|
-
function
|
|
17
|
+
export function AppRender(props) {
|
|
44
18
|
const {
|
|
45
19
|
className,
|
|
46
20
|
virtualFields,
|
|
@@ -50,11 +24,12 @@ function getRenderList(props) {
|
|
|
50
24
|
codeContext,
|
|
51
25
|
scopeContext = {},
|
|
52
26
|
} = props;
|
|
27
|
+
|
|
53
28
|
const { 'x-props': xProps, properties = {} } = componentSchema;
|
|
54
29
|
|
|
55
30
|
// 判断是否为 slot
|
|
56
31
|
const isSlot = !xProps;
|
|
57
|
-
if (
|
|
32
|
+
if (isSlot && !(renderSlot || rootNode)) {
|
|
58
33
|
return null;
|
|
59
34
|
}
|
|
60
35
|
|
|
@@ -92,6 +67,7 @@ function getRenderList(props) {
|
|
|
92
67
|
}
|
|
93
68
|
}
|
|
94
69
|
|
|
70
|
+
const children = getComponentChildren(componentSchema);
|
|
95
71
|
const slots = {};
|
|
96
72
|
// eslint-disable-next-line guard-for-in
|
|
97
73
|
for (const key in properties) {
|
|
@@ -129,40 +105,27 @@ function getRenderList(props) {
|
|
|
129
105
|
}
|
|
130
106
|
}
|
|
131
107
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
slots,
|
|
156
|
-
codeContext,
|
|
157
|
-
scopeContext,
|
|
158
|
-
children: getComponentChildren(componentSchema, {
|
|
159
|
-
virtualFields,
|
|
160
|
-
codeContext,
|
|
161
|
-
scopeContext,
|
|
162
|
-
}),
|
|
163
|
-
});
|
|
108
|
+
return (
|
|
109
|
+
<CompRenderer
|
|
110
|
+
id={componentSchema.key}
|
|
111
|
+
xProps={xProps}
|
|
112
|
+
emitEvents={componentSchema.emitEvents || []}
|
|
113
|
+
virtualFields={virtualFields}
|
|
114
|
+
slots={slots}
|
|
115
|
+
codeContext={codeContext}
|
|
116
|
+
scopeContext={scopeContext}
|
|
117
|
+
>
|
|
118
|
+
{children.map((comp) => (
|
|
119
|
+
<AppRender
|
|
120
|
+
key={comp.key}
|
|
121
|
+
componentSchema={comp}
|
|
122
|
+
rootNode={false}
|
|
123
|
+
renderSlot={false}
|
|
124
|
+
virtualFields={virtualFields}
|
|
125
|
+
codeContext={codeContext}
|
|
126
|
+
scopeContext={scopeContext}
|
|
127
|
+
/>
|
|
128
|
+
))}
|
|
129
|
+
</CompRenderer>
|
|
130
|
+
);
|
|
164
131
|
}
|
|
165
|
-
|
|
166
|
-
export const AppRender = observer(function (props) {
|
|
167
|
-
return getRenderList(props);
|
|
168
|
-
});
|
package/template/src/index.jsx
CHANGED
|
@@ -16,7 +16,6 @@ import { app } from './app/global-api'
|
|
|
16
16
|
if (process.env.isApp) {
|
|
17
17
|
initWebConfig(app, AppConfig);
|
|
18
18
|
}
|
|
19
|
-
attachFastClick && attachFastClick.attach && attachFastClick.attach(document.body)
|
|
20
19
|
|
|
21
20
|
// 设置数据源请求的 loading 及 toast 处理
|
|
22
21
|
setConfig({
|
|
@@ -87,14 +86,16 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
function render(props){
|
|
89
|
+
const target = props && props.container ? props.container.querySelector('#react-body') : document.getElementById('react-body');
|
|
90
90
|
ReactDOM.render(
|
|
91
91
|
<App />,
|
|
92
|
-
|
|
92
|
+
target
|
|
93
93
|
)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// if (!process.env.isAdminPortal) {
|
|
97
97
|
if (!window.__POWERED_BY_QIANKUN__) {
|
|
98
|
+
attachFastClick && attachFastClick.attach && attachFastClick.attach(document.body)
|
|
98
99
|
render()
|
|
99
100
|
}
|
|
100
101
|
|