@cloudbase/lowcode-builder 1.8.51 → 1.8.53
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.d.ts +1 -1
- package/lib/builder/config/index.js +1 -1
- package/lib/builder/core/index.js +2 -1
- package/lib/builder/mp/index.d.ts +3 -1
- package/lib/builder/mp/index.js +20 -6
- package/lib/builder/mp/materials.js +1 -1
- package/lib/builder/mp/util.d.ts +1 -0
- package/lib/builder/mp/util.js +34 -1
- package/package.json +9 -5
- package/template/html/index.html.ejs +6 -4
- package/template/mp/app.js +11 -5
- package/template/mp/common/info/index.js +12 -9
- package/template/mp/common/merge-renderer.js +1 -1
- package/template/mp/common/placeholder/index.json +4 -0
- package/template/mp/common/placeholder/index.ts +1 -0
- package/template/mp/common/placeholder/index.wxml +1 -0
- package/template/mp/common/placeholder/index.wxss +1 -0
- package/template/mp/common/query.js +12 -1
- package/template/mp/common/util.js +10 -3
- package/template/mp/common/weapp-page.js +12 -7
- package/template/mp/common/widget.js +6 -6
- package/template/mp/datasources/config.js.tpl +23 -1
- package/template/mp/datasources/{index.js → index.js.tpl} +5 -1
- package/template/mp/package.json +4 -4
- package/template/mp/page/api.js +2 -1
|
@@ -6,7 +6,7 @@ export declare const materialsDirName = "materials";
|
|
|
6
6
|
* src/template的代码,在IDE编辑器插件中构建builder
|
|
7
7
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
8
8
|
*/
|
|
9
|
-
export declare const builderTemplateURL = "https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.
|
|
9
|
+
export declare const builderTemplateURL = "https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.52.zip";
|
|
10
10
|
/**
|
|
11
11
|
* miniprogram的代码,IDE插件后续会提供端功能
|
|
12
12
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
@@ -45,7 +45,7 @@ exports.materialsDirName = 'materials'; // materials diretory of current project
|
|
|
45
45
|
* src/template的代码,在IDE编辑器插件中构建builder
|
|
46
46
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
47
47
|
*/
|
|
48
|
-
exports.builderTemplateURL = 'https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.
|
|
48
|
+
exports.builderTemplateURL = 'https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.52.zip';
|
|
49
49
|
/**
|
|
50
50
|
* miniprogram的代码,IDE插件后续会提供端功能
|
|
51
51
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
@@ -168,6 +168,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
168
168
|
},
|
|
169
169
|
buildTypeList,
|
|
170
170
|
ignoreInstall,
|
|
171
|
+
cdnEndpoints: { ...(0, config_1.generateCdnEndpoints)(cdnEndpoints), aegis: '' },
|
|
171
172
|
});
|
|
172
173
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
173
174
|
// 针对 app.json / package.json 则采用 merge 的操作
|
|
@@ -216,7 +217,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
216
217
|
runtime,
|
|
217
218
|
deployOptions,
|
|
218
219
|
ignoreInstall,
|
|
219
|
-
cdnEndpoints,
|
|
220
|
+
cdnEndpoints: (0, config_1.generateCdnEndpoints)(cdnEndpoints),
|
|
220
221
|
});
|
|
221
222
|
await (cb === null || cb === void 0 ? void 0 : cb(null, {
|
|
222
223
|
outDir: h5BuildDir,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IWeAppData, IPlugin } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
|
+
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
2
3
|
import { IBuildContext } from './BuildContext';
|
|
3
4
|
import { BuildType, IAppUsedComp, IUsedComps } from '../types/common';
|
|
4
5
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
5
6
|
import { IBuildWedaApp } from '../core';
|
|
6
|
-
export declare function generateWxMp({ buildContext, weapps, calses, plugins, deployOptions, options, buildTypeList, ignoreInstall, }: {
|
|
7
|
+
export declare function generateWxMp({ buildContext, weapps, calses, plugins, deployOptions, options, buildTypeList, ignoreInstall, cdnEndpoints, }: {
|
|
7
8
|
buildContext: IBuildContext;
|
|
8
9
|
weapps: IWeAppData[];
|
|
9
10
|
calses: IPlatformApp[];
|
|
@@ -16,6 +17,7 @@ export declare function generateWxMp({ buildContext, weapps, calses, plugins, de
|
|
|
16
17
|
};
|
|
17
18
|
buildTypeList: BuildType[];
|
|
18
19
|
ignoreInstall: boolean;
|
|
20
|
+
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
19
21
|
}): Promise<{
|
|
20
22
|
miniprogramRoot: string;
|
|
21
23
|
}>;
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const lodash_1 = require("lodash");
|
|
|
51
51
|
const junk = __importStar(require("../util/junk"));
|
|
52
52
|
const net_1 = require("../util/net");
|
|
53
53
|
const cals_1 = require("@cloudbase/cals");
|
|
54
|
+
const core_1 = require("../core");
|
|
54
55
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
55
56
|
const em = chalk_1.default.blue.bold;
|
|
56
57
|
const error = chalk_1.default.redBright;
|
|
@@ -67,7 +68,7 @@ function patchBuildContext(ctx, calses, weapps) {
|
|
|
67
68
|
ctx.miniprogramPlugins = (mainAppData.miniprogramPlugins || []).filter((plugin) => allAppUsedComps[plugin.name]);
|
|
68
69
|
return { allAppUsedComps };
|
|
69
70
|
}
|
|
70
|
-
async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptions, options, buildTypeList, ignoreInstall = false, }) {
|
|
71
|
+
async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptions, options, buildTypeList, ignoreInstall = false, cdnEndpoints = {}, }) {
|
|
71
72
|
var _a, _b;
|
|
72
73
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
73
74
|
console.time(operationLabel);
|
|
@@ -77,7 +78,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
77
78
|
* 注意一定在入口进行处理,应当尽可能提前,后续逻辑不应该更新buildContext
|
|
78
79
|
*/
|
|
79
80
|
const { allAppUsedComps } = patchBuildContext(buildContext, calses, weapps);
|
|
80
|
-
const { appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = buildContext;
|
|
81
|
+
const { uin = '', appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = buildContext;
|
|
81
82
|
// 安装依赖库,生成 materials 目录
|
|
82
83
|
await (0, materials_1.installMaterials)(buildContext, projDir, allAppUsedComps, weapps);
|
|
83
84
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
|
|
@@ -183,6 +184,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
183
184
|
appId,
|
|
184
185
|
importJSSDK: endpointType === 'tcb-api',
|
|
185
186
|
extraDeps: resolveNpmDeps(weapps, materials),
|
|
187
|
+
cdnEndpoints,
|
|
186
188
|
},
|
|
187
189
|
};
|
|
188
190
|
}
|
|
@@ -195,8 +197,11 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
195
197
|
}
|
|
196
198
|
// 生成数据源
|
|
197
199
|
if (weapps.find((item) => !item.mpPkgUrl)) {
|
|
200
|
+
const officialLib = materials.find((item) => item.name === cals_1.OFFICIAL_LIB_KEY);
|
|
198
201
|
const datasourceFileData = {
|
|
199
|
-
'datasources/index.js': {
|
|
202
|
+
'datasources/index.js.tpl': {
|
|
203
|
+
cdnEndpoints,
|
|
204
|
+
},
|
|
200
205
|
'datasources/config.js.tpl': {
|
|
201
206
|
envID: mainAppData.envId,
|
|
202
207
|
appID: appId,
|
|
@@ -205,6 +210,10 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
205
210
|
clientID: ((_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.enableLoginStatusShare)
|
|
206
211
|
? mainAppData.envId
|
|
207
212
|
: (_b = mainAppData.extra) === null || _b === void 0 ? void 0 : _b.clientId,
|
|
213
|
+
cdnEndpoints,
|
|
214
|
+
builderVersion: core_1.version || '',
|
|
215
|
+
officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
|
|
216
|
+
uin,
|
|
208
217
|
},
|
|
209
218
|
'datasources/datasource-profiles.js.tpl': {
|
|
210
219
|
datasourceProfiles: (0, util_3.JsonToStringWithVariableName)([], { EOL: false }),
|
|
@@ -237,6 +246,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
237
246
|
appId,
|
|
238
247
|
importJSSDK: endpointType === 'tcb-api',
|
|
239
248
|
extraDeps: resolveNpmDeps(weapps, materials),
|
|
249
|
+
cdnEndpoints,
|
|
240
250
|
},
|
|
241
251
|
}, templateDir, subpackageRootPath);
|
|
242
252
|
}
|
|
@@ -358,6 +368,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
358
368
|
const pageFileData = {
|
|
359
369
|
[`api.js|api.js`]: {
|
|
360
370
|
subLevelPath,
|
|
371
|
+
packageName: rootPath || '',
|
|
361
372
|
uuid: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
362
373
|
label: ((_b = (_a = page === null || page === void 0 ? void 0 : page.data) === null || _a === void 0 ? void 0 : _a.navigationBarTitleText) === null || _b === void 0 ? void 0 : _b.value) || ((_d = (_c = page === null || page === void 0 ? void 0 : page.data) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.value),
|
|
363
374
|
},
|
|
@@ -399,9 +410,12 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
399
410
|
subWxss: rootPath && !((_l = ctx.mainAppData) === null || _l === void 0 ? void 0 : _l.mpPkgUrl)
|
|
400
411
|
? `@import "${path_1.default.posix.relative(`/packages/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
|
|
401
412
|
: '',
|
|
402
|
-
content:
|
|
403
|
-
|
|
404
|
-
|
|
413
|
+
content: [
|
|
414
|
+
(0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
|
|
415
|
+
defaultUnit: processCssUnit,
|
|
416
|
+
}), 'page'),
|
|
417
|
+
(0, util_2.generateScopedStyleText)(componentInstances),
|
|
418
|
+
].join('\n'),
|
|
405
419
|
pageWxss: importor.styles.length ? `@import "../../lowcode/${page.id}/style.wxss"` : '',
|
|
406
420
|
},
|
|
407
421
|
};
|
|
@@ -296,7 +296,7 @@ async function generateCompositeComponent(ctx, compositedComp, compLibCommonReso
|
|
|
296
296
|
.map((m) => m.name),
|
|
297
297
|
eventHandlers: (0, util_3.createEventHandlers)(compositeCtx, componentInstances, weapps_core_1.COMPONENT_API_PREFIX),
|
|
298
298
|
// protectEventKeys: builtinMpEvents,
|
|
299
|
-
emitEvents: compositedComp.emitEvents.map((evt) => evt.eventName),
|
|
299
|
+
emitEvents: (compositedComp.emitEvents || []).map((evt) => evt.eventName),
|
|
300
300
|
widgetProps: (0, util_3.createWidgetProps)(compositeCtx, componentInstances),
|
|
301
301
|
compApi: weapps_core_1.COMPONENT_API_PREFIX,
|
|
302
302
|
jsonSchemaType2jsClass: mp_1.jsonSchemaType2jsClass,
|
package/lib/builder/mp/util.d.ts
CHANGED
package/lib/builder/mp/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
3
|
+
exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
4
4
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
5
5
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
6
6
|
const weapp_1 = require("@cloudbase/lowcode-generator/lib/generator/util/weapp");
|
|
@@ -482,3 +482,36 @@ function findComponentInfo(xComponent, { materialLibs, miniprogramPlugins }) {
|
|
|
482
482
|
return compProto;
|
|
483
483
|
}
|
|
484
484
|
exports.findComponentInfo = findComponentInfo;
|
|
485
|
+
function generateScopedStyleText(widgets) {
|
|
486
|
+
const cssTextList = [];
|
|
487
|
+
function traverse(target) {
|
|
488
|
+
var _a;
|
|
489
|
+
for (const [id, widget] of Object.entries(target)) {
|
|
490
|
+
const scopedStyle = (_a = widget.xProps) === null || _a === void 0 ? void 0 : _a.scopedStyle;
|
|
491
|
+
if (scopedStyle) {
|
|
492
|
+
let cssText = scopedStyle
|
|
493
|
+
// 移除 `/* ... */` 注释
|
|
494
|
+
.replace(/\/\*(?:[\s\S]*?)\*\//g, '')
|
|
495
|
+
// 移除换行及其前后的空白符
|
|
496
|
+
.replace(/\s*\n\s*/g, '')
|
|
497
|
+
// 添加 `#wd-page-root` 前缀以增加样式权重
|
|
498
|
+
.replace(/(:root.*?{)/g, '\n#wd-page-root $1')
|
|
499
|
+
// 替换 `:root`
|
|
500
|
+
.replace(/:root/g, `.wd-comp-id-${id}`)
|
|
501
|
+
// `: ` => `:`
|
|
502
|
+
.replace(/\s*:\s*/g, ':')
|
|
503
|
+
// ` {` => `{`
|
|
504
|
+
.replace(/\s*{\s*/g, '{')
|
|
505
|
+
// `;}` => `}`
|
|
506
|
+
.replace(/;\s*}/g, '}');
|
|
507
|
+
cssTextList.push(cssText.trim());
|
|
508
|
+
}
|
|
509
|
+
if (widget.properties) {
|
|
510
|
+
traverse(widget.properties);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
traverse(widgets);
|
|
515
|
+
return cssTextList.join('\n');
|
|
516
|
+
}
|
|
517
|
+
exports.generateScopedStyleText = generateScopedStyleText;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.53",
|
|
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",
|
|
@@ -31,9 +31,12 @@
|
|
|
31
31
|
"build": "tsc",
|
|
32
32
|
"test:build": "ts-node ./__tests__/build.ts",
|
|
33
33
|
"dev:web:serve": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/web.config.js",
|
|
34
|
-
"dev:web": "rm -rf dist &&
|
|
35
|
-
"build:web": "rm -rf dist &&
|
|
34
|
+
"dev:web": "rm -rf dist && cross-env NODE_ENV=development webpack --config ./webpack/web.config.js",
|
|
35
|
+
"build:web": "rm -rf dist && cross-env NODE_ENV=production webpack --config ./webpack/web.config.js && cp -Rf dist/ lib/",
|
|
36
36
|
"build:template": "./scripts/buildTemplate.sh",
|
|
37
|
+
"dev:debug": "tsc-watch --onSuccess 'npm run build-dev-web-and-push'",
|
|
38
|
+
"build-dev-web-and-push": "npm run dev:web && clear && yalc publish --push",
|
|
39
|
+
"release": "yarn npm whoami --publish && npm run build && npm run build:web && yarn set version 1.22.19 && yarn config set version-tag-prefix '@cloudbase/lowcode-builder@' && yarn version --no-commit-hooks --message 'chore(builder): v%s' && yarn config set version-tag-prefix v && yarn set version 3.6.2 && yarn npm publish",
|
|
37
40
|
"publish:web": "node ./scripts/publish.ide.js"
|
|
38
41
|
},
|
|
39
42
|
"bugs": {
|
|
@@ -42,8 +45,8 @@
|
|
|
42
45
|
"dependencies": {
|
|
43
46
|
"@babel/core": "7.21.4",
|
|
44
47
|
"@babel/preset-env": "7.21.4",
|
|
45
|
-
"@cloudbase/cals": "^1.0.
|
|
46
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
48
|
+
"@cloudbase/cals": "^1.0.38",
|
|
49
|
+
"@cloudbase/lowcode-generator": "^1.8.15",
|
|
47
50
|
"axios": "^0.21.0",
|
|
48
51
|
"browserfs": "^1.4.3",
|
|
49
52
|
"browserify-zlib": "^0.2.0",
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
"jest": "^27.5.1",
|
|
80
83
|
"ts-loader": "^8.3.0",
|
|
81
84
|
"ts-node": "^10.4.0",
|
|
85
|
+
"tsc-watch": "^6.0.4",
|
|
82
86
|
"typescript": "^4.7.4",
|
|
83
87
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
84
88
|
"webpack-cli": "^4.9.1",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
ext1: '<%=appId%>',
|
|
32
32
|
ext3: '<%=ext3%>',
|
|
33
33
|
version: '<%= !isAdminPortal? "0.0.2" : "0.0.3" %>',
|
|
34
|
+
env: '<%= mode !== "production"? "pre" : "production" %>',
|
|
34
35
|
});
|
|
35
36
|
window._aegis = _aegis;
|
|
36
37
|
window._aegis_inited = Date.now();
|
|
@@ -449,9 +450,7 @@
|
|
|
449
450
|
</div>
|
|
450
451
|
<% }%>
|
|
451
452
|
</div>
|
|
452
|
-
<%
|
|
453
|
-
<script src="<%=jsApi %>"></script>
|
|
454
|
-
<% })%> <% if(canUseVite){ %>
|
|
453
|
+
<% if(canUseVite){ %>
|
|
455
454
|
<script type="module" src="/src/index.jsx"></script>
|
|
456
455
|
<% } %> <% if(!isAdminPortal){ %>
|
|
457
456
|
<script src="/weda-config/weda-private.js"></script>
|
|
@@ -537,11 +536,14 @@
|
|
|
537
536
|
cdnEndpoints.cdngo
|
|
538
537
|
%>/lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
|
|
539
538
|
></script>
|
|
539
|
+
<% jsApis.forEach(function(jsApi){%>
|
|
540
|
+
<script src="<%=jsApi %>"></script>
|
|
541
|
+
<% })%>
|
|
540
542
|
<script
|
|
541
543
|
crossorigin
|
|
542
544
|
src="<%=
|
|
543
545
|
cdnEndpoints.cdngo
|
|
544
|
-
%>/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.24b6f4f560a5d284c4ff.bundle.js"
|
|
545
547
|
></script>
|
|
546
548
|
</body>
|
|
547
549
|
</html>
|
package/template/mp/app.js
CHANGED
|
@@ -131,11 +131,17 @@ App({
|
|
|
131
131
|
} finally {
|
|
132
132
|
for (const queryId in app.dataset?.query || {}) {
|
|
133
133
|
if (app.dataset.query[queryId]?._schema?.trigger === 'auto') {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
/**
|
|
135
|
+
* query 初始化不阻塞生命周期
|
|
136
|
+
*/
|
|
137
|
+
Promise.resolve()
|
|
138
|
+
.then(async () => {
|
|
139
|
+
await app.dataset?.query?.[queryId]?.initPromise;
|
|
140
|
+
return app.dataset?.query?.[queryId]?.trigger?.();
|
|
141
|
+
})
|
|
142
|
+
.catch((e) => {
|
|
143
|
+
console.error(`query ${queryId} 初始化失败:`, e);
|
|
144
|
+
});
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
147
|
resolve();
|
|
@@ -49,15 +49,18 @@ Component({
|
|
|
49
49
|
if (status && status.id !== uuid) {
|
|
50
50
|
switch (this.data.type) {
|
|
51
51
|
case 'auth': {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
if( $page?.id){
|
|
53
|
+
getApp().app?.redirectTo({
|
|
54
|
+
pageId: status.id,
|
|
55
|
+
params: {
|
|
56
|
+
statusCode: "403",
|
|
57
|
+
sourcePagePackageName: $page?.__internal__.packageName,
|
|
58
|
+
sourcePageId: $page?.id,
|
|
59
|
+
sourcePageParams: $page?.dataset?.params,
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
61
64
|
}
|
|
62
65
|
case 'notfound': {
|
|
63
66
|
getApp().app?.redirectTo({
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
}
|
|
15
15
|
for (const id in widgets) {
|
|
16
16
|
const props = widgets[id]
|
|
17
|
-
dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props)
|
|
17
|
+
dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props, id)
|
|
18
18
|
}
|
|
19
19
|
const disposers = []
|
|
20
20
|
for (const k in dataFactory) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Component({})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<block></block>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* common/placeholder/index.wxss */
|
|
@@ -9,6 +9,8 @@ export class Query {
|
|
|
9
9
|
#disposes = [];
|
|
10
10
|
#dataBinds = {};
|
|
11
11
|
#triggered = false;
|
|
12
|
+
initPromise;
|
|
13
|
+
#initedResolver = (value) => {};
|
|
12
14
|
#paramsRef = observable({ current: null });
|
|
13
15
|
#currentRequestKey = null;
|
|
14
16
|
#observableValue = observable({ data: null, error: null, isFetching: false });
|
|
@@ -21,6 +23,11 @@ export class Query {
|
|
|
21
23
|
trigger: schema.trigger,
|
|
22
24
|
};
|
|
23
25
|
this.#context = context;
|
|
26
|
+
|
|
27
|
+
this.initPromise = new Promise((resolve) => {
|
|
28
|
+
this.#initedResolver = resolve;
|
|
29
|
+
});
|
|
30
|
+
|
|
24
31
|
if (this.#schema?.trigger === 'auto') {
|
|
25
32
|
this.#disposes.push(
|
|
26
33
|
autorun(
|
|
@@ -32,11 +39,15 @@ export class Query {
|
|
|
32
39
|
}
|
|
33
40
|
} catch (e) {
|
|
34
41
|
console.error(e);
|
|
42
|
+
} finally {
|
|
43
|
+
this.#initedResolver(true);
|
|
35
44
|
}
|
|
36
45
|
},
|
|
37
46
|
{ delay: 50 },
|
|
38
47
|
),
|
|
39
48
|
);
|
|
49
|
+
} else {
|
|
50
|
+
this.#initedResolver(true);
|
|
40
51
|
}
|
|
41
52
|
this.#paramsRef.current = this.#schema.data;
|
|
42
53
|
this.#dataBinds = Object.entries(this.#schema.dataBinds || {}).reduce((map, [prop, fn]) => {
|
|
@@ -49,7 +60,7 @@ export class Query {
|
|
|
49
60
|
const { $w } = this.#context;
|
|
50
61
|
|
|
51
62
|
this.#action =
|
|
52
|
-
this.#schema.type === 'sql'
|
|
63
|
+
this.#schema.type === 'sql' || this.#schema.type === 'sqlserver'
|
|
53
64
|
? async function (data) {
|
|
54
65
|
const Data = await $w.cloud.callWedaApi({
|
|
55
66
|
action: 'RunPluginQuery',
|
|
@@ -425,8 +425,14 @@ export async function getAuthConfig() {
|
|
|
425
425
|
|
|
426
426
|
let _AUTH_CACHE_MAP = {};
|
|
427
427
|
|
|
428
|
-
async function getAccessPermission(app, appId, pageId) {
|
|
429
|
-
|
|
428
|
+
async function getAccessPermission(app, appId, packageName = "", pageId) {
|
|
429
|
+
let cacheKey = `${appId}-${pageId}`;
|
|
430
|
+
if (packageName) {
|
|
431
|
+
const matched = packageName.match(/packages\/(.*)$/);
|
|
432
|
+
const subKey = matched?.[1] || packageName
|
|
433
|
+
cacheKey = `${appId}-${subKey}-${pageId}`
|
|
434
|
+
}
|
|
435
|
+
|
|
430
436
|
if (_AUTH_CACHE_MAP[cacheKey] !== undefined) {
|
|
431
437
|
return _AUTH_CACHE_MAP[cacheKey];
|
|
432
438
|
}
|
|
@@ -492,7 +498,7 @@ export async function checkAuth(app, appId, $page) {
|
|
|
492
498
|
return true;
|
|
493
499
|
}
|
|
494
500
|
wx.showNavigationBarLoading();
|
|
495
|
-
const requestList = [getAccessPermission(app, appId, $page.id)];
|
|
501
|
+
const requestList = [getAccessPermission(app, appId, $page.__internal__.packageName, $page.id)];
|
|
496
502
|
// 暂时先认为有登录页则自定义登录功能开启且生效
|
|
497
503
|
if (loginPage) {
|
|
498
504
|
requestList.push(getAuthConfig(app));
|
|
@@ -554,6 +560,7 @@ export function redirectToLogin(currentPage) {
|
|
|
554
560
|
app.redirectTo({
|
|
555
561
|
pageId: loginPage.id,
|
|
556
562
|
params: {
|
|
563
|
+
sourcePagePackageName: currentPage.__internal__.packageName || undefined,
|
|
557
564
|
sourcePageId: currentPage.id,
|
|
558
565
|
sourcePageParams: currentPage.params || currentPage.dataset?.params,
|
|
559
566
|
},
|
|
@@ -225,12 +225,17 @@ export function createPage({
|
|
|
225
225
|
// eslint-disable-next-line no-restricted-syntax
|
|
226
226
|
for (const queryId in $page.dataset?.query || {}) {
|
|
227
227
|
if ($page.dataset.query[queryId]?._schema?.trigger === 'auto') {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
/**
|
|
229
|
+
* query 初始化不阻塞生命周期
|
|
230
|
+
*/
|
|
231
|
+
Promise.resolve()
|
|
232
|
+
.then(async () => {
|
|
233
|
+
await $page.dataset.query[queryId]?.initPromise;
|
|
234
|
+
return $page.dataset.query[queryId].trigger();
|
|
235
|
+
})
|
|
236
|
+
.catch((e) => {
|
|
237
|
+
console.error(`query ${queryId} 初始化失败:`, e);
|
|
238
|
+
});
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
241
|
resolve();
|
|
@@ -386,7 +391,7 @@ export function createPage({
|
|
|
386
391
|
};
|
|
387
392
|
|
|
388
393
|
if (typeof readonlyMap[method] !== 'function') {
|
|
389
|
-
throw new Error(`调用方法失败:未找到id为${
|
|
394
|
+
throw new Error(`调用方法失败:未找到id为${componentInstance?.id}下的方法${method}`);
|
|
390
395
|
}
|
|
391
396
|
return readonlyMap[method](params);
|
|
392
397
|
};
|
|
@@ -51,7 +51,7 @@ const EXTRA_PROPS_MAP = [
|
|
|
51
51
|
return map;
|
|
52
52
|
}, {});
|
|
53
53
|
|
|
54
|
-
function resolveWidgetProp(props) {
|
|
54
|
+
function resolveWidgetProp(props, widgetId) {
|
|
55
55
|
let { classList = [], _staticResourceAttribute = ['src'], ...restProps } = props;
|
|
56
56
|
const data = {};
|
|
57
57
|
Object.keys(restProps).forEach((key) => {
|
|
@@ -64,7 +64,7 @@ function resolveWidgetProp(props) {
|
|
|
64
64
|
data[key] = restProps[key];
|
|
65
65
|
});
|
|
66
66
|
data.style = styleToCss(restProps.style);
|
|
67
|
-
data.className = classList.join ? classList.join(' ') : classList
|
|
67
|
+
data.className = `${widgetId ? `wd-comp-id-${widgetId}` : ''} ${classList.join ? classList.join(' ') : classList}`;
|
|
68
68
|
|
|
69
69
|
_staticResourceAttribute?.forEach?.((property) => {
|
|
70
70
|
processStaticResourceAttribute(data, undefined, property);
|
|
@@ -73,11 +73,11 @@ function resolveWidgetProp(props) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// widget prop -> wxml data
|
|
76
|
-
export function resolveWidgetData(props) {
|
|
76
|
+
export function resolveWidgetData(props, widgetId) {
|
|
77
77
|
if (!Array.isArray(props)) {
|
|
78
|
-
return resolveWidgetProp(props);
|
|
78
|
+
return resolveWidgetProp(props, widgetId);
|
|
79
79
|
}
|
|
80
|
-
return props.map(resolveWidgetData);
|
|
80
|
+
return props.map(prop => resolveWidgetData(prop, widgetId));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function createWidgets(widgetProps, dataBinds, ownerMpInst, widgetHolder) {
|
|
@@ -591,7 +591,7 @@ export function disposeWidget(widget, noRecursive = false) {
|
|
|
591
591
|
export function createInitData(widgets, dataBinds, keyPrefix = '') {
|
|
592
592
|
return Object.keys(widgets).reduce((result, id) => {
|
|
593
593
|
if (!isWidgetInFor(id, widgets, dataBinds)) {
|
|
594
|
-
result[keyPrefix + id] = resolveWidgetData(widgets[id]);
|
|
594
|
+
result[keyPrefix + id] = resolveWidgetData(widgets[id], id);
|
|
595
595
|
} else {
|
|
596
596
|
result[keyPrefix + id] = [];
|
|
597
597
|
}
|
|
@@ -5,7 +5,7 @@ import config from '../common/config'
|
|
|
5
5
|
/**
|
|
6
6
|
* 数据源基本配置
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
const CLOUD_CONFIG = {
|
|
9
9
|
/** 当前是否处于正式发布模式 */
|
|
10
10
|
isProd: <%= isProd %>,
|
|
11
11
|
/** 低码应用ID */
|
|
@@ -37,3 +37,25 @@ export default {
|
|
|
37
37
|
*/
|
|
38
38
|
isPrivate: config.isPrivate
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
export default CLOUD_CONFIG
|
|
42
|
+
<% if(cdnEndpoints.aegis){ %>
|
|
43
|
+
export const AEGIS_CONFIG = {
|
|
44
|
+
id: 'lXHFsBpTjIzNADiczY', // 项目ID,即上报key
|
|
45
|
+
reportApiSpeed: true, // 接口测速
|
|
46
|
+
reportAssetSpeed: true, // 静态资源测速
|
|
47
|
+
ext1: CLOUD_CONFIG.appID,
|
|
48
|
+
ext3: [
|
|
49
|
+
CLOUD_CONFIG.envID,
|
|
50
|
+
'<%= uin %>',
|
|
51
|
+
'<%= builderVersion %>',
|
|
52
|
+
'<%= officialLibVersion %>',
|
|
53
|
+
wx.getAccountInfoSync()?.miniProgram?.appId || '',
|
|
54
|
+
].join('|'),
|
|
55
|
+
version: "0.0.2",
|
|
56
|
+
env: CLOUD_CONFIG.isProd ? 'production' : 'pre',
|
|
57
|
+
|
|
58
|
+
hostUrl: 'https://rumt-zh.com', // 上报域名,中国大陆 rumt-zh.com
|
|
59
|
+
spa: true, // spa 页面需要开启,页面切换的时候上报pv
|
|
60
|
+
}
|
|
61
|
+
<% }%>
|
|
@@ -25,7 +25,11 @@ export {
|
|
|
25
25
|
initTcb,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
import config from './config'
|
|
28
|
+
import { default as config, AEGIS_CONFIG } from './config'
|
|
29
29
|
|
|
30
30
|
setConfig(config)
|
|
31
31
|
initTcb()
|
|
32
|
+
<% if(cdnEndpoints.aegis){ %>
|
|
33
|
+
import Aegis from 'aegis-mp-sdk';
|
|
34
|
+
new Aegis(AEGIS_CONFIG);
|
|
35
|
+
<% }%>
|
package/template/mp/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"version": "1.0.8",
|
|
4
4
|
"scripts": {},
|
|
5
5
|
"dependencies": {<% if(importJSSDK) {%>
|
|
6
|
-
"@cloudbase/js-sdk": "2.5.6-beta.1",<%
|
|
7
|
-
} %>
|
|
6
|
+
"@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
|
|
8
7
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
9
|
-
"@cloudbase/weda-client": "1.0.
|
|
10
|
-
"@cloudbase/weda-cloud-sdk": "1.0.46"
|
|
8
|
+
"@cloudbase/weda-client": "1.0.14",
|
|
9
|
+
"@cloudbase/weda-cloud-sdk": "1.0.46",<% if(cdnEndpoints.aegis){ %>
|
|
10
|
+
"aegis-mp-sdk": "~1.38.1",<% } %>
|
|
11
11
|
"mobx": "^5.15.4",
|
|
12
12
|
"lodash.get": "^4.4.2",
|
|
13
13
|
"lodash.set": "^4.3.2",
|
package/template/mp/page/api.js
CHANGED