@cloudbase/framework-plugin-low-code 0.7.2-beta.0 → 0.7.2-beta.1
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/common.js +1 -1
- package/lib/builder/config/index.js +2 -2
- package/lib/builder/config/mp.js +1 -1
- package/lib/builder/core/copy.js +3 -3
- package/lib/builder/core/generate.js +11 -11
- package/lib/builder/core/index.js +13 -13
- package/lib/builder/core/material.js +6 -6
- package/lib/builder/core/plugin.js +3 -3
- package/lib/builder/core/prepare.js +2 -2
- package/lib/builder/core/webpack.js +5 -5
- package/lib/builder/mp/index.d.ts.map +1 -1
- package/lib/builder/mp/index.js +50 -49
- package/lib/builder/mp/lowcode.js +4 -4
- package/lib/builder/mp/materials.js +16 -16
- package/lib/builder/mp/mixMode.js +12 -12
- package/lib/builder/mp/mp_config.js +11 -11
- package/lib/builder/mp/util.js +6 -6
- package/lib/builder/mp/wxml.js +4 -4
- package/lib/builder/service/builder/copy.js +11 -11
- package/lib/builder/service/builder/generate.js +56 -52
- package/lib/builder/service/builder/index.js +2 -2
- package/lib/builder/service/builder/plugin.js +2 -2
- package/lib/builder/service/builder/webpack.js +24 -23
- package/lib/builder/types/common.js +1 -0
- package/lib/builder/util/common.d.ts.map +1 -1
- package/lib/builder/util/common.js +8 -6
- package/lib/builder/util/console.js +1 -1
- package/lib/builder/util/generateFiles.js +2 -2
- package/lib/builder/util/index.js +1 -1
- package/lib/builder/util/junk.js +4 -2
- package/lib/builder/util/mp.js +1 -1
- package/lib/builder/util/net.js +1 -1
- package/lib/builder/util/style.js +1 -1
- package/lib/builder/util/weapp.js +1 -1
- package/lib/generate.js +2 -2
- package/lib/generator/config/index.js +2 -2
- package/lib/generator/core/generate.js +36 -34
- package/lib/generator/core/index.js +4 -4
- package/lib/generator/core/material.js +14 -14
- package/lib/generator/types/common.js +6 -3
- package/lib/generator/util/common.d.ts.map +1 -1
- package/lib/generator/util/common.js +1 -1
- package/lib/generator/util/index.js +1 -1
- package/lib/generator/util/style.js +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +104 -66
- package/lib/utils/common.d.ts +1 -1
- package/lib/utils/common.d.ts.map +1 -1
- package/lib/utils/common.js +2 -2
- package/lib/utils/dataSource.js +2 -2
- package/lib/utils/index.js +1 -1
- package/lib/utils/postProcess.js +3 -3
- package/lib/weapps-core/config/index.js +1 -1
- package/lib/weapps-core/index.js +2 -2
- package/lib/weapps-core/types/index.js +1 -1
- package/lib/weapps-core/utils/appbuild.js +6 -3
- package/lib/weapps-core/utils/common.js +3 -2
- package/lib/weapps-core/utils/formily.js +37 -37
- package/lib/weapps-core/utils/index.js +1 -1
- package/lib/weapps-core/utils/style.js +15 -15
- package/package.json +1 -1
- package/template/mp/app/weapps-api.js +13 -5
- package/template/mp/app.js +59 -48
- package/template/mp/common/util.js +6 -4
- package/template/mp/common/weapp-page.js +2 -2
- package/template/src/app/global-api.js +15 -3
- package/template/src/handlers/utils/common.js +26 -20
- package/template/src/index.jsx +3 -2
|
@@ -17,9 +17,9 @@ function serialize(webRuntimeAppData) {
|
|
|
17
17
|
vars: webRuntimeAppData.vars || { data: [] },
|
|
18
18
|
dataset: webRuntimeAppData.dataset,
|
|
19
19
|
};
|
|
20
|
-
common_1.setValidValue(weAppData, 'appConfig', webRuntimeAppData.appConfig);
|
|
21
|
-
common_1.setValidValue(weAppData, 'themeVars', webRuntimeAppData.themeVars);
|
|
22
|
-
common_1.setValidValue(weAppData, 'presetColors', webRuntimeAppData.presetColors);
|
|
20
|
+
(0, common_1.setValidValue)(weAppData, 'appConfig', webRuntimeAppData.appConfig);
|
|
21
|
+
(0, common_1.setValidValue)(weAppData, 'themeVars', webRuntimeAppData.themeVars);
|
|
22
|
+
(0, common_1.setValidValue)(weAppData, 'presetColors', webRuntimeAppData.presetColors);
|
|
23
23
|
handlePageInstanceList(webRuntimeAppData.pageInstanceList, weAppData.pageInstanceList);
|
|
24
24
|
function handlePageInstanceList(pageInstanceList, collection) {
|
|
25
25
|
pageInstanceList.map((pageData) => {
|
|
@@ -27,20 +27,20 @@ function serialize(webRuntimeAppData) {
|
|
|
27
27
|
const newPage = {
|
|
28
28
|
id: pageData.id,
|
|
29
29
|
};
|
|
30
|
-
common_1.setValidValue(newPage, 'isHome', pageData.isHome);
|
|
31
|
-
common_1.setValidValue(newPage, 'data', readDynamicData(pageData));
|
|
32
|
-
common_1.setValidValue(newPage, 'commonStyle', style_1.removeInvalidStyleFormValue(pageData.style));
|
|
33
|
-
common_1.setValidValue(newPage, 'styleBindPath', pageData.styleBindPath);
|
|
34
|
-
if (common_1.isValidStyleBind(pageData.styleBind)) {
|
|
35
|
-
common_1.setValidValue(newPage, 'styleBind', pageData.styleBind);
|
|
30
|
+
(0, common_1.setValidValue)(newPage, 'isHome', pageData.isHome);
|
|
31
|
+
(0, common_1.setValidValue)(newPage, 'data', readDynamicData(pageData));
|
|
32
|
+
(0, common_1.setValidValue)(newPage, 'commonStyle', (0, style_1.removeInvalidStyleFormValue)(pageData.style));
|
|
33
|
+
(0, common_1.setValidValue)(newPage, 'styleBindPath', pageData.styleBindPath);
|
|
34
|
+
if ((0, common_1.isValidStyleBind)(pageData.styleBind)) {
|
|
35
|
+
(0, common_1.setValidValue)(newPage, 'styleBind', pageData.styleBind);
|
|
36
36
|
}
|
|
37
|
-
if (common_1.isValidClassNameListBind(pageData.classNameListBind)) {
|
|
38
|
-
common_1.setValidValue(newPage, 'classNameListBind', pageData.classNameListBind);
|
|
37
|
+
if ((0, common_1.isValidClassNameListBind)(pageData.classNameListBind)) {
|
|
38
|
+
(0, common_1.setValidValue)(newPage, 'classNameListBind', pageData.classNameListBind);
|
|
39
39
|
}
|
|
40
|
-
common_1.setValidValue(newPage, 'componentInstances', readComponents(pageData.componentSchemaJson.properties));
|
|
41
|
-
common_1.setValidValue(newPage, 'listeners', readListeners(pageData.listenerInstances));
|
|
42
|
-
common_1.setValidValue(newPage, 'pluginInstances', pageData.pluginInstances);
|
|
43
|
-
common_1.setValidValue(newPage, 'lowCodes', pageData.codeModules);
|
|
40
|
+
(0, common_1.setValidValue)(newPage, 'componentInstances', readComponents(pageData.componentSchemaJson.properties));
|
|
41
|
+
(0, common_1.setValidValue)(newPage, 'listeners', readListeners(pageData.listenerInstances));
|
|
42
|
+
(0, common_1.setValidValue)(newPage, 'pluginInstances', pageData.pluginInstances);
|
|
43
|
+
(0, common_1.setValidValue)(newPage, 'lowCodes', pageData.codeModules);
|
|
44
44
|
if ((_a = pageData.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
45
45
|
newPage.children = newPage.children || [];
|
|
46
46
|
handlePageInstanceList(pageData.children, newPage.children);
|
|
@@ -60,41 +60,41 @@ function serialize(webRuntimeAppData) {
|
|
|
60
60
|
if (srcProps) {
|
|
61
61
|
const cmpParts = srcProps.sourceKey.split(':');
|
|
62
62
|
cmps[key] = { genericComp: srcCmp['genericComp'] };
|
|
63
|
-
common_1.setValidValue(cmps[key], 'xComponent', {
|
|
63
|
+
(0, common_1.setValidValue)(cmps[key], 'xComponent', {
|
|
64
64
|
moduleName: cmpParts[0],
|
|
65
65
|
name: cmpParts[1],
|
|
66
66
|
});
|
|
67
67
|
const componentXProps = {};
|
|
68
|
-
common_1.setValidValue(componentXProps, 'data', readDynamicData(srcProps));
|
|
69
|
-
common_1.setValidValue(componentXProps, 'listeners', readListeners(srcProps.listenerInstances));
|
|
70
|
-
common_1.setValidValue(componentXProps, 'staticResourceAttribute', srcProps.staticResourceAttribute);
|
|
71
|
-
common_1.setValidValue(componentXProps, 'directives', readDirectives(srcProps));
|
|
72
|
-
common_1.setValidValue(componentXProps, 'customDataForm', srcProps.customDataForm);
|
|
73
|
-
common_1.setValidValue(componentXProps, 'style', srcProps.style);
|
|
74
|
-
common_1.setValidValue(componentXProps, 'commonStyle', style_1.removeInvalidStyleFormValue(srcProps.commonStyle));
|
|
75
|
-
common_1.setValidValue(componentXProps, 'styleBindPath', srcProps.styleBindPath);
|
|
68
|
+
(0, common_1.setValidValue)(componentXProps, 'data', readDynamicData(srcProps));
|
|
69
|
+
(0, common_1.setValidValue)(componentXProps, 'listeners', readListeners(srcProps.listenerInstances));
|
|
70
|
+
(0, common_1.setValidValue)(componentXProps, 'staticResourceAttribute', srcProps.staticResourceAttribute);
|
|
71
|
+
(0, common_1.setValidValue)(componentXProps, 'directives', readDirectives(srcProps));
|
|
72
|
+
(0, common_1.setValidValue)(componentXProps, 'customDataForm', srcProps.customDataForm);
|
|
73
|
+
(0, common_1.setValidValue)(componentXProps, 'style', srcProps.style);
|
|
74
|
+
(0, common_1.setValidValue)(componentXProps, 'commonStyle', (0, style_1.removeInvalidStyleFormValue)(srcProps.commonStyle));
|
|
75
|
+
(0, common_1.setValidValue)(componentXProps, 'styleBindPath', srcProps.styleBindPath);
|
|
76
76
|
if ((_a = srcProps.styleBind) === null || _a === void 0 ? void 0 : _a.bindDataPath) {
|
|
77
77
|
componentXProps.styleBind = {
|
|
78
78
|
type: srcProps.styleBind.type,
|
|
79
79
|
value: srcProps.styleBind.bindDataPath,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
if (common_1.isValidClassNameListBind(srcProps.classNameListBind)) {
|
|
82
|
+
if ((0, common_1.isValidClassNameListBind)(srcProps.classNameListBind)) {
|
|
83
83
|
const classList = srcProps.classNameListBind;
|
|
84
|
-
common_1.setValidValue(componentXProps, 'classListBind', {
|
|
84
|
+
(0, common_1.setValidValue)(componentXProps, 'classListBind', {
|
|
85
85
|
type: classList.type,
|
|
86
86
|
value: classList.bindDataPath,
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
if (srcProps.classNameList) {
|
|
90
|
-
common_1.setValidValue(componentXProps, 'classList', srcProps.classNameList);
|
|
90
|
+
(0, common_1.setValidValue)(componentXProps, 'classList', srcProps.classNameList);
|
|
91
91
|
}
|
|
92
|
-
common_1.setValidValue(cmps[key], 'xProps', componentXProps);
|
|
93
|
-
common_1.setValidValue(cmps[key], 'xIndex', srcCmp['x-index']);
|
|
92
|
+
(0, common_1.setValidValue)(cmps[key], 'xProps', componentXProps);
|
|
93
|
+
(0, common_1.setValidValue)(cmps[key], 'xIndex', srcCmp['x-index']);
|
|
94
94
|
const excludeKeys = (srcProps.dataTypes || [])
|
|
95
95
|
.filter((dataType) => dataType.type !== 'slot')
|
|
96
96
|
.map((dataType) => dataType.propertyPath);
|
|
97
|
-
common_1.setValidValue(cmps[key], 'properties', readComponents(srcCmp.properties, excludeKeys));
|
|
97
|
+
(0, common_1.setValidValue)(cmps[key], 'properties', readComponents(srcCmp.properties, excludeKeys));
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
100
|
cmps[key] = { properties: readComponents(srcCmp.properties) };
|
|
@@ -212,7 +212,7 @@ function deserialize(weAppData) {
|
|
|
212
212
|
page.vars = srcPage.vars ? srcPage.vars : page.vars;
|
|
213
213
|
page.isHome = srcPage.isHome || false;
|
|
214
214
|
page.style = srcPage.commonStyle || {};
|
|
215
|
-
common_1.setValidValue(page, 'styleBindPath', srcPage.styleBindPath);
|
|
215
|
+
(0, common_1.setValidValue)(page, 'styleBindPath', srcPage.styleBindPath);
|
|
216
216
|
page.codeModules = srcPage.lowCodes || [];
|
|
217
217
|
page.pluginInstances = srcPage.pluginInstances || [];
|
|
218
218
|
page.componentSchemaJson = {
|
|
@@ -264,7 +264,7 @@ function readCmpInstances(cmps) {
|
|
|
264
264
|
xProps.style = cmp.xProps.style || {};
|
|
265
265
|
xProps.commonStyle = cmp.xProps.commonStyle || {};
|
|
266
266
|
xProps.staticResourceAttribute = cmp.xProps.staticResourceAttribute || [];
|
|
267
|
-
common_1.setValidValue(xProps, 'styleBindPath', cmp.xProps.styleBindPath);
|
|
267
|
+
(0, common_1.setValidValue)(xProps, 'styleBindPath', cmp.xProps.styleBindPath);
|
|
268
268
|
let { classList, classListBind } = cmp.xProps;
|
|
269
269
|
const { styleBind } = cmp.xProps;
|
|
270
270
|
const legacyClassList = classList;
|
|
@@ -277,9 +277,9 @@ function readCmpInstances(cmps) {
|
|
|
277
277
|
classListBind = classListBind;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
classList && common_1.setValidValue(xProps, 'classNameList', classList);
|
|
280
|
+
classList && (0, common_1.setValidValue)(xProps, 'classNameList', classList);
|
|
281
281
|
classListBind &&
|
|
282
|
-
common_1.setValidValue(xProps, 'classNameListBind', {
|
|
282
|
+
(0, common_1.setValidValue)(xProps, 'classNameListBind', {
|
|
283
283
|
type: classListBind.type,
|
|
284
284
|
propertyPath: 'classNameList',
|
|
285
285
|
bindDataPath: classListBind.value,
|
|
@@ -330,10 +330,10 @@ function readCmpInstances(cmps) {
|
|
|
330
330
|
xProps.data = xProps.data || {};
|
|
331
331
|
xProps.data._visible = true;
|
|
332
332
|
}
|
|
333
|
-
common_1.setValidValue(target, 'x-component', xCmp.toLocaleLowerCase());
|
|
334
|
-
common_1.setValidValue(xProps, 'customDataForm', cmp.xProps.customDataForm);
|
|
333
|
+
(0, common_1.setValidValue)(target, 'x-component', xCmp.toLocaleLowerCase());
|
|
334
|
+
(0, common_1.setValidValue)(xProps, 'customDataForm', cmp.xProps.customDataForm);
|
|
335
335
|
target['x-props'] = xProps;
|
|
336
|
-
common_1.setValidValue(target, 'x-index', cmp.xIndex);
|
|
336
|
+
(0, common_1.setValidValue)(target, 'x-index', cmp.xIndex);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
return properties;
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./formily"), exports);
|
|
@@ -76,9 +76,9 @@ function toCssStyle(commonStyle = {}, options = { toRem: true, ignoreSelf: false
|
|
|
76
76
|
if (radius !== undefined) {
|
|
77
77
|
setStyleValue(style, 'borderRadius', _handleStyleNumValue(radius, !!options.addPXUnit));
|
|
78
78
|
}
|
|
79
|
-
if (radiusInfo && !common_1.isEmptyObj(radiusInfo)) {
|
|
79
|
+
if (radiusInfo && !(0, common_1.isEmptyObj)(radiusInfo)) {
|
|
80
80
|
if (Object.keys(radiusInfo).length === 4) {
|
|
81
|
-
if (uniq_1.default(map_1.default(radiusInfo, (val) => val)).length === 1) {
|
|
81
|
+
if ((0, uniq_1.default)((0, map_1.default)(radiusInfo, (val) => val)).length === 1) {
|
|
82
82
|
setStyleValue(style, 'borderRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
|
|
83
83
|
}
|
|
84
84
|
else if (radiusInfo.topLeft === radiusInfo.bottomRight &&
|
|
@@ -120,7 +120,7 @@ function toCssStyle(commonStyle = {}, options = { toRem: true, ignoreSelf: false
|
|
|
120
120
|
setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
|
|
121
121
|
}
|
|
122
122
|
setStyleValue(style, 'backgroundPosition', position);
|
|
123
|
-
if (positionObj && !common_1.isEmptyObj(positionObj)) {
|
|
123
|
+
if (positionObj && !(0, common_1.isEmptyObj)(positionObj)) {
|
|
124
124
|
style.background += ` ${_handleStyleNumValue(positionObj.left, !!options.addPXUnit)} ${_handleStyleNumValue(positionObj.top, !!options.addPXUnit)}`;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -166,7 +166,7 @@ exports.toCssStyle = toCssStyle;
|
|
|
166
166
|
function removeInvalidStyleFormValue(styleForm = {}) {
|
|
167
167
|
return Object.keys(styleForm).reduce((result, key) => {
|
|
168
168
|
const propStyleFormData = styleForm[key];
|
|
169
|
-
if (common_1.isPlainObject(propStyleFormData)) {
|
|
169
|
+
if ((0, common_1.isPlainObject)(propStyleFormData)) {
|
|
170
170
|
setStyleValue(result, key, removeInvalidStyleFormValue(propStyleFormData));
|
|
171
171
|
}
|
|
172
172
|
else {
|
|
@@ -178,24 +178,24 @@ function removeInvalidStyleFormValue(styleForm = {}) {
|
|
|
178
178
|
exports.removeInvalidStyleFormValue = removeInvalidStyleFormValue;
|
|
179
179
|
function setDistanceStyle(style, distance, attr, addPXUnit) {
|
|
180
180
|
if (Object.keys(distance).length === 4) {
|
|
181
|
-
if (uniq_1.default(map_1.default(distance, (val) => val)).length === 1) {
|
|
182
|
-
setStyleValue(style, common_1.camelcase(`${attr}`), _handleStyleNumValue(distance.top, addPXUnit));
|
|
181
|
+
if ((0, uniq_1.default)((0, map_1.default)(distance, (val) => val)).length === 1) {
|
|
182
|
+
setStyleValue(style, (0, common_1.camelcase)(`${attr}`), _handleStyleNumValue(distance.top, addPXUnit));
|
|
183
183
|
}
|
|
184
184
|
else if (distance.top === distance.bottom &&
|
|
185
185
|
distance.left === distance.right) {
|
|
186
|
-
setStyleValue(style, common_1.camelcase(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
|
|
186
|
+
setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
|
|
187
187
|
}
|
|
188
188
|
else if (distance.left === distance.right) {
|
|
189
|
-
setStyleValue(style, common_1.camelcase(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
|
|
189
|
+
setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
setStyleValue(style, common_1.camelcase(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
|
|
192
|
+
setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
else {
|
|
196
196
|
config_1.DISTANCE_KEY_LIST.forEach((key) => {
|
|
197
197
|
if (distance[key] !== undefined)
|
|
198
|
-
setStyleValue(style, common_1.camelcase(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
|
|
198
|
+
setStyleValue(style, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -227,10 +227,10 @@ function setStyleValue(object, key, value) {
|
|
|
227
227
|
if (key === 'open') {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
if (common_1.isEmptyObj(value)) {
|
|
230
|
+
if ((0, common_1.isEmptyObj)(value)) {
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
|
-
object[common_1.camelcase(key)] = value;
|
|
233
|
+
object[(0, common_1.camelcase)(key)] = value;
|
|
234
234
|
}
|
|
235
235
|
function calPxToREM(px) {
|
|
236
236
|
if (Number.isNaN(px / 28))
|
|
@@ -280,7 +280,7 @@ exports.toRPX = toRPX;
|
|
|
280
280
|
function removeWrapperBadEffectStyle(commonStyle = {}) {
|
|
281
281
|
return Object.keys(commonStyle).reduce((result, key) => {
|
|
282
282
|
const value = commonStyle[key];
|
|
283
|
-
const camelcaseKey = common_1.camelcase(key);
|
|
283
|
+
const camelcaseKey = (0, common_1.camelcase)(key);
|
|
284
284
|
if (config_1.WRAPPER_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
|
|
285
285
|
return result;
|
|
286
286
|
}
|
|
@@ -296,7 +296,7 @@ function removeEffectTwiceStyle(commonStyle = {}) {
|
|
|
296
296
|
const style = {};
|
|
297
297
|
Object.keys(commonStyle).map((key) => {
|
|
298
298
|
const value = commonStyle[key];
|
|
299
|
-
const camelcaseKey = common_1.camelcase(key);
|
|
299
|
+
const camelcaseKey = (0, common_1.camelcase)(key);
|
|
300
300
|
if (config_1.SELF_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
|
|
301
301
|
return false;
|
|
302
302
|
}
|
|
@@ -313,7 +313,7 @@ function toCssText(style, className = '.some-class-name') {
|
|
|
313
313
|
const attrText = Object.keys(style)
|
|
314
314
|
.map((key) => {
|
|
315
315
|
const value = style[key];
|
|
316
|
-
return `${common_1.kebabCase(key)}: ${value};`;
|
|
316
|
+
return `${(0, common_1.kebabCase)(key)}: ${value};`;
|
|
317
317
|
})
|
|
318
318
|
.join('\n');
|
|
319
319
|
return `${className} { ${attrText} }\n`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.7.2-beta.
|
|
3
|
+
"version": "0.7.2-beta.1",
|
|
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",
|
|
@@ -25,7 +25,12 @@ function createGlboalApi() {
|
|
|
25
25
|
id: '<%= appId %>',
|
|
26
26
|
domain: '<%= domain %>',
|
|
27
27
|
platform: 'MINIPROGRAME',
|
|
28
|
-
|
|
28
|
+
__internal__: {
|
|
29
|
+
activePage: null,
|
|
30
|
+
getConfig: function () {
|
|
31
|
+
return <%= appConfig %>;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
29
34
|
dataSources: DS_SDK,
|
|
30
35
|
pages: {},
|
|
31
36
|
session: {
|
|
@@ -39,7 +44,7 @@ function createGlboalApi() {
|
|
|
39
44
|
common,
|
|
40
45
|
relaunchHome: function () {
|
|
41
46
|
let wx_pages = getCurrentPages();
|
|
42
|
-
const { pages = [] } = globalAPI.
|
|
47
|
+
const { pages = [] } = globalAPI.__internal__.getConfig();
|
|
43
48
|
if (
|
|
44
49
|
wx_pages[0]?.route?.match(/pages\/(.*)\/index/)?.[1] === pages[0]?.id
|
|
45
50
|
) {
|
|
@@ -55,8 +60,11 @@ function createGlboalApi() {
|
|
|
55
60
|
formatEnum,
|
|
56
61
|
get: getter,
|
|
57
62
|
set: setter,
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
*/
|
|
66
|
+
_getConfig(){
|
|
67
|
+
return globalAPI.__internal__.getConfig()
|
|
60
68
|
},
|
|
61
69
|
async getWXContext() {
|
|
62
70
|
const { Data } = await globalAPI.cloud.callWedaApi({
|
|
@@ -68,7 +76,7 @@ function createGlboalApi() {
|
|
|
68
76
|
return typeof Data === 'string' ? JSON.parse(Data) : Data
|
|
69
77
|
},
|
|
70
78
|
getCurrentPage: function(){
|
|
71
|
-
return globalAPI.activePage
|
|
79
|
+
return globalAPI.__internal__.activePage
|
|
72
80
|
}
|
|
73
81
|
},
|
|
74
82
|
// ... other sdk apis & apis from mp
|
package/template/mp/app.js
CHANGED
|
@@ -20,64 +20,75 @@ const wxReport = new WxReportV2({
|
|
|
20
20
|
});
|
|
21
21
|
<% }%>
|
|
22
22
|
|
|
23
|
-
// 设置数据源请求的 loading 及 toast 处理
|
|
24
|
-
setConfig({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// 设置数据源请求的 loading 及 toast 处理
|
|
24
|
+
setConfig({
|
|
25
|
+
beforeDSRequest: (cfg) => {
|
|
26
|
+
if (!cfg.options || !cfg.options.showLoading) return
|
|
27
|
+
app.showLoading()
|
|
28
|
+
},
|
|
29
|
+
beforeCallFunction: async (params) => {
|
|
30
|
+
try {
|
|
31
|
+
const loginPage = findLoginPage();
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
let skip = false;
|
|
34
|
+
switch (params?.data?.methodName) {
|
|
35
|
+
case 'callWedaApi': {
|
|
36
|
+
if (['GetMiniProgramUserTicket', 'DescribeRuntimeResourceStrategy'].includes(params?.data?.params.action)) {
|
|
37
|
+
skip = true;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
38
40
|
}
|
|
39
|
-
break;
|
|
40
41
|
}
|
|
41
|
-
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
return params;
|
|
56
|
-
},
|
|
57
|
-
afterDSRequest: (cfg, error, result) => {
|
|
58
|
-
if (!cfg.options) return
|
|
59
|
-
if (cfg.options.showLoading) app.hideLoading()
|
|
60
|
-
if (!cfg.options.showToast) return
|
|
61
|
-
const isSuccess = !error && result && !result.code
|
|
62
|
-
app.showToast({ icon: isSuccess ? 'success' : 'error' })
|
|
63
|
-
},
|
|
64
|
-
async afterCallFunction(params, error, res) {
|
|
65
|
-
if (params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' && ['InnerError.AuthFailure','InvalidAccessToken'].includes(res?.result?.code)) {
|
|
66
|
-
const loginPage = findLoginPage();
|
|
67
|
-
if (loginPage) {
|
|
68
|
-
const authConfig = await getAuthConfig();
|
|
69
|
-
if (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login') {
|
|
70
|
-
redirectToLogin();
|
|
71
|
-
} else if (authConfig.RejectStrategy == 'show_warning') {
|
|
43
|
+
// 后续做过滤处理
|
|
44
|
+
if (!loginPage || (params?.data?.mode === 'c' && skip)) {
|
|
45
|
+
return params;
|
|
46
|
+
}
|
|
47
|
+
// await initTcb();
|
|
48
|
+
const { accessToken } = await getAccessToken();
|
|
49
|
+
if (accessToken) {
|
|
50
|
+
params.data.accessToken = accessToken;
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
if (app?.cloud?.currentUser?.userType === "externalUser" && e?.error === 'unauthenticated') {
|
|
72
54
|
app.showToast({
|
|
73
|
-
title: '
|
|
55
|
+
title: '登录态失效',
|
|
74
56
|
icon: 'error',
|
|
75
57
|
});
|
|
76
58
|
}
|
|
59
|
+
console.error('beforeCallFunction error', e);
|
|
60
|
+
}
|
|
61
|
+
return params;
|
|
62
|
+
},
|
|
63
|
+
afterDSRequest: (cfg, error, result) => {
|
|
64
|
+
if (!cfg.options) return
|
|
65
|
+
if (cfg.options.showLoading) app.hideLoading()
|
|
66
|
+
if (!cfg.options.showToast) return
|
|
67
|
+
const isSuccess = !error && result && !result.code
|
|
68
|
+
app.showToast({ icon: isSuccess ? 'success' : 'error' })
|
|
69
|
+
},
|
|
70
|
+
async afterCallFunction(params, error, res) {
|
|
71
|
+
if (params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' && ['InnerError.AuthFailure', 'InvalidAccessToken'].includes(res?.result?.code)) {
|
|
72
|
+
const loginPage = findLoginPage();
|
|
73
|
+
if (loginPage) {
|
|
74
|
+
const authConfig = await getAuthConfig();
|
|
75
|
+
let isAnonymous = true;
|
|
76
|
+
try {
|
|
77
|
+
const { accessToken } = await getAccessToken();
|
|
78
|
+
isAnonymous = !accessToken;
|
|
79
|
+
} catch (e) { }
|
|
80
|
+
if (isAnonymous && authConfig.RejectStrategy == 'to_login') {
|
|
81
|
+
redirectToLogin();
|
|
82
|
+
} else if (authConfig.RejectStrategy == 'show_warning') {
|
|
83
|
+
app.showToast({
|
|
84
|
+
title: '接口无访问权限',
|
|
85
|
+
icon: 'error',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
}
|
|
80
|
-
})
|
|
91
|
+
})
|
|
81
92
|
|
|
82
93
|
App({
|
|
83
94
|
onLaunch(options) {
|
|
@@ -235,7 +235,7 @@ export function setter(context, path, value = undefined) {
|
|
|
235
235
|
|
|
236
236
|
export function findLoginPage() {
|
|
237
237
|
const { app } = getApp();
|
|
238
|
-
const { pages = [] } = app.
|
|
238
|
+
const { pages = [] } = app.__internal__.getConfig();
|
|
239
239
|
return pages.find(item => item.type === 'login');
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -312,8 +312,11 @@ export async function checkAuth(app, appId, $page) {
|
|
|
312
312
|
const [isAccess, authConfig] = await Promise.all(requestList);
|
|
313
313
|
app.hideNavigationBarLoading();
|
|
314
314
|
|
|
315
|
+
const { accessToken } = await getAccessToken()
|
|
316
|
+
const isAnonymousUser = !accessToken
|
|
317
|
+
|
|
315
318
|
if (!isAccess) {
|
|
316
|
-
if (loginPage && (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login')) {
|
|
319
|
+
if (isAnonymousUser && loginPage && (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login')) {
|
|
317
320
|
redirectToLogin($page);
|
|
318
321
|
} else {
|
|
319
322
|
app.showToast({
|
|
@@ -324,8 +327,7 @@ export async function checkAuth(app, appId, $page) {
|
|
|
324
327
|
} else if (loginPage && authConfig.NeedLogin) {
|
|
325
328
|
// 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
|
|
326
329
|
try {
|
|
327
|
-
|
|
328
|
-
if (!accessToken) {
|
|
330
|
+
if (isAnonymousUser) {
|
|
329
331
|
redirectToLogin($page);
|
|
330
332
|
}
|
|
331
333
|
} catch (e) {
|
|
@@ -89,7 +89,7 @@ export function createPage(
|
|
|
89
89
|
onLoad(options) {
|
|
90
90
|
const $page = this.getWeAppInst()
|
|
91
91
|
|
|
92
|
-
app.activePage = $page;
|
|
92
|
+
app.__internal__.activePage = $page;
|
|
93
93
|
setConfig({ currentPageId: $page.uuid });
|
|
94
94
|
this._pageActive = true;
|
|
95
95
|
|
|
@@ -109,7 +109,7 @@ export function createPage(
|
|
|
109
109
|
},
|
|
110
110
|
async onShow() {
|
|
111
111
|
const $page = this.getWeAppInst()
|
|
112
|
-
app.activePage = $page;
|
|
112
|
+
app.__internal__.activePage = $page;
|
|
113
113
|
setConfig({ currentPageId: $page.uuid });
|
|
114
114
|
$page.widgets = this._widgets;
|
|
115
115
|
this._pageActive = true;
|
|
@@ -17,6 +17,9 @@ export const app = createGlboalApi();
|
|
|
17
17
|
export const $page = createPageApi();
|
|
18
18
|
|
|
19
19
|
export function setCurrentPage(pageCtx) {
|
|
20
|
+
try {
|
|
21
|
+
app.__internal__.activePage = pageCtx
|
|
22
|
+
} catch(e) { }
|
|
20
23
|
Object.assign($page, pageCtx);
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -25,6 +28,12 @@ function createGlboalApi() {
|
|
|
25
28
|
id: '<%= appId %>',
|
|
26
29
|
domain: '<%= domain %>',
|
|
27
30
|
platform: 'WEB',
|
|
31
|
+
__internal__: {
|
|
32
|
+
activePage: null,
|
|
33
|
+
getConfig: function () {
|
|
34
|
+
return <%= appConfig %>;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
28
37
|
formActions: {},
|
|
29
38
|
pages: {},
|
|
30
39
|
session: {
|
|
@@ -38,7 +47,7 @@ function createGlboalApi() {
|
|
|
38
47
|
common,
|
|
39
48
|
dataSources: DS_SDK,
|
|
40
49
|
relaunchHome: function () {
|
|
41
|
-
const { pages = [] } = globalAPI.
|
|
50
|
+
const { pages = [] } = globalAPI.__internal__.getConfig();
|
|
42
51
|
if (pages[0]) {
|
|
43
52
|
globalAPI.reLaunch({
|
|
44
53
|
pageId: pages[0].id,
|
|
@@ -50,8 +59,11 @@ function createGlboalApi() {
|
|
|
50
59
|
formatEnum,
|
|
51
60
|
get: getter,
|
|
52
61
|
set: setter,
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
*/
|
|
65
|
+
_getConfig(){
|
|
66
|
+
return globalAPI.__internal__.getConfig()
|
|
55
67
|
},
|
|
56
68
|
getWXContext: function () {
|
|
57
69
|
return Promise.resolve({})
|
|
@@ -150,7 +150,7 @@ export function getStaticResourceAttribute(staticUrl) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export function findLoginPage(app = window.app) {
|
|
153
|
-
const { pages = [] } = app.
|
|
153
|
+
const { pages = [] } = app.__internal__.getConfig();
|
|
154
154
|
return pages.find(item => item.type === 'login');
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -209,6 +209,19 @@ async function getAccessPermission(app, appId, pageId) {
|
|
|
209
209
|
return isAccess
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
export async function checkAnonymous() {
|
|
213
|
+
// 用户是否非匿名登录前端判断条件:有accessToken且scope不为anonymous
|
|
214
|
+
// 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
|
|
215
|
+
let isAnonymous = true;
|
|
216
|
+
try {
|
|
217
|
+
const [scope, { accessToken }] = await Promise.all([loginScope(), getAccessToken()]);
|
|
218
|
+
if (accessToken && scope !== 'anonymous') {
|
|
219
|
+
isAnonymous = false;
|
|
220
|
+
}
|
|
221
|
+
} catch (e) { }
|
|
222
|
+
return isAnonymous;
|
|
223
|
+
}
|
|
224
|
+
|
|
212
225
|
/**
|
|
213
226
|
* 检查页面权限
|
|
214
227
|
**/
|
|
@@ -223,31 +236,24 @@ export async function checkAuth(app, appId, $page) {
|
|
|
223
236
|
// 暂时先认为有登录页则自定义登录功能开启且生效
|
|
224
237
|
if (loginPage) {
|
|
225
238
|
requestList.push(getAuthConfig(app));
|
|
239
|
+
requestList.push(checkAnonymous());
|
|
226
240
|
}
|
|
227
|
-
const [isAccess, authConfig] = await Promise.all(requestList);
|
|
241
|
+
const [isAccess, authConfig, isAnonymous] = await Promise.all(requestList);
|
|
228
242
|
app.hideNavigationBarLoading();
|
|
229
243
|
|
|
230
|
-
if (
|
|
231
|
-
if (
|
|
232
|
-
redirectToLogin($page);
|
|
233
|
-
} else {
|
|
234
|
-
app.showToast({
|
|
235
|
-
title: '页面无访问权限',
|
|
236
|
-
icon: 'error',
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
} else if (loginPage && authConfig.NeedLogin) {
|
|
240
|
-
// 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
|
|
241
|
-
try {
|
|
242
|
-
const [scope, { accessToken }] = await Promise.all([loginScope(), getAccessToken()]);
|
|
243
|
-
if (!accessToken || scope === 'anonymous') {
|
|
244
|
-
redirectToLogin($page);
|
|
245
|
-
}
|
|
246
|
-
} catch (e) {
|
|
247
|
-
console.error('获取身份失败', e);
|
|
244
|
+
if (loginPage && isAnonymous) {
|
|
245
|
+
if (authConfig.NeedLogin || (!isAccess && authConfig.RejectStrategy === 'to_login')) {
|
|
248
246
|
redirectToLogin($page);
|
|
247
|
+
return isAccess;
|
|
249
248
|
}
|
|
250
249
|
}
|
|
250
|
+
|
|
251
|
+
if (!isAccess) {
|
|
252
|
+
app.showToast({
|
|
253
|
+
title: '页面无访问权限',
|
|
254
|
+
icon: 'error',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
251
257
|
return isAccess;
|
|
252
258
|
}
|
|
253
259
|
|
package/template/src/index.jsx
CHANGED
|
@@ -12,7 +12,7 @@ import attachFastClick from 'fastclick'
|
|
|
12
12
|
import { initWebConfig } from 'handlers/lifecycle'
|
|
13
13
|
const AppConfig = require('../webpack/miniprogram.config')
|
|
14
14
|
import { app } from './app/global-api'
|
|
15
|
-
import { redirectToLogin, findLoginPage, getAuthConfig } from './handlers/utils'
|
|
15
|
+
import { redirectToLogin, findLoginPage, getAuthConfig, checkAnonymous } from './handlers/utils'
|
|
16
16
|
// app 中注册配置页面以及app的全局配置miniprogram.config,h5里分app以及web页分别处理,使用process.env.isApp 区分判断
|
|
17
17
|
if (process.env.isApp) {
|
|
18
18
|
initWebConfig(app, AppConfig);
|
|
@@ -63,7 +63,8 @@ setConfig({
|
|
|
63
63
|
const loginPage = findLoginPage();
|
|
64
64
|
if (loginPage) {
|
|
65
65
|
const authConfig = await getAuthConfig();
|
|
66
|
-
|
|
66
|
+
const isAnonymous = await checkAnonymous();
|
|
67
|
+
if (isAnonymous && authConfig.RejectStrategy == 'to_login') {
|
|
67
68
|
redirectToLogin();
|
|
68
69
|
} else if (authConfig.RejectStrategy == 'show_warning') {
|
|
69
70
|
app.showToast({
|