@cloudbase/framework-plugin-low-code 0.6.55 → 0.6.58-alpha.0

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.
Files changed (66) hide show
  1. package/lib/builder/config/common.js +1 -1
  2. package/lib/builder/config/index.js +2 -2
  3. package/lib/builder/config/mp.js +1 -1
  4. package/lib/builder/core/copy.js +3 -3
  5. package/lib/builder/core/generate.d.ts.map +1 -1
  6. package/lib/builder/core/generate.js +18 -14
  7. package/lib/builder/core/index.js +13 -13
  8. package/lib/builder/core/material.js +6 -6
  9. package/lib/builder/core/plugin.js +3 -3
  10. package/lib/builder/core/prepare.js +2 -2
  11. package/lib/builder/core/webpack.js +5 -5
  12. package/lib/builder/mp/index.d.ts.map +1 -1
  13. package/lib/builder/mp/index.js +54 -50
  14. package/lib/builder/mp/lowcode.js +4 -4
  15. package/lib/builder/mp/materials.js +16 -16
  16. package/lib/builder/mp/mixMode.js +12 -12
  17. package/lib/builder/mp/mp_config.js +11 -11
  18. package/lib/builder/mp/util.js +6 -6
  19. package/lib/builder/mp/wxml.js +4 -4
  20. package/lib/builder/service/builder/copy.js +11 -11
  21. package/lib/builder/service/builder/generate.d.ts.map +1 -1
  22. package/lib/builder/service/builder/generate.js +58 -60
  23. package/lib/builder/service/builder/index.js +2 -2
  24. package/lib/builder/service/builder/plugin.js +2 -2
  25. package/lib/builder/service/builder/webpack.js +23 -24
  26. package/lib/builder/types/common.js +0 -1
  27. package/lib/builder/util/common.js +6 -8
  28. package/lib/builder/util/console.js +1 -1
  29. package/lib/builder/util/generateFiles.js +2 -2
  30. package/lib/builder/util/index.js +1 -1
  31. package/lib/builder/util/junk.js +2 -4
  32. package/lib/builder/util/mp.js +1 -1
  33. package/lib/builder/util/net.js +1 -1
  34. package/lib/builder/util/style.js +1 -1
  35. package/lib/builder/util/weapp.js +1 -1
  36. package/lib/generate.js +2 -2
  37. package/lib/generator/config/index.js +2 -2
  38. package/lib/generator/core/generate.js +34 -36
  39. package/lib/generator/core/index.js +4 -4
  40. package/lib/generator/core/material.js +14 -14
  41. package/lib/generator/types/common.js +3 -6
  42. package/lib/generator/util/index.js +1 -1
  43. package/lib/generator/util/style.js +2 -2
  44. package/lib/index.js +53 -58
  45. package/lib/utils/common.d.ts +1 -1
  46. package/lib/utils/common.d.ts.map +1 -1
  47. package/lib/utils/common.js +2 -2
  48. package/lib/utils/dataSource.js +2 -2
  49. package/lib/utils/index.js +1 -1
  50. package/lib/utils/postProcess.js +3 -3
  51. package/lib/weapps-core/config/index.js +1 -1
  52. package/lib/weapps-core/index.js +2 -2
  53. package/lib/weapps-core/types/index.js +1 -1
  54. package/lib/weapps-core/utils/appbuild.js +3 -6
  55. package/lib/weapps-core/utils/common.js +2 -3
  56. package/lib/weapps-core/utils/file.d.ts +1 -1
  57. package/lib/weapps-core/utils/formily.js +37 -37
  58. package/lib/weapps-core/utils/index.js +1 -1
  59. package/lib/weapps-core/utils/style.js +15 -15
  60. package/package.json +1 -1
  61. package/template/html/index.html.ejs +6 -3
  62. package/template/mp/common/weapp-page.js +23 -11
  63. package/template/mp/component/index.js +2 -2
  64. package/template/mp/page/index.js +2 -2
  65. package/template/package.json +1 -0
  66. package/template/src/pages/app.tpl +53 -11
@@ -17,9 +17,9 @@ function serialize(webRuntimeAppData) {
17
17
  vars: webRuntimeAppData.vars || { data: [] },
18
18
  dataset: webRuntimeAppData.dataset,
19
19
  };
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);
20
+ common_1.setValidValue(weAppData, 'appConfig', webRuntimeAppData.appConfig);
21
+ common_1.setValidValue(weAppData, 'themeVars', webRuntimeAppData.themeVars);
22
+ 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
- (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);
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);
36
36
  }
37
- if ((0, common_1.isValidClassNameListBind)(pageData.classNameListBind)) {
38
- (0, common_1.setValidValue)(newPage, 'classNameListBind', pageData.classNameListBind);
37
+ if (common_1.isValidClassNameListBind(pageData.classNameListBind)) {
38
+ common_1.setValidValue(newPage, 'classNameListBind', pageData.classNameListBind);
39
39
  }
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);
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);
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
- (0, common_1.setValidValue)(cmps[key], 'xComponent', {
63
+ common_1.setValidValue(cmps[key], 'xComponent', {
64
64
  moduleName: cmpParts[0],
65
65
  name: cmpParts[1],
66
66
  });
67
67
  const componentXProps = {};
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);
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);
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 ((0, common_1.isValidClassNameListBind)(srcProps.classNameListBind)) {
82
+ if (common_1.isValidClassNameListBind(srcProps.classNameListBind)) {
83
83
  const classList = srcProps.classNameListBind;
84
- (0, common_1.setValidValue)(componentXProps, 'classListBind', {
84
+ 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
- (0, common_1.setValidValue)(componentXProps, 'classList', srcProps.classNameList);
90
+ common_1.setValidValue(componentXProps, 'classList', srcProps.classNameList);
91
91
  }
92
- (0, common_1.setValidValue)(cmps[key], 'xProps', componentXProps);
93
- (0, common_1.setValidValue)(cmps[key], 'xIndex', srcCmp['x-index']);
92
+ common_1.setValidValue(cmps[key], 'xProps', componentXProps);
93
+ 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
- (0, common_1.setValidValue)(cmps[key], 'properties', readComponents(srcCmp.properties, excludeKeys));
97
+ 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
- (0, common_1.setValidValue)(page, 'styleBindPath', srcPage.styleBindPath);
215
+ 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
- (0, common_1.setValidValue)(xProps, 'styleBindPath', cmp.xProps.styleBindPath);
267
+ 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 && (0, common_1.setValidValue)(xProps, 'classNameList', classList);
280
+ classList && common_1.setValidValue(xProps, 'classNameList', classList);
281
281
  classListBind &&
282
- (0, common_1.setValidValue)(xProps, 'classNameListBind', {
282
+ 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
- (0, common_1.setValidValue)(target, 'x-component', xCmp.toLocaleLowerCase());
334
- (0, common_1.setValidValue)(xProps, 'customDataForm', cmp.xProps.customDataForm);
333
+ common_1.setValidValue(target, 'x-component', xCmp.toLocaleLowerCase());
334
+ common_1.setValidValue(xProps, 'customDataForm', cmp.xProps.customDataForm);
335
335
  target['x-props'] = xProps;
336
- (0, common_1.setValidValue)(target, 'x-index', cmp.xIndex);
336
+ 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" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(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 && !(0, common_1.isEmptyObj)(radiusInfo)) {
79
+ if (radiusInfo && !common_1.isEmptyObj(radiusInfo)) {
80
80
  if (Object.keys(radiusInfo).length === 4) {
81
- if ((0, uniq_1.default)((0, map_1.default)(radiusInfo, (val) => val)).length === 1) {
81
+ if (uniq_1.default(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 && !(0, common_1.isEmptyObj)(positionObj)) {
123
+ if (positionObj && !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 ((0, common_1.isPlainObject)(propStyleFormData)) {
169
+ if (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 ((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));
181
+ if (uniq_1.default(map_1.default(distance, (val) => val)).length === 1) {
182
+ setStyleValue(style, 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, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
186
+ setStyleValue(style, 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, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
189
+ setStyleValue(style, common_1.camelcase(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
190
190
  }
191
191
  else {
192
- setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
192
+ setStyleValue(style, 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, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
198
+ setStyleValue(style, 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 ((0, common_1.isEmptyObj)(value)) {
230
+ if (common_1.isEmptyObj(value)) {
231
231
  return;
232
232
  }
233
- object[(0, common_1.camelcase)(key)] = value;
233
+ object[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 = (0, common_1.camelcase)(key);
283
+ const camelcaseKey = 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 = (0, common_1.camelcase)(key);
299
+ const camelcaseKey = 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 `${(0, common_1.kebabCase)(key)}: ${value};`;
316
+ return `${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.6.55",
3
+ "version": "0.6.58-alpha.0",
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",
@@ -411,12 +411,15 @@
411
411
  const isPrivate = sessionStorage.getItem('__URL_QUERY_IS_PRIVATE');
412
412
  if (isPrivate === 'true') {
413
413
  document.write(
414
- `<script src="//static.cloudbase.net/cloudbase-js-sdk/2.0.1-alpha.0/cloudbase.full.js?v=1><\/script>`
414
+ `<script src="//static.cloudbase.net/cloudbase-js-sdk/2.0.1-alpha.1/cloudbase.full.js?v=1><\/script>`
415
415
  );
416
416
  } else {
417
417
  document.write(
418
- `<script src="//static.cloudbase.net/cloudbase-js-sdk/1.5.3-alpha.0/cloudbase.full.js?v=1"><\/script>`
418
+ `<script src="//static.cloudbase.net/cloudbase-js-sdk/2.0.1-alpha.1/cloudbase.full.js?v=1><\/script>`
419
419
  );
420
+ // document.write(
421
+ // `<script src="//static.cloudbase.net/cloudbase-js-sdk/1.5.3-alpha.0/cloudbase.full.js?v=1"><\/script>`
422
+ // );
420
423
  }
421
424
  })();
422
425
  </script>
@@ -479,7 +482,7 @@
479
482
  ></script>
480
483
  <script
481
484
  crossorigin="anonymous"
482
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.5/dist/h5.browser.js?v=1"
485
+ src="https://cdn.jsdelivr.net/npm/@cloudbase/weda-cloud-sdk@1.0.8-alpha.1/dist/h5.browser.js?v=1"
483
486
  ></script>
484
487
  <script>
485
488
  // zxing polifill
@@ -15,16 +15,6 @@ export function createPage(
15
15
  $page,
16
16
  context,
17
17
  ) {
18
- $page.state = observable(pageState);
19
- let dataset = createDataset($page.uuid);
20
- $page.dataset = dataset;
21
- $page.state.dataset = dataset;
22
- $page.computed = createComputed(pageComputed);
23
- $page.setState = (userSetState) => {
24
- Object.keys(userSetState).forEach((keyPath) => {
25
- app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
26
- });
27
- };
28
18
  const evtHandlers = createEventHandlers(evtListeners, context);
29
19
 
30
20
  function extractLifecyles() {
@@ -57,6 +47,7 @@ export function createPage(
57
47
  data: createInitData(widgetProps, dataBinds),
58
48
  lifetimes: {
59
49
  attached() {
50
+ const $page = this.getWeAppInst()
60
51
  // createWidgets 从上面移到这里是为了 i18n 切换语言的时候页面能生效
61
52
  $page.widgets = {};
62
53
  const { rootWidget, widgets } = createWidgets(widgetProps, dataBinds, $page.widgets, context);
@@ -83,6 +74,8 @@ export function createPage(
83
74
  ...evtHandlers,
84
75
  ...mergeRenderer,
85
76
  onLoad(options) {
77
+ const $page = this.getWeAppInst()
78
+
86
79
  app.activePage = $page;
87
80
  setConfig({ currentPageId: $page.uuid });
88
81
  this._pageActive = true;
@@ -95,12 +88,14 @@ export function createPage(
95
88
  hook && hook.call(this, query);
96
89
  },
97
90
  onUnload() {
91
+ const $page = this.getWeAppInst()
98
92
  this._disposers.forEach(dispose => dispose());
99
93
 
100
94
  const hook = lifecycle.onUnload || lifecycle.onPageUnload;
101
95
  hook && hook.call(this);
102
96
  },
103
97
  async onShow() {
98
+ const $page = this.getWeAppInst()
104
99
  app.activePage = $page;
105
100
  setConfig({ currentPageId: $page.uuid });
106
101
  $page.widgets = this._widgets;
@@ -117,12 +112,29 @@ export function createPage(
117
112
  }
118
113
  },
119
114
  onHide() {
115
+ const $page = this.getWeAppInst()
120
116
  const hook = lifecycle.onHide || lifecycle.onPageHide;
121
117
  hook && hook.call(this);
122
118
  this._pageActive = false;
123
119
  },
124
120
 
125
- getWeAppInst: () => $page,
121
+ getWeAppInst() {
122
+ if(!this.$WEAPPS_PAGE){
123
+ $page.state = observable(pageState);
124
+ let dataset = createDataset($page.uuid);
125
+ $page.dataset = dataset;
126
+ $page.state.dataset = dataset;
127
+ $page.computed = createComputed(pageComputed);
128
+ $page.setState = (userSetState) => {
129
+ Object.keys(userSetState).forEach((keyPath) => {
130
+ app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
131
+ });
132
+ };
133
+
134
+ this.$WEAPPS_PAGE = $page;
135
+ }
136
+ return this.$WEAPPS_PAGE
137
+ },
126
138
  },
127
139
  });
128
140
  }
@@ -25,7 +25,7 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
25
25
  handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
26
26
  data: <%= stringifyObj(l.data, {depth: null}) %>,
27
27
  boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for=forItems; return (
28
- <%= expr %>
28
+ <%= expr === ''? 'undefined': expr %>
29
29
  )},
30
30
  <%}) %>}
31
31
  },<%})%>
@@ -55,7 +55,7 @@ const handler = {<% handlers.forEach(h => {%>
55
55
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
56
56
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
57
57
  <%= prop %>: function (lists, forItems, event, $context) {const $for=forItems; return (
58
- <%= expr %>
58
+ <%= expr === '' ? 'undefined': expr %>
59
59
  ); },<% }) %>
60
60
  },<%}) %>
61
61
  }
@@ -20,7 +20,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
20
20
  handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
21
21
  data: <%= stringifyObj(l.data, {depth: null}) %>,
22
22
  boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for = forItems; return (
23
- <%= expr %>
23
+ <%= expr === '' ? 'undefined': expr %>
24
24
  )},
25
25
  <%}) %>}
26
26
  },<%})%>
@@ -29,7 +29,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
29
29
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
30
30
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
31
31
  <%= prop %>: function (lists, forItems, event, $context) {const $for = forItems; return (
32
- <%= expr %>
32
+ <%= expr === '' ? 'undefined': expr %>
33
33
  ); },<% }) %>
34
34
  },<%}) %>
35
35
  }
@@ -44,6 +44,7 @@
44
44
  "postcss-pxtorem": "^6.0.0",
45
45
  "postcss-loader": "^4.0.3",
46
46
  "postcss-css-variables": "^0.16.0",
47
+ "qiankun": "^2.7.0",
47
48
  "less": "^4.0.0",
48
49
  "less-loader": "^7.0.1",
49
50
  "sass-loader": "^8.0.0",
@@ -6,9 +6,6 @@ import { initLifeCycle, pageLifeCycleMount } from 'handlers/lifecycle'
6
6
  import { createComputed } from 'utils'
7
7
  import AppLifeCycle from 'lowcode/lifecycle'
8
8
  import { createDataset, createStateDataSourceVar, generateParamsParser, EXTRA_API } from '../../datasources'
9
- import PageLifeCycle from '../../lowcode/<%= pageName %>/lifecycle'
10
- import initPageState from '../../lowcode/<%= pageName %>/state'
11
- import computed from '../../lowcode/<%= pageName %>/computed'
12
9
  import { $$_<%= pageName %> as handler } from '../../app/handlers'
13
10
  import { app as mainApp } from 'app/global-api' // 取主包app
14
11
  import { app, $page } from '../../app/global-api' // 取对应子包app
@@ -16,6 +13,23 @@ import { createWidgets, retryDataBinds, resolveComponentProps, checkAuth, report
16
13
  import { useScrollTop } from 'handlers/hooks'
17
14
  import { get } from "lodash";
18
15
  import './index.less'
16
+ <% if(pageSource){ %>
17
+ import { loadMicroApp } from 'qiankun';
18
+ const PageLifeCycle = {};
19
+ const initPageState = {};
20
+ const computed = {}
21
+ <% } else { %>
22
+ import PageLifeCycle from '../../lowcode/<%= pageName %>/lifecycle'
23
+ import initPageState from '../../lowcode/<%= pageName %>/state'
24
+ import computed from '../../lowcode/<%= pageName %>/computed'
25
+ function loadMicroApp(){
26
+ return new Proxy({}, {
27
+ get(obj, prop) {
28
+ return (...args) => {};
29
+ },
30
+ })
31
+ }
32
+ <% } %>
19
33
 
20
34
  let ReactDOMServer;
21
35
 
@@ -65,6 +79,10 @@ export default function App() {
65
79
  // 检查权限
66
80
  const [weDaHasLogin, setWeDaHasLogin] = React.useState(false);
67
81
  const context = React.useRef(observable({})).current;
82
+ const containerRef = React.useRef(null);
83
+ const microApp = React.useRef(null);
84
+ const pureSrc = '<%= pageSource %>';
85
+ const isPure = !!pureSrc;
68
86
 
69
87
  /**
70
88
  * 更新数据容器的上下文的方法
@@ -107,6 +125,11 @@ export default function App() {
107
125
  app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
108
126
  });
109
127
  };
128
+ return () => {
129
+ if (microApp.current) {
130
+ microApp.current.unmount();
131
+ }
132
+ };
110
133
  }, []);
111
134
 
112
135
  React.useEffect(() => {
@@ -123,23 +146,42 @@ export default function App() {
123
146
  pageLifeCycleMount(React.useEffect, PageLifeCycle, app)
124
147
  }
125
148
 
149
+ React.useEffect(() => {
150
+ if (isPure) {
151
+ if (weDaHasLogin) {
152
+ if (!microApp.current) {
153
+ microApp.current = loadMicroApp({
154
+ name: '<%= pageName %>',
155
+ entry: pureSrc,
156
+ container: containerRef.current,
157
+ });
158
+ } else {
159
+ microApp.current.mount?.();
160
+ }
161
+ } else if (microApp.current) {
162
+ microApp.current.unmount();
163
+ }
164
+ }
165
+ }, [weDaHasLogin]);
166
+
126
167
  useScrollTop();
127
168
 
128
169
  return (
129
- <div className="weapps-page">
170
+ <div className="weapps-page" ref={containerRef}>
130
171
  <style
131
172
  type="text/css"
132
173
  dangerouslySetInnerHTML={{
133
174
  __html: `<%= pageStyleText %>`,
134
175
  }}
135
176
  />
136
- {weDaHasLogin && (
137
- <AppRender pageListenerInstances={pageListenerInstances}
138
- virtualFields={virtualFields}
139
- componentSchema={componentSchema}
140
- context={context}
141
- updateContext={updateContext}
142
- />)}
177
+ {weDaHasLogin && !isPure && (
178
+ <AppRender pageListenerInstances={pageListenerInstances}
179
+ virtualFields={virtualFields}
180
+ componentSchema={componentSchema}
181
+ context={context}
182
+ updateContext={updateContext}
183
+ />
184
+ )}
143
185
  </div>
144
186
  );
145
187
  }