@cloudbase/lowcode-builder 1.8.27 → 1.8.28
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.28",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/core": "7.12.3",
|
|
43
43
|
"@babel/preset-env": "7.12.1",
|
|
44
|
-
"@cloudbase/cals": "^1.0.
|
|
44
|
+
"@cloudbase/cals": "^1.0.18",
|
|
45
45
|
"@cloudbase/lowcode-generator": "^1.8.10",
|
|
46
46
|
"axios": "^0.21.0",
|
|
47
47
|
"browserfs": "^1.4.3",
|
|
@@ -551,7 +551,7 @@
|
|
|
551
551
|
crossorigin
|
|
552
552
|
src="<%=
|
|
553
553
|
cdnEndpoints.cdngo
|
|
554
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
554
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.5ec891fedc6dc37d6d57.bundle.js"
|
|
555
555
|
></script>
|
|
556
556
|
</body>
|
|
557
557
|
</html>
|
|
@@ -111,8 +111,9 @@ function createGlboalApi() {
|
|
|
111
111
|
|
|
112
112
|
let dataset = createDataset('$global')
|
|
113
113
|
dataset.query = generateDatasetQuery({<% Object.entries(appQuery).map(([id, item])=>{%>
|
|
114
|
-
<%= id %>: { <% const { dataBinds, eventHandlers, ...rest } = item %>
|
|
114
|
+
<%= id %>: { <% const { dataBinds, eventHandlers, handler, ...rest } = item %>
|
|
115
115
|
...(<%= stringifyObj(rest, {depth: null}) %>),
|
|
116
|
+
handler: <%= handler %>,
|
|
116
117
|
dataBinds: {<%= printBoundData(dataBinds) %>},
|
|
117
118
|
eventHandlers: {<% printEventHandler(eventHandlers) %>}
|
|
118
119
|
},<%}) %>
|
package/template/mp/app.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
<%= importor.lifecycle? "import lifeCycle from './lowcode/lifecycle'" : "const lifeCycle = {}" %>
|
|
2
|
-
import { app, $app } from './app/weapps-api'
|
|
2
|
+
import { app, $app } from './app/weapps-api';
|
|
3
3
|
// 引入数据源管理器并进行初始化
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
setConfig,
|
|
6
|
+
getAccessToken,
|
|
7
|
+
EXTRA_API,
|
|
8
|
+
createStateDataSourceVar,
|
|
9
|
+
generateParamsParser,
|
|
10
|
+
} from './datasources/index';
|
|
11
|
+
import { redirectToLogin, findLoginPage, getAuthConfig, checkAnonymous } from './common/util';
|
|
6
12
|
|
|
7
13
|
// 防止报类型不匹配warning
|
|
8
14
|
const originWarn = console.warn;
|
|
9
15
|
const warningSkipRegexp = /(type-uncompatible)|(slot "[\w-]*?" is not found)/;
|
|
10
16
|
console.warn = (...args) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
+
// 只看第一条
|
|
18
|
+
const shouldSkip = args.length > 0 && args[0][0] === '[' && args[0][1] === 'C' && warningSkipRegexp.test(args[0]);
|
|
19
|
+
if (!shouldSkip) {
|
|
20
|
+
originWarn(...args);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
17
23
|
|
|
18
24
|
// 设置数据源请求的 loading 及 toast 处理
|
|
19
25
|
setConfig({
|
|
20
26
|
beforeDSRequest: (cfg) => {
|
|
21
|
-
if (!cfg.options || !cfg.options.showLoading) return
|
|
22
|
-
app.showLoading()
|
|
27
|
+
if (!cfg.options || !cfg.options.showLoading) return;
|
|
28
|
+
app.showLoading();
|
|
23
29
|
},
|
|
24
30
|
beforeCallFunction: async (params) => {
|
|
25
31
|
try {
|
|
@@ -46,7 +52,7 @@ setConfig({
|
|
|
46
52
|
params.data.accessToken = accessToken;
|
|
47
53
|
}
|
|
48
54
|
} catch (e) {
|
|
49
|
-
if (app?.cloud?.currentUser?.userType ===
|
|
55
|
+
if (app?.cloud?.currentUser?.userType === 'externalUser' && e?.error === 'unauthenticated') {
|
|
50
56
|
app.showToast({
|
|
51
57
|
title: '登录态失效',
|
|
52
58
|
icon: 'error',
|
|
@@ -57,25 +63,45 @@ setConfig({
|
|
|
57
63
|
return params;
|
|
58
64
|
},
|
|
59
65
|
afterDSRequest: (cfg, error, result) => {
|
|
60
|
-
if (!cfg.options) return
|
|
61
|
-
if (cfg.options.showLoading) app.hideLoading()
|
|
62
|
-
if (!cfg.options.showToast) return
|
|
63
|
-
const isSuccess = !error && result && !result.code
|
|
64
|
-
app.showToast({ icon: isSuccess ? 'success' : 'error' })
|
|
66
|
+
if (!cfg.options) return;
|
|
67
|
+
if (cfg.options.showLoading) app.hideLoading();
|
|
68
|
+
if (!cfg.options.showToast) return;
|
|
69
|
+
const isSuccess = !error && result && !result.code;
|
|
70
|
+
app.showToast({ icon: isSuccess ? 'success' : 'error' });
|
|
65
71
|
},
|
|
66
72
|
async afterCallFunction(params, error, res) {
|
|
67
|
-
|
|
73
|
+
const oauthError =
|
|
74
|
+
error?.message?.includes?.('PERMISSION_DENIED') ||
|
|
75
|
+
error?.code === 'unauthenticated' ||
|
|
76
|
+
error?.error === 'unauthenticated' ||
|
|
77
|
+
error?.code === 'invalid_grant' ||
|
|
78
|
+
error?.error === 'invalid_grant' ||
|
|
79
|
+
error?.code === 'INVALID_ACCESS_TOKEN' ||
|
|
80
|
+
(error?.code === 'OPERATION_FAIL' && /^\[INVALID_ACCESS_TOKEN\]/.test(error?.message || ''));
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' &&
|
|
84
|
+
(['InnerError.AuthFailure', 'InvalidAccessToken'].includes(res?.result?.code) ||
|
|
85
|
+
oauthError)
|
|
86
|
+
) {
|
|
68
87
|
const loginPage = findLoginPage();
|
|
69
88
|
if (loginPage) {
|
|
70
89
|
const authConfig = await getAuthConfig();
|
|
71
|
-
if (authConfig.RejectStrategy
|
|
90
|
+
if (authConfig.RejectStrategy === 'to_login') {
|
|
72
91
|
if (['InnerError.AuthFailure'].includes(res?.result?.code)) {
|
|
73
92
|
const isAnonymous = await checkAnonymous();
|
|
74
93
|
if (!isAnonymous) return;
|
|
75
94
|
// 匿名用户越权去登录
|
|
76
95
|
}
|
|
77
96
|
redirectToLogin();
|
|
78
|
-
} else if (authConfig.RejectStrategy
|
|
97
|
+
} else if (authConfig.RejectStrategy === 'show_warning') {
|
|
98
|
+
if (oauthError) {
|
|
99
|
+
const isAnonymous = await checkAnonymous();
|
|
100
|
+
if (!isAnonymous) {
|
|
101
|
+
redirectToLogin(generateLoginUrl);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
79
105
|
app.showToast({
|
|
80
106
|
title: '接口无访问权限',
|
|
81
107
|
icon: 'error',
|
|
@@ -83,27 +109,27 @@ setConfig({
|
|
|
83
109
|
}
|
|
84
110
|
}
|
|
85
111
|
}
|
|
86
|
-
}
|
|
87
|
-
})
|
|
112
|
+
},
|
|
113
|
+
});
|
|
88
114
|
|
|
89
115
|
App({
|
|
90
116
|
_query: {},
|
|
91
117
|
globaldata: {
|
|
92
|
-
_beforeCustomLaunchPromise: null
|
|
118
|
+
_beforeCustomLaunchPromise: null,
|
|
93
119
|
},
|
|
94
120
|
async beforeCustomLaunch(query) {
|
|
95
|
-
if(!this.globaldata?._beforeCustomLaunchPromise){
|
|
96
|
-
if(!this.globaldata) {
|
|
97
|
-
this.globaldata = {}
|
|
121
|
+
if (!this.globaldata?._beforeCustomLaunchPromise) {
|
|
122
|
+
if (!this.globaldata) {
|
|
123
|
+
this.globaldata = {};
|
|
98
124
|
}
|
|
99
|
-
this.globaldata._beforeCustomLaunchPromise = new Promise(async (resolve)=>{
|
|
125
|
+
this.globaldata._beforeCustomLaunchPromise = new Promise(async (resolve) => {
|
|
100
126
|
try {
|
|
101
|
-
EXTRA_API.setParams('$global', query || {})
|
|
127
|
+
EXTRA_API.setParams('$global', query || {});
|
|
102
128
|
await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {}, $w: app.__internal__?.$w }));
|
|
103
129
|
} catch (e) {
|
|
104
130
|
throw e;
|
|
105
131
|
} finally {
|
|
106
|
-
for (const queryId in app.dataset?.query||{}) {
|
|
132
|
+
for (const queryId in app.dataset?.query || {}) {
|
|
107
133
|
if (app.dataset.query[queryId]?._schema?.trigger === 'auto') {
|
|
108
134
|
try {
|
|
109
135
|
app.dataset?.query?.[queryId]?.trigger?.();
|
|
@@ -112,44 +138,44 @@ App({
|
|
|
112
138
|
}
|
|
113
139
|
}
|
|
114
140
|
}
|
|
115
|
-
resolve()
|
|
141
|
+
resolve();
|
|
116
142
|
}
|
|
117
|
-
})
|
|
143
|
+
});
|
|
118
144
|
}
|
|
119
|
-
return this.globaldata._beforeCustomLaunchPromise
|
|
145
|
+
return this.globaldata._beforeCustomLaunchPromise;
|
|
120
146
|
},
|
|
121
147
|
async onLaunch(options) {
|
|
122
|
-
this.app = app
|
|
123
|
-
const onLaunch = lifeCycle.onLaunch || lifeCycle.onAppLaunch
|
|
124
|
-
let { query = {} } = options
|
|
125
|
-
this._query = query
|
|
148
|
+
this.app = app;
|
|
149
|
+
const onLaunch = lifeCycle.onLaunch || lifeCycle.onAppLaunch;
|
|
150
|
+
let { query = {} } = options;
|
|
151
|
+
this._query = query;
|
|
126
152
|
|
|
127
|
-
await this.beforeCustomLaunch(query)
|
|
128
|
-
onLaunch && onLaunch.call(this, options)
|
|
153
|
+
await this.beforeCustomLaunch(query);
|
|
154
|
+
onLaunch && onLaunch.call(this, options);
|
|
129
155
|
// 初始私有全局数据
|
|
130
156
|
this.$$global = {
|
|
131
|
-
homePageId: '<%= appConfig.homePageId %>'
|
|
132
|
-
}
|
|
157
|
+
homePageId: '<%= appConfig.homePageId %>',
|
|
158
|
+
};
|
|
133
159
|
},
|
|
134
160
|
async onShow(options) {
|
|
135
|
-
await this.beforeCustomLaunch(this._query)
|
|
136
|
-
const fn = lifeCycle.onShow || lifeCycle.onAppShow
|
|
137
|
-
fn && fn.call(this, options)
|
|
161
|
+
await this.beforeCustomLaunch(this._query);
|
|
162
|
+
const fn = lifeCycle.onShow || lifeCycle.onAppShow;
|
|
163
|
+
fn && fn.call(this, options);
|
|
138
164
|
},
|
|
139
165
|
onHide() {
|
|
140
|
-
const fn = lifeCycle.onHide || lifeCycle.onAppHide
|
|
141
|
-
fn && fn.call(this)
|
|
166
|
+
const fn = lifeCycle.onHide || lifeCycle.onAppHide;
|
|
167
|
+
fn && fn.call(this);
|
|
142
168
|
},
|
|
143
169
|
onError(msg) {
|
|
144
|
-
const fn = lifeCycle.onError || lifeCycle.onAppError
|
|
145
|
-
fn && fn.call(this, msg)
|
|
170
|
+
const fn = lifeCycle.onError || lifeCycle.onAppError;
|
|
171
|
+
fn && fn.call(this, msg);
|
|
146
172
|
},
|
|
147
173
|
onPageNotFound() {
|
|
148
|
-
const fn = lifeCycle.onPageNotFound || lifeCycle.onAppPageNotFound
|
|
149
|
-
fn && fn.call(this)
|
|
174
|
+
const fn = lifeCycle.onPageNotFound || lifeCycle.onAppPageNotFound;
|
|
175
|
+
fn && fn.call(this);
|
|
150
176
|
},
|
|
151
177
|
onUnhandledRejection() {
|
|
152
|
-
const fn = lifeCycle.onUnhandledRejection || lifeCycle.onAppUnhandledRejection
|
|
153
|
-
fn && fn.call(this)
|
|
178
|
+
const fn = lifeCycle.onUnhandledRejection || lifeCycle.onAppUnhandledRejection;
|
|
179
|
+
fn && fn.call(this);
|
|
154
180
|
},
|
|
155
|
-
})
|
|
181
|
+
});
|