@cloudbase/lowcode-builder 1.8.63 → 1.8.64
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 +2 -1
- package/lib/builder/config/index.js +3 -2
- package/lib/builder/core/index.js +9 -0
- package/lib/builder/h5/index.js +6 -6
- package/lib/builder/mp/BuildContext.d.ts +4 -0
- package/lib/builder/mp/index.js +4 -0
- package/lib/builder/mp/util.js +1 -1
- package/lib/builder.web.js +13 -13
- package/package.json +3 -3
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app.js +15 -3
- package/template/mp/common/util.js +41 -7
- package/template/mp/common/weapp-component.js +4 -3
- package/template/mp/common/weapp-page.js +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.64",
|
|
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",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "7.21.4",
|
|
48
48
|
"@babel/preset-env": "7.21.4",
|
|
49
|
-
"@cloudbase/cals": "^1.0.
|
|
50
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
49
|
+
"@cloudbase/cals": "^1.0.49",
|
|
50
|
+
"@cloudbase/lowcode-generator": "^1.8.18",
|
|
51
51
|
"axios": "^0.21.0",
|
|
52
52
|
"browserfs": "^1.4.3",
|
|
53
53
|
"browserify-zlib": "^0.2.0",
|
|
@@ -543,7 +543,7 @@
|
|
|
543
543
|
crossorigin
|
|
544
544
|
src="<%=
|
|
545
545
|
cdnEndpoints.cdngo
|
|
546
|
-
%>/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.66f4e5788cf846be20b3.bundle.js"
|
|
547
547
|
></script>
|
|
548
548
|
</body>
|
|
549
549
|
</html>
|
package/template/mp/app.js
CHANGED
|
@@ -70,14 +70,26 @@ setConfig({
|
|
|
70
70
|
app.showToast({ icon: isSuccess ? 'success' : 'error' });
|
|
71
71
|
},
|
|
72
72
|
async afterCallFunction(params, error, res) {
|
|
73
|
-
|
|
73
|
+
let oauthError =
|
|
74
74
|
error?.message?.includes?.('PERMISSION_DENIED') ||
|
|
75
75
|
error?.code === 'unauthenticated' ||
|
|
76
76
|
error?.error === 'unauthenticated' ||
|
|
77
77
|
error?.code === 'invalid_grant' ||
|
|
78
78
|
error?.error === 'invalid_grant' ||
|
|
79
|
-
error?.code === 'INVALID_ACCESS_TOKEN'
|
|
80
|
-
|
|
79
|
+
error?.code === 'INVALID_ACCESS_TOKEN';
|
|
80
|
+
|
|
81
|
+
if (!oauthError) {
|
|
82
|
+
try {
|
|
83
|
+
/**
|
|
84
|
+
* js-sdk v2 实现上吞了所有错误
|
|
85
|
+
* 返回 new Error(JSON.stringify({code: "OPERATION_FAIL", msg:"[INVALID_ACCESS_TOKEN]XXX"}))
|
|
86
|
+
*/
|
|
87
|
+
let tcbErrorObj = JSON.parse(error.message);
|
|
88
|
+
if (tcbErrorObj?.code === 'OPERATION_FAIL' && /\[INVALID_ACCESS_TOKEN\]/.test(tcbErrorObj.msg)) {
|
|
89
|
+
oauthError = true;
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {}
|
|
92
|
+
}
|
|
81
93
|
|
|
82
94
|
if (
|
|
83
95
|
params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' &&
|
|
@@ -489,7 +489,8 @@ export function formatErrorMsg(e) {
|
|
|
489
489
|
* 检查页面权限
|
|
490
490
|
**/
|
|
491
491
|
export async function checkAuth(app, appId, $page) {
|
|
492
|
-
return true
|
|
492
|
+
<% if(skipCheckAuth){ %> return true <% } %>
|
|
493
|
+
|
|
493
494
|
const loginPage = findLoginPage(app);
|
|
494
495
|
if (loginPage?.id === $page.id) {
|
|
495
496
|
return true;
|
|
@@ -762,11 +763,13 @@ function formatLifecycle(time) {
|
|
|
762
763
|
return str;
|
|
763
764
|
}
|
|
764
765
|
|
|
765
|
-
const PROMISE = new Promise((resolve,reject)=>{
|
|
766
|
+
const PROMISE = new Promise((resolve, reject)=>{
|
|
766
767
|
wx.request({
|
|
767
|
-
url: '
|
|
768
|
+
url: '<%= RUNTIME_CONFIG_URL %>',
|
|
768
769
|
success: res => resolve(res.data),
|
|
769
|
-
fail:
|
|
770
|
+
fail: e => {
|
|
771
|
+
resolve(<%= JSON.stringify(runtimeDynamicConfig)%>)
|
|
772
|
+
}
|
|
770
773
|
})
|
|
771
774
|
})
|
|
772
775
|
<% } %>
|
|
@@ -779,10 +782,15 @@ export async function getExpiredMessage(createdTime = 0) {
|
|
|
779
782
|
try {
|
|
780
783
|
if (createdTime) {
|
|
781
784
|
const json = await PROMISE;
|
|
782
|
-
const {
|
|
783
|
-
|
|
785
|
+
const { expLifeTime = Infinity } = json;
|
|
786
|
+
const releaseTime = wx.getAccountInfoSync()?.miniProgram?.releaseTime;
|
|
787
|
+
if(releaseTime) {
|
|
788
|
+
let date = new Date(releaseTime);
|
|
789
|
+
createdTime = date.getTime()
|
|
790
|
+
}
|
|
791
|
+
if (Date.now() - createdTime > expLifeTime) {
|
|
784
792
|
return `该版本为体验版,需要再次发布激活,每次发布应用活跃时间为${formatLifecycle(
|
|
785
|
-
|
|
793
|
+
expLifeTime,
|
|
786
794
|
)}。您也可以升级为正式版本,无应用活跃时间限制。`;
|
|
787
795
|
}
|
|
788
796
|
}
|
|
@@ -791,3 +799,29 @@ export async function getExpiredMessage(createdTime = 0) {
|
|
|
791
799
|
}
|
|
792
800
|
<% } %>
|
|
793
801
|
}
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
export function patchWdigetPropsWithEvtListeners(widgetProps, evtListeners) {
|
|
805
|
+
const actionMap = Object.keys(evtListeners).reduce((map, evtKey = '') => {
|
|
806
|
+
const matched = evtKey.match(/^on(.*?)\$(.*)$/);
|
|
807
|
+
if (matched?.[1] && matched?.[2] && !/[._]/.test(matched?.[2])) {
|
|
808
|
+
if (!map[matched?.[1]]) {
|
|
809
|
+
map[matched?.[1]] = new Set([]);
|
|
810
|
+
}
|
|
811
|
+
map[matched?.[1]].add(matched?.[2]);
|
|
812
|
+
}
|
|
813
|
+
return map;
|
|
814
|
+
}, {});
|
|
815
|
+
for (let key in widgetProps) {
|
|
816
|
+
const props = widgetProps[key];
|
|
817
|
+
if (actionMap[key]) {
|
|
818
|
+
if (!props.classList) {
|
|
819
|
+
props.classList = [];
|
|
820
|
+
}
|
|
821
|
+
props.classList = Array.from(
|
|
822
|
+
new Set([...props.classList, ...Array.from(actionMap[key]).map((trigger) => `wd-event-${trigger}`)]),
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return widgetProps;
|
|
827
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { observable } from 'mobx'
|
|
2
|
-
import { createEventHandlers, createComputed } from './util'
|
|
2
|
+
import { createEventHandlers, createComputed, patchWdigetPropsWithEvtListeners } from './util'
|
|
3
3
|
import { createWidgets, getWidget, disposeWidget } from './widget'
|
|
4
4
|
import mergeRenderer from './merge-renderer'
|
|
5
5
|
import { runWatchers } from './watch'
|
|
@@ -14,7 +14,8 @@ import { $w as baseAPI } from '../app/weapps-api'
|
|
|
14
14
|
export const compLowcodes = {}
|
|
15
15
|
|
|
16
16
|
export function createComponent(key, behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes, libCode) {
|
|
17
|
-
|
|
17
|
+
widgetProps = patchWdigetPropsWithEvtListeners(widgetProps, evtListeners)
|
|
18
|
+
|
|
18
19
|
compLowcodes[key] = {
|
|
19
20
|
index,
|
|
20
21
|
stateFn,
|
|
@@ -46,7 +47,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
46
47
|
...properties,
|
|
47
48
|
},
|
|
48
49
|
|
|
49
|
-
data:
|
|
50
|
+
data: createInitData(widgetProps, dataBinds, ''),
|
|
50
51
|
|
|
51
52
|
lifetimes: {
|
|
52
53
|
created() {
|
|
@@ -21,7 +21,7 @@ import { runWatchers } from './watch';
|
|
|
21
21
|
import { $w as baseAPI } from '../app/weapps-api';
|
|
22
22
|
import { Event } from './event-emitter';
|
|
23
23
|
import { generatePageUrl } from '@cloudbase/weda-client';
|
|
24
|
-
import { mergeDynamic2StaticData } from './util';
|
|
24
|
+
import { mergeDynamic2StaticData, patchWdigetPropsWithEvtListeners } from './util';
|
|
25
25
|
|
|
26
26
|
export const PAGE_ROOT_SYMBOL = Symbol('@@page_route@@')
|
|
27
27
|
|
|
@@ -114,6 +114,8 @@ export function createPage({
|
|
|
114
114
|
pageAttributes = {},
|
|
115
115
|
resetShare = true,
|
|
116
116
|
}) {
|
|
117
|
+
widgetProps = patchWdigetPropsWithEvtListeners(widgetProps, evtListeners)
|
|
118
|
+
|
|
117
119
|
const evtHandlers = createEventHandlers(evtListeners);
|
|
118
120
|
const {[PAGE_ROOT_SYMBOL]: pageRootDataBinds, ...componentDataBinds} = dataBinds
|
|
119
121
|
|
|
@@ -415,3 +417,4 @@ function decodePageQuery(query) {
|
|
|
415
417
|
return decoded;
|
|
416
418
|
}, {});
|
|
417
419
|
}
|
|
420
|
+
|