@cloudbase/lowcode-builder 1.8.85 → 1.8.87
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/builder/mp/index.js +3 -3
- package/lib/builder/mp/mp_config.d.ts +2 -2
- package/lib/builder/mp/mp_config.js +32 -24
- package/lib/builder/util/net.js +5 -2
- package/lib/builder.web.js +3 -3
- package/package.json +2 -2
- package/template/html/index.html.ejs +14 -12
- package/template/mp/common/query.js +83 -66
- package/template/mp/common/util.js +27 -14
- package/template/mp/common/weapp-page.js +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.87",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
|
-
"@cloudbase/cals": "^1.0.
|
|
50
|
+
"@cloudbase/cals": "^1.0.70",
|
|
51
51
|
"@cloudbase/lowcode-generator": "^1.8.25",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
53
|
"browserfs": "^1.4.3",
|
|
@@ -23,17 +23,19 @@
|
|
|
23
23
|
<% })%> <% if(cdnEndpoints.aegis){ %>
|
|
24
24
|
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
|
|
25
25
|
<script>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
if (Aegis) {
|
|
27
|
+
const _aegis = new Aegis({
|
|
28
|
+
id: 'lXHFsBpTjIzNADiczY', // 项目ID,即上报key
|
|
29
|
+
reportApiSpeed: true, // 接口测速
|
|
30
|
+
reportAssetSpeed: true, // 静态资源测速
|
|
31
|
+
spa: true,
|
|
32
|
+
ext1: '<%=appId%>',
|
|
33
|
+
ext3: '<%=ext3%>',
|
|
34
|
+
version: '<%= !isAdminPortal? "0.0.2" : "0.0.3" %>',
|
|
35
|
+
env: '<%= mode !== "production"? "pre" : "production" %>',
|
|
36
|
+
});
|
|
37
|
+
window._aegis = _aegis;
|
|
38
|
+
}
|
|
37
39
|
window._aegis_inited = Date.now();
|
|
38
40
|
</script>
|
|
39
41
|
<% }%>
|
|
@@ -543,7 +545,7 @@
|
|
|
543
545
|
crossorigin
|
|
544
546
|
src="<%=
|
|
545
547
|
cdnEndpoints.cdngo
|
|
546
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
548
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.4b74407996a537f4d5a6.bundle.js"
|
|
547
549
|
></script>
|
|
548
550
|
</body>
|
|
549
551
|
</html>
|
|
@@ -16,6 +16,11 @@ export class Query {
|
|
|
16
16
|
#observableValue = observable({ data: null, error: null, isFetching: false });
|
|
17
17
|
#eventHandlerMap = {};
|
|
18
18
|
#action = () => {};
|
|
19
|
+
#runQueryMap = {
|
|
20
|
+
sql: { QueryResource: 'mysql-plugin', QueryPath: '/WeDa/Query/V1/RunPluginQuery' },
|
|
21
|
+
sqlserver: { QueryResource: 'mssql-plugin', QueryPath: '/WeDa/Query/V1/RunPluginQuery' },
|
|
22
|
+
'cloud-connector': { QueryResource: 'apis-plugin', QueryPath: '/WeDa/Connector/v1/RunApisQuery' },
|
|
23
|
+
};
|
|
19
24
|
constructor({ schema, context, options = {} }) {
|
|
20
25
|
const { looseError = false } = options;
|
|
21
26
|
this.#schema = schema;
|
|
@@ -33,7 +38,7 @@ export class Query {
|
|
|
33
38
|
autorun(
|
|
34
39
|
(r) => {
|
|
35
40
|
try {
|
|
36
|
-
const data = this.#resolveParams();
|
|
41
|
+
const data = this.#resolveParams({}, { combainErrors: true });
|
|
37
42
|
if (this.#triggered) {
|
|
38
43
|
this.#debounceTrigger(data);
|
|
39
44
|
}
|
|
@@ -59,76 +64,85 @@ export class Query {
|
|
|
59
64
|
|
|
60
65
|
const { $w } = this.#context;
|
|
61
66
|
|
|
62
|
-
this.#action =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
type = 'OBJECT';
|
|
91
|
-
}
|
|
67
|
+
this.#action = this.#isRunQueryType
|
|
68
|
+
? async function (data) {
|
|
69
|
+
const requestData = {
|
|
70
|
+
EnvId: $w.env.envId,
|
|
71
|
+
Name: data.sqlTemplateId,
|
|
72
|
+
Parameter: JSON.stringify(
|
|
73
|
+
Object.entries(data.params || {}).reduce((list, [key, value]) => {
|
|
74
|
+
if (value !== undefined) {
|
|
75
|
+
let type = 'OBJECT';
|
|
76
|
+
const typeofValue = typeof value;
|
|
77
|
+
switch (typeofValue) {
|
|
78
|
+
case 'boolean': {
|
|
79
|
+
type = 'BOOLEAN';
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'number': {
|
|
83
|
+
type = 'NUMBER';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'string': {
|
|
87
|
+
type = 'STRING';
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
default: {
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
type = 'ARRAY';
|
|
93
|
+
} else {
|
|
94
|
+
type = 'OBJECT';
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
|
|
95
|
-
list.push({
|
|
96
|
-
Key: key,
|
|
97
|
-
Type: type,
|
|
98
|
-
Value: type === 'STRING' ? value : JSON.stringify(value),
|
|
99
|
-
});
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
list.push({
|
|
100
|
+
Key: key,
|
|
101
|
+
Type: type,
|
|
102
|
+
Value: type === 'STRING' ? value : JSON.stringify(value),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return list;
|
|
107
|
+
}, []) || [],
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const Data = await $w.cloud.callWedaApi({
|
|
112
|
+
action: 'RunQuery',
|
|
113
|
+
CallQuery: true,
|
|
114
|
+
...(this.#runQueryMap[this.#schema.type] || this.#runQueryMap['sql']),
|
|
115
|
+
EnvId: requestData.EnvId,
|
|
116
|
+
QueryName: requestData.Name,
|
|
117
|
+
data: requestData,
|
|
118
|
+
});
|
|
106
119
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
data: requestData,
|
|
115
|
-
});
|
|
120
|
+
// const Data = await $w.cloud.callWedaApi({
|
|
121
|
+
// action: 'RunPluginQuery',
|
|
122
|
+
// data: {
|
|
123
|
+
// MainAppId: $w.app.id,
|
|
124
|
+
// ...requestData
|
|
125
|
+
// },
|
|
126
|
+
// });
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
// action: 'RunPluginQuery',
|
|
119
|
-
// data: {
|
|
120
|
-
// MainAppId: $w.app.id,
|
|
121
|
-
// ...requestData
|
|
122
|
-
// },
|
|
123
|
-
// });
|
|
128
|
+
const { ExecuteResultList = [], Total, Payload } = Data || {};
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
130
|
+
let payload = Payload;
|
|
131
|
+
try {
|
|
132
|
+
if (Payload) {
|
|
133
|
+
payload = JSON.parse(Payload);
|
|
134
|
+
}
|
|
135
|
+
} catch (e) {}
|
|
136
|
+
return {
|
|
137
|
+
...(this.#schema.type === 'cloud-connector'
|
|
138
|
+
? payload
|
|
139
|
+
: {
|
|
140
|
+
records: ExecuteResultList.map((item) => JSON.parse(item)),
|
|
141
|
+
total: Total || ExecuteResultList.length,
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
: this.#schema.handler;
|
|
132
146
|
this.#eventHandlerMap = Object.entries(
|
|
133
147
|
createEventHandlers(this.#schema.eventHandlers || {}, {
|
|
134
148
|
looseError: looseError,
|
|
@@ -164,6 +178,9 @@ export class Query {
|
|
|
164
178
|
get isFetching() {
|
|
165
179
|
return this.#observableValue.isFetching;
|
|
166
180
|
}
|
|
181
|
+
get #isRunQueryType() {
|
|
182
|
+
return !!this.#runQueryMap[this.#schema.type];
|
|
183
|
+
}
|
|
167
184
|
async trigger(additionalScope, options = {}) {
|
|
168
185
|
this.#triggered = true;
|
|
169
186
|
return this.#innerTrigger(this.#resolveParams(additionalScope), options);
|
|
@@ -217,7 +234,7 @@ export class Query {
|
|
|
217
234
|
}, 300);
|
|
218
235
|
}
|
|
219
236
|
|
|
220
|
-
#resolveParams(additionalScope = {}) {
|
|
237
|
+
#resolveParams(additionalScope = {}, options = {}) {
|
|
221
238
|
/**
|
|
222
239
|
* 这里万一其中某个字段计算失败
|
|
223
240
|
* 好像会阻塞其他字段的计算
|
|
@@ -227,7 +244,7 @@ export class Query {
|
|
|
227
244
|
mergeDynamic2StaticData(toJS(this.#paramsRef.current), this.#dataBinds, {
|
|
228
245
|
$w: this.#context.$w,
|
|
229
246
|
paramsContext: additionalScope,
|
|
230
|
-
}) || {};
|
|
247
|
+
}, options?.combainErrors) || {};
|
|
231
248
|
|
|
232
249
|
return params;
|
|
233
250
|
}
|
|
@@ -714,6 +714,7 @@ export function mergeDynamic2StaticData(
|
|
|
714
714
|
dataContext?: Record<string,any>;
|
|
715
715
|
paramsContext?: Record<string,any>;
|
|
716
716
|
}*/,
|
|
717
|
+
combainErrors = false,
|
|
717
718
|
) {
|
|
718
719
|
const { forContext = {}, codeContext = {}, dataContext = {}, $w, paramsContext = {} } = context;
|
|
719
720
|
const { lists = [], forItems = {} } = forContext;
|
|
@@ -721,22 +722,34 @@ export function mergeDynamic2StaticData(
|
|
|
721
722
|
const resolvedData = {
|
|
722
723
|
...staticData,
|
|
723
724
|
};
|
|
725
|
+
let error = null;
|
|
724
726
|
|
|
725
727
|
for (const key in dataBinds) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
728
|
+
try {
|
|
729
|
+
set(
|
|
730
|
+
resolvedData,
|
|
731
|
+
key,
|
|
732
|
+
dataBinds[key].call(
|
|
733
|
+
codeContext.instance,
|
|
734
|
+
codeContext.instance,
|
|
735
|
+
lists,
|
|
736
|
+
forItems,
|
|
737
|
+
codeContext.event,
|
|
738
|
+
dataContext,
|
|
739
|
+
$w,
|
|
740
|
+
paramsContext,
|
|
741
|
+
),
|
|
742
|
+
);
|
|
743
|
+
} catch(e) {
|
|
744
|
+
if(combainErrors) {
|
|
745
|
+
error = e
|
|
746
|
+
} else {
|
|
747
|
+
throw e
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if(error) {
|
|
752
|
+
throw error
|
|
740
753
|
}
|
|
741
754
|
|
|
742
755
|
return resolvedData;
|
|
@@ -310,10 +310,12 @@ export function createPage({
|
|
|
310
310
|
this._disposers.push(...runWatchers(index, this));
|
|
311
311
|
|
|
312
312
|
await this.beforePageCustomLaunch?.(this._query);
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
setTimeout(async () => {
|
|
314
|
+
const hook = lifecycle.onReady || lifecycle.onPageReady;
|
|
315
|
+
await hook?.call?.($page);
|
|
315
316
|
|
|
316
|
-
|
|
317
|
+
this._invokeEventHandler('ready');
|
|
318
|
+
}, 100);
|
|
317
319
|
},
|
|
318
320
|
onUnload() {
|
|
319
321
|
const $page = this._getInstance();
|