@cloudbase/lowcode-builder 1.3.12-alpha.3 → 1.3.12-alpha.4
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/config/index.js +1 -1
- package/lib/builder/core/index.d.ts +8 -0
- package/lib/builder/core/index.js +78 -8
- package/lib/builder/h5/generate.d.ts +2 -1
- package/lib/builder/h5/generate.js +14 -3
- package/lib/builder/h5/index.d.ts +4 -3
- package/lib/builder/h5/index.js +54 -3
- package/lib/builder/h5/webpack.js +1 -0
- package/lib/builder/mp/BuildContext.d.ts +9 -0
- package/lib/builder/mp/index.d.ts +8 -3
- package/lib/builder/mp/index.js +42 -32
- package/lib/builder/mp/materials.js +12 -10
- package/lib/builder/mp/util.js +29 -5
- package/lib/builder/mp/wxml.js +32 -4
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder/util/common.js +0 -4
- package/lib/builder/util/generateFiles.d.ts +1 -2
- package/lib/builder/util/generateFiles.js +1 -13
- package/package.json +3 -3
- package/template/html/index.html.ejs +72 -4
- package/template/mp/app/weapps-api.js +8 -5
- package/template/mp/app.js +27 -4
- package/template/mp/app.wxss +2 -1
- package/template/mp/common/config.js +9 -0
- package/template/mp/common/config.wxs +3 -0
- package/template/mp/common/util.js +16 -9
- package/template/mp/common/utils.wxs +3 -1
- package/template/mp/common/weapp-page.js +57 -18
- package/template/mp/common/widget.js +42 -13
- package/template/mp/component/index.js +1 -0
- package/template/mp/datasources/config.js.tpl +4 -3
- package/template/mp/package.json +1 -1
- package/template/mp/page/api.js +5 -2
- package/template/mp/page/index.js +2 -1
- package/dist/builder.web.js +0 -71
- package/lib/.turbo/turbo-build.log +0 -0
- package/lib/.turbo/turbo-develop.log +0 -0
- package/lib/builder.web.js +0 -71
- package/lib/test.d.ts +0 -11
- package/lib/test.js +0 -717
|
@@ -146,9 +146,7 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
|
|
|
146
146
|
comp.materialName = lib.name;
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
|
-
|
|
150
|
-
const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
|
|
151
|
-
compositedLibs.map((lib) => {
|
|
149
|
+
materialLibs.map((lib) => {
|
|
152
150
|
lib.dependencies = lib.dependencies || {};
|
|
153
151
|
lib.components.map((cmp) => {
|
|
154
152
|
cmp.meta.syncProps = {};
|
|
@@ -159,14 +157,18 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
|
|
|
159
157
|
cmp.meta.syncProps[prop] = syncProp || inputProp;
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
if (lib.isComposite) {
|
|
161
|
+
cmp.meta.platforms = {
|
|
162
|
+
mp: {
|
|
163
|
+
path: `${cmp.name}/index`,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
lib.dependencies = { ...lib.dependencies, ...cmp.npmDependencies };
|
|
167
|
+
}
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
// Collection infomation from components to lib meta
|
|
171
|
+
const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
|
|
170
172
|
// #2 Generate composited libs
|
|
171
173
|
await Promise.all(compositedLibs.map(async (lib) => {
|
|
172
174
|
console.log(`Generate composited library ${lib.name}`);
|
|
@@ -311,7 +313,7 @@ async function generateCompositeComponent(ctx, compositedComp, compLibCommonReso
|
|
|
311
313
|
},
|
|
312
314
|
};
|
|
313
315
|
// Generating file by template and data
|
|
314
|
-
await (0, generateFiles_1.default)(
|
|
316
|
+
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/component`, outDir);
|
|
315
317
|
// #3 writing lowcode files
|
|
316
318
|
/**
|
|
317
319
|
* 低码没有开放 index 类别,直接去掉
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -200,8 +200,10 @@ function generateDataContainerListeners() {
|
|
|
200
200
|
{
|
|
201
201
|
trigger: 'onDataChange',
|
|
202
202
|
jsCode: `({event})=>{
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
if(event.currentTarget) {
|
|
204
|
+
app.utils.set(event.currentTarget._scope, 'dataContext.data', event?.detail?.data);
|
|
205
|
+
app.utils.set(event.currentTarget._scope, 'dataContext.state', event?.detail?.state);
|
|
206
|
+
}
|
|
205
207
|
}`,
|
|
206
208
|
type: weapps_core_1.ActionType.Inline,
|
|
207
209
|
data: {},
|
|
@@ -220,7 +222,7 @@ function getListenersHandlers(listeners, id, componentApi) {
|
|
|
220
222
|
return {};
|
|
221
223
|
const eventHandlers = {};
|
|
222
224
|
listeners.forEach((l) => {
|
|
223
|
-
var _a, _b, _c;
|
|
225
|
+
var _a, _b, _c, _d, _e;
|
|
224
226
|
const handlerName = (0, wxml_1.getMpEventHanlderName)(id, l.trigger, l);
|
|
225
227
|
eventHandlers[handlerName] = eventHandlers[handlerName] || [];
|
|
226
228
|
const params = generatedDynamicData(l.data);
|
|
@@ -243,6 +245,7 @@ function getListenersHandlers(listeners, id, componentApi) {
|
|
|
243
245
|
key: l.key || '',
|
|
244
246
|
handler,
|
|
245
247
|
handlerModule: (_c = l.handler) === null || _c === void 0 ? void 0 : _c.moduleName,
|
|
248
|
+
sourceKey: `${((_d = l.handler) === null || _d === void 0 ? void 0 : _d.moduleName) || ''}:${((_e = l.handler) === null || _e === void 0 ? void 0 : _e.name) || ''}`,
|
|
246
249
|
data: params.staticProps,
|
|
247
250
|
boundData: params.boundProps,
|
|
248
251
|
type: l.type,
|
|
@@ -273,9 +276,21 @@ function createDataBinds(ctx, widgets) {
|
|
|
273
276
|
const { directives = {} } = xProps;
|
|
274
277
|
setDataBind(dataBinds[id], '_waFor', directives.waFor);
|
|
275
278
|
setDataBind(dataBinds[id], '_waIf', directives.waIf);
|
|
279
|
+
if (directives.waDisplay) {
|
|
280
|
+
let { type, value } = directives.waDisplay;
|
|
281
|
+
if (!type || type === 'static') {
|
|
282
|
+
type = weapps_core_1.PropBindType.expression;
|
|
283
|
+
value = `${JSON.stringify(value)}`;
|
|
284
|
+
}
|
|
285
|
+
setDataBind(dataBinds[id], '_waDisplay', {
|
|
286
|
+
...directives.waDisplay,
|
|
287
|
+
type,
|
|
288
|
+
value,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
276
291
|
setDataBind(dataBinds[id], 'classList', xProps.classListBind);
|
|
277
292
|
setDataBind(dataBinds[id], 'style', xProps.styleBind);
|
|
278
|
-
const { classList, style } = dataBinds[id];
|
|
293
|
+
const { classList, style, _waDisplay } = dataBinds[id];
|
|
279
294
|
if (classList) {
|
|
280
295
|
dataBinds[id].classList = {
|
|
281
296
|
...classList,
|
|
@@ -283,12 +298,21 @@ function createDataBinds(ctx, widgets) {
|
|
|
283
298
|
};
|
|
284
299
|
}
|
|
285
300
|
if (style) {
|
|
286
|
-
const styleExpression =
|
|
301
|
+
const styleExpression = _waDisplay
|
|
302
|
+
? `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n), display: (()=>{${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.imports}\n return (\n${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.expression}\n)})() ? undefined: 'none' }`
|
|
303
|
+
: `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n)}`;
|
|
287
304
|
dataBinds[id].style = {
|
|
288
305
|
...style,
|
|
289
306
|
expression: processCssUnit === 'rpx' ? `px2rpx(${styleExpression})` : styleExpression,
|
|
290
307
|
};
|
|
291
308
|
}
|
|
309
|
+
else if (_waDisplay) {
|
|
310
|
+
const styleExpression = `{...widgetProps.${id}.style, display: (\n${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.expression}\n)? undefined: 'none' }`;
|
|
311
|
+
dataBinds[id].style = {
|
|
312
|
+
..._waDisplay,
|
|
313
|
+
expression: processCssUnit === 'rpx' ? `px2rpx(${styleExpression})` : styleExpression,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
292
316
|
if (Object.keys(dataBinds[id]).length === 0) {
|
|
293
317
|
delete dataBinds[id];
|
|
294
318
|
}
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -32,17 +32,36 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
32
32
|
].concat(createXml(widgets)),
|
|
33
33
|
};
|
|
34
34
|
if (ctx.isPage) {
|
|
35
|
+
const { enablePageRoot } = ctx;
|
|
35
36
|
const originElements = xmlJson.elements;
|
|
36
37
|
// 登录校验: 向其最外层包裹一层block
|
|
37
38
|
xmlJson.elements = [
|
|
38
39
|
{
|
|
39
40
|
type: 'element',
|
|
40
|
-
name: 'block',
|
|
41
|
+
name: enablePageRoot ? 'view' : 'block',
|
|
41
42
|
attributes: {
|
|
43
|
+
id: 'wd-page-root',
|
|
42
44
|
['wx:if']: '{{weDaHasLogin}}',
|
|
43
45
|
['data-weui-theme']: 'light',
|
|
44
46
|
},
|
|
45
|
-
elements:
|
|
47
|
+
elements: [
|
|
48
|
+
...originElements,
|
|
49
|
+
/**
|
|
50
|
+
* 可能需要依赖添加逻辑节点的方式
|
|
51
|
+
* 来触发 page 的 ready
|
|
52
|
+
* 目的是为了让 page 的 ready 在组件的 ready 之后
|
|
53
|
+
*/
|
|
54
|
+
// {
|
|
55
|
+
// type: 'element',
|
|
56
|
+
// name: 'readyPlaceHoler',
|
|
57
|
+
// attributes: {
|
|
58
|
+
// ['bind:ready']: '_onReady',
|
|
59
|
+
// },
|
|
60
|
+
// elements: originElements,
|
|
61
|
+
// _order: Infinity,
|
|
62
|
+
// _parent: null,
|
|
63
|
+
// },
|
|
64
|
+
],
|
|
46
65
|
_order: -1,
|
|
47
66
|
_parent: null,
|
|
48
67
|
},
|
|
@@ -164,6 +183,13 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
164
183
|
if ((_d = directives.waIf) === null || _d === void 0 ? void 0 : _d.value) {
|
|
165
184
|
node.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}._waIf`);
|
|
166
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* 对于 hidden 的支持依赖组件透传对应的属性
|
|
188
|
+
* 为了兼容,采用 style merge 的方式
|
|
189
|
+
*/
|
|
190
|
+
// if (directives.waDisplay?.value !== undefined && directives.waDisplay?.value !== true) {
|
|
191
|
+
// node.attributes['hidden'] = getAttrBind(directives.waDisplay, `${attrPrefix}._waDisplay`, false, true);
|
|
192
|
+
// }
|
|
167
193
|
if ((_e = directives.waFor) === null || _e === void 0 ? void 0 : _e.value) {
|
|
168
194
|
node.attributes['wx:for'] = getAttrBind(directives.waFor, `${wxmlDataPrefix.widgetProp}${id}${parentForNodes
|
|
169
195
|
.map((forNodeId) => `[${wxmlDataPrefix.forIndex}${forNodeId}]`)
|
|
@@ -368,10 +394,12 @@ function getUsedComponents(widgets, usedCmps = {}) {
|
|
|
368
394
|
return usedCmps;
|
|
369
395
|
}
|
|
370
396
|
exports.getUsedComponents = getUsedComponents;
|
|
371
|
-
function getAttrBind(dVale, widgetBind, isStaticResource) {
|
|
397
|
+
function getAttrBind(dVale, widgetBind, isStaticResource, neg) {
|
|
372
398
|
const { type, value } = dVale;
|
|
373
399
|
const attrVal = type === weapps_core_1.PropBindType.prop ? value : widgetBind;
|
|
374
|
-
return isStaticResource
|
|
400
|
+
return isStaticResource
|
|
401
|
+
? `{{${neg ? '!' : ''}wxsUtils._getStaticResourceAttribute(${attrVal})}}`
|
|
402
|
+
: `{{${neg ? `!(${attrVal})` : `${attrVal}`}}}`;
|
|
375
403
|
}
|
|
376
404
|
function getGenericCompTagName(propName) {
|
|
377
405
|
return `g--${propName}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
2
|
import { IMaterialItem, IWeAppComponentInstance, IWeAppCode } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
3
|
export { getMetaInfoBySourceKey, isArray, isPlainObject, deepDeal, simpleDeepClone, deepDealSchema, getFileNameByUrl, } from '@cloudbase/lowcode-generator/lib/generator/util/common';
|
|
4
|
-
|
|
4
|
+
declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
6
6
|
export declare function getCurrentPackageJson(): {
|
|
7
7
|
name: any;
|
|
@@ -34,10 +34,6 @@ function promiseWrapper(p) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.promiseWrapper = promiseWrapper;
|
|
37
|
-
// export function isEmpty(i: any): boolean {
|
|
38
|
-
// if (typeof i === 'string') return !i.trim()
|
|
39
|
-
// return R.isEmpty(i) || R.isNil(i) || Number.isNaN(i)
|
|
40
|
-
// }
|
|
41
37
|
function getCurrentPackageJson() {
|
|
42
38
|
try {
|
|
43
39
|
const { name, version } = fs_extra_1.default.readJSONSync(path_1.default.resolve(process.cwd(), 'package.json'));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IBuildContext } from '../mp/BuildContext';
|
|
3
2
|
import { OutputType } from 'jszip';
|
|
4
3
|
export declare const generatedFileContents: {};
|
|
5
|
-
export default function generateFiles(
|
|
4
|
+
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
|
|
6
5
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
7
6
|
export declare function removeFile(file: string): void;
|
|
8
7
|
/**
|
|
@@ -35,7 +35,7 @@ const glob_1 = __importDefault(require("glob"));
|
|
|
35
35
|
const jszip_1 = __importDefault(require("jszip"));
|
|
36
36
|
const buffer_1 = require("buffer");
|
|
37
37
|
exports.generatedFileContents = {}; // generated files for incrmental build
|
|
38
|
-
async function generateFiles(
|
|
38
|
+
async function generateFiles(appFileData, srcDir, dstDir) {
|
|
39
39
|
const filesGenerated = [];
|
|
40
40
|
// Generating file by template and data
|
|
41
41
|
for (const file in appFileData) {
|
|
@@ -46,18 +46,6 @@ async function generateFiles(ctx, appFileData, srcDir, dstDir) {
|
|
|
46
46
|
encoding: 'utf8',
|
|
47
47
|
});
|
|
48
48
|
let generatedCode = (0, lodash_1.template)(tplStr, { interpolate: /<%=([\s\S]+?)%>/ })(appFileData[file]);
|
|
49
|
-
// 混合模式下,引用公共路径要多增加一层,并加多一层命名
|
|
50
|
-
// 混合子包直接在对应目录上生成,而不采用替换的方式 @royhyang
|
|
51
|
-
// if (ctx?.isMixMode && ctx?.rootPath) {
|
|
52
|
-
// generatedCode = generatedCode.replace(
|
|
53
|
-
// /..\/..\/..\/common\//g,
|
|
54
|
-
// '../../../../common/'
|
|
55
|
-
// )
|
|
56
|
-
// generatedCode = generatedCode.replace(
|
|
57
|
-
// /..\/..\/..\/app\//g,
|
|
58
|
-
// '../../../../app/'
|
|
59
|
-
// )
|
|
60
|
-
// }
|
|
61
49
|
const outFile = path_1.default.resolve(dstDir, outFileName.replace(/\.tpl$/, ''));
|
|
62
50
|
if (await writeFile(outFile, generatedCode)) {
|
|
63
51
|
filesGenerated.push(outFileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.3.12-alpha.
|
|
3
|
+
"version": "1.3.12-alpha.4",
|
|
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",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@cloudbase/cals": "
|
|
42
|
-
"@cloudbase/lowcode-generator": "
|
|
41
|
+
"@cloudbase/cals": "workspace:^",
|
|
42
|
+
"@cloudbase/lowcode-generator": "workspace:^",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<% cssStyles.forEach(function(styleUrl){%>
|
|
20
20
|
<link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
|
|
21
21
|
<% })%> <% if(cdnEndpoints.aegis){ %>
|
|
22
|
-
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis
|
|
22
|
+
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
|
|
23
23
|
<script>
|
|
24
24
|
<% if(!isAdminPortal){ %>
|
|
25
25
|
const _aegis = new Aegis({
|
|
@@ -386,7 +386,75 @@
|
|
|
386
386
|
</head>
|
|
387
387
|
|
|
388
388
|
<body data-weui-theme="light">
|
|
389
|
-
<div id="root" class="main-wrap"
|
|
389
|
+
<div id="root" class="main-wrap">
|
|
390
|
+
<% if(enableStaticLoading){ %>
|
|
391
|
+
<style type="text/css">
|
|
392
|
+
.weda-loading-container {
|
|
393
|
+
position: fixed;
|
|
394
|
+
left: 0;
|
|
395
|
+
top: 0;
|
|
396
|
+
width: 100%;
|
|
397
|
+
display: flex;
|
|
398
|
+
justify-content: center;
|
|
399
|
+
align-items: center;
|
|
400
|
+
flex-direction: column;
|
|
401
|
+
height: 100%;
|
|
402
|
+
padding: 0 20px;
|
|
403
|
+
}
|
|
404
|
+
.weda-loading-container .logo {
|
|
405
|
+
width: 100%;
|
|
406
|
+
display: flex;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
text-align: center;
|
|
409
|
+
margin-bottom: 50px;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.weda-loading-container .sp {
|
|
413
|
+
width: 48px;
|
|
414
|
+
height: 48px;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.weda-loading-container .sp-circle {
|
|
418
|
+
border: 6px rgba(0, 82, 217, 0.25) solid;
|
|
419
|
+
border-top: 6px rgba(0, 82, 217, 1) solid;
|
|
420
|
+
border-radius: 50%;
|
|
421
|
+
-webkit-animation: spCircRot 0.6s infinite linear;
|
|
422
|
+
animation: spCircRot 0.6s infinite linear;
|
|
423
|
+
}
|
|
424
|
+
@-webkit-keyframes spCircRot {
|
|
425
|
+
from {
|
|
426
|
+
-webkit-transform: rotate(0deg);
|
|
427
|
+
}
|
|
428
|
+
to {
|
|
429
|
+
-webkit-transform: rotate(359deg);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
@keyframes spCircRot {
|
|
433
|
+
from {
|
|
434
|
+
transform: rotate(0deg);
|
|
435
|
+
}
|
|
436
|
+
to {
|
|
437
|
+
transform: rotate(359deg);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
</style>
|
|
441
|
+
<div class="weda-loading-container">
|
|
442
|
+
<div class="logo">
|
|
443
|
+
<div class="sp sp-circle"></div>
|
|
444
|
+
</div>
|
|
445
|
+
<div class="text">初始化中...</div>
|
|
446
|
+
<script>
|
|
447
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
448
|
+
if (ua.indexOf('wxwork') !== -1 && /[?&]code=/.test(location.search) && /[?&]state=/.test(location.search)) {
|
|
449
|
+
var el = document.querySelector('#root .weda-loading-container>.text');
|
|
450
|
+
if (el) {
|
|
451
|
+
el.innerHTML = '数据加载中...';
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
</script>
|
|
455
|
+
</div>
|
|
456
|
+
<% }%>
|
|
457
|
+
</div>
|
|
390
458
|
<% jsApis.forEach(function(jsApi){%>
|
|
391
459
|
<script src="<%=jsApi %>"></script>
|
|
392
460
|
<% })%> <% if(canUseVite){ %>
|
|
@@ -453,7 +521,7 @@
|
|
|
453
521
|
crossorigin="anonymous"
|
|
454
522
|
src="<%=
|
|
455
523
|
cdnEndpoints.cdngo
|
|
456
|
-
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.
|
|
524
|
+
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.27-alpha.0/dist/h5.browser.js"
|
|
457
525
|
></script>
|
|
458
526
|
<script>
|
|
459
527
|
// zxing polifill
|
|
@@ -475,7 +543,7 @@
|
|
|
475
543
|
crossorigin
|
|
476
544
|
src="<%=
|
|
477
545
|
cdnEndpoints.cdngo
|
|
478
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
546
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.051bed8f584a31b92c63.bundle.js"
|
|
479
547
|
></script>
|
|
480
548
|
</body>
|
|
481
549
|
</html>
|
|
@@ -4,6 +4,7 @@ import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../c
|
|
|
4
4
|
import appGlobal from '<%= subLevelPath %>../app/app-global'
|
|
5
5
|
import { createDataset } from '<%= subLevelPath %>../datasources/index'
|
|
6
6
|
import lodashGet from 'lodash.get';
|
|
7
|
+
import config from '<%= subLevelPath %>../common/config';
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
<%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
|
|
@@ -25,11 +26,13 @@ export const $w = new Proxy(
|
|
|
25
26
|
|
|
26
27
|
function createGlboalApi() {
|
|
27
28
|
const mpApp = createMpApp({
|
|
28
|
-
appConfig:
|
|
29
|
+
appConfig: {
|
|
30
|
+
staticResourceDomain: config.domain,
|
|
31
|
+
...(<%= appConfig %>)
|
|
32
|
+
},
|
|
29
33
|
});
|
|
30
|
-
const globalAPI = {
|
|
31
|
-
|
|
32
|
-
domain: '<%= domain %>',
|
|
34
|
+
const globalAPI = Object.assign(mpApp, {
|
|
35
|
+
domain: config.domain,
|
|
33
36
|
pages: {},
|
|
34
37
|
session: {
|
|
35
38
|
//configure: sdk.configure,
|
|
@@ -45,7 +48,7 @@ function createGlboalApi() {
|
|
|
45
48
|
return $page.invokeComponentMethod(params)
|
|
46
49
|
},
|
|
47
50
|
// ... other sdk apis & apis from mp
|
|
48
|
-
} // The global api exposed to lowcode
|
|
51
|
+
}) // The global api exposed to lowcode
|
|
49
52
|
|
|
50
53
|
globalAPI.__internal__.enumOptions = enumOptions
|
|
51
54
|
globalAPI.utils.formatEnum = formatEnum
|
package/template/mp/app.js
CHANGED
|
@@ -83,20 +83,43 @@ setConfig({
|
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
App({
|
|
86
|
-
|
|
86
|
+
_query: {},
|
|
87
|
+
globaldata: {
|
|
88
|
+
_beforeCustomLaunchPromise: null
|
|
89
|
+
},
|
|
90
|
+
async beforeCustomLaunch(query) {
|
|
91
|
+
if(!this.globaldata?._beforeCustomLaunchPromise){
|
|
92
|
+
if(!this.globaldata) {
|
|
93
|
+
this.globaldata = {}
|
|
94
|
+
}
|
|
95
|
+
this.globaldata._beforeCustomLaunchPromise = new Promise(async (resolve)=>{
|
|
96
|
+
try {
|
|
97
|
+
EXTRA_API.setParams('$global', query || {})
|
|
98
|
+
await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {} }));
|
|
99
|
+
} catch (e) {
|
|
100
|
+
throw e;
|
|
101
|
+
} finally {
|
|
102
|
+
resolve()
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
return this.globaldata._beforeCustomLaunchPromise
|
|
107
|
+
},
|
|
108
|
+
async onLaunch(options) {
|
|
87
109
|
this.app = app
|
|
88
110
|
const onLaunch = lifeCycle.onLaunch || lifeCycle.onAppLaunch
|
|
89
111
|
let { query = {} } = options
|
|
90
|
-
|
|
91
|
-
createStateDataSourceVar('$global', generateParamsParser({ app }))
|
|
112
|
+
this._query = query
|
|
92
113
|
|
|
114
|
+
await this.beforeCustomLaunch(query)
|
|
93
115
|
onLaunch && onLaunch.call(this, options)
|
|
94
116
|
// 初始私有全局数据
|
|
95
117
|
this.$$global = {
|
|
96
118
|
homePageId: '<%= appConfig.homePageId %>'
|
|
97
119
|
}
|
|
98
120
|
},
|
|
99
|
-
onShow(options) {
|
|
121
|
+
async onShow(options) {
|
|
122
|
+
await this.beforeCustomLaunch(this._query)
|
|
100
123
|
const fn = lifeCycle.onShow || lifeCycle.onAppShow
|
|
101
124
|
fn && fn.call(this, options)
|
|
102
125
|
},
|
package/template/mp/app.wxss
CHANGED
|
@@ -33,11 +33,13 @@ export function generateDataContext(widget) {
|
|
|
33
33
|
while (widget?._scope) {
|
|
34
34
|
const current = widget;
|
|
35
35
|
// 此处采用代理的方式,是为了可以获取到最新的 _scope.dataContext 防止 dataContext 引用被重新赋值
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if(current?._scope?.id){
|
|
37
|
+
Object.defineProperty(dataContext, current._scope.id, {
|
|
38
|
+
get() {
|
|
39
|
+
return current?._scope?.dataContext;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
41
43
|
widget = widget.parent;
|
|
42
44
|
}
|
|
43
45
|
return dataContext;
|
|
@@ -64,14 +66,19 @@ export function createEventHandlers(
|
|
|
64
66
|
const currentTarget = !!event?.currentTarget?.id ? getWidget(owner.widgets, event.currentTarget.id) : undefined;
|
|
65
67
|
event.target = target;
|
|
66
68
|
event.currentTarget = currentTarget;
|
|
67
|
-
const [prefix = ''] = name.split('$');
|
|
69
|
+
const [prefix = '', trigger] = name.split('$');
|
|
68
70
|
// The page event handler
|
|
69
71
|
const forContext = (!!currentTarget && generateForContextOfWidget(currentTarget)) || {};
|
|
70
72
|
const { lists = [], forItems = {} } = forContext;
|
|
71
73
|
const dataContext = untracked(() => generateDataContext(currentTarget));
|
|
72
74
|
const $w = untracked(() => generateWidgetAPIContext(owner?.__internal__?.$w, currentTarget, forContext));
|
|
73
75
|
|
|
76
|
+
const currentPageId = app.__internal__?.activePage?.id
|
|
74
77
|
listeners.forEach(async (l) => {
|
|
78
|
+
if(currentPageId && owner.id && currentPageId !== owner.id) {
|
|
79
|
+
console.error(`Action error: [${trigger}:${l.key}] 页面生命周期结束,链式调用中断`);
|
|
80
|
+
return ;
|
|
81
|
+
}
|
|
75
82
|
let { data = {}, boundData = {} } = l;
|
|
76
83
|
data = { ...data };
|
|
77
84
|
try {
|
|
@@ -79,16 +86,16 @@ export function createEventHandlers(
|
|
|
79
86
|
set(data, k, boundData[k].call(owner, owner, lists, forItems, event, dataContext, $w));
|
|
80
87
|
}
|
|
81
88
|
let res = await l.handler.call(owner, { event, data });
|
|
82
|
-
let eventName = prefix && l.key ? `${prefix}$${l.key}_success` : '';
|
|
89
|
+
let eventName = prefix && l.key ? `${prefix}$${l.key}${(l.sourceKey !== 'platform:utils.If') ? '_success' : (res ? '_success' : '_fail')}` : '';
|
|
83
90
|
self[eventName] &&
|
|
84
91
|
self[eventName]({
|
|
85
92
|
...event,
|
|
86
|
-
detail: res,
|
|
93
|
+
detail: l.sourceKey === 'platform:utils.If' ? event.detail : res,
|
|
87
94
|
});
|
|
88
95
|
} catch (e) {
|
|
89
96
|
let eventName = l.key ? `${prefix}$${l.key}_fail` : '';
|
|
90
97
|
if (self[eventName]) {
|
|
91
|
-
console.error(
|
|
98
|
+
console.error(`Action error: [${trigger}:${l.key}]`, e);
|
|
92
99
|
await self[eventName]({
|
|
93
100
|
...event,
|
|
94
101
|
detail: e,
|