@cloudbase/lowcode-builder 1.0.13 → 1.0.16

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.0.13",
3
+ "version": "1.0.16",
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",
@@ -38,8 +38,8 @@
38
38
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
39
39
  },
40
40
  "dependencies": {
41
- "@cloudbase/cals": "^0.3.35",
42
- "@cloudbase/lowcode-generator": "^1.0.3",
41
+ "@cloudbase/cals": "^0.3.37",
42
+ "@cloudbase/lowcode-generator": "^1.0.4",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "browserify-zlib": "^0.2.0",
@@ -75,10 +75,10 @@
75
75
  "jest": "^26.0.1",
76
76
  "ts-loader": "^8.3.0",
77
77
  "ts-node": "^10.4.0",
78
- "typescript": "^4.4.2",
78
+ "typescript": "^4.7.4",
79
79
  "uglifyjs-webpack-plugin": "^2.2.0",
80
80
  "webpack-cli": "^4.9.1",
81
81
  "webpack-dev-server": "^4.7.3",
82
82
  "worker-loader": "^3.0.8"
83
83
  }
84
- }
84
+ }
@@ -461,7 +461,7 @@
461
461
  ></script>
462
462
  <script
463
463
  crossorigin
464
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.03b54575136335f76391.bundle.js"
464
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.3a66f83a42344bba1e13.bundle.js"
465
465
  ></script>
466
466
  </body>
467
467
  </html>
@@ -1,14 +1,14 @@
1
1
  import { observable } from 'mobx'
2
2
  import { createMpApp } from '@cloudbase/weda-client';
3
- import { createComputed } from '<%= subLevelPath %>../common/util'
3
+ import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../common/util'
4
4
  import process from '<%= subLevelPath %>../common/process'
5
5
  import appGlobal from '<%= subLevelPath %>../app/app-global'
6
6
  import { createDataset, EXTRA_API } from '<%= subLevelPath %>../datasources/index'
7
7
 
8
8
  <% if (!isBare) {%>
9
9
  import state from '../lowcode/state'
10
- import computed from '../lowcode/computed'
11
- import common from './common'
10
+ import computed from '../lowcode/computed'
11
+ import common from './common'
12
12
  <%} else {%>
13
13
  const state = {}
14
14
  const computed = {}
@@ -38,11 +38,21 @@ function createGlboalApi() {
38
38
  common,
39
39
  ...mpApp,
40
40
  invoke(params) {
41
- return globalAPI.__internal__.activePage.invokeComponentMethod(params)
41
+ const $page = globalAPI.utils.getCurrentPage();
42
+ return $page.invokeComponentMethod(params)
42
43
  },
43
44
  // ... other sdk apis & apis from mp
44
45
  } // The global api exposed to lowcode
45
46
 
47
+ globalAPI.__internal__.enumOptions = enumOptions
48
+ globalAPI.utils.formatEnum = formatEnum
49
+ /**
50
+ * @deprecated utils._getConfig
51
+ */
52
+ globalAPI.utils._getConfig = () => {
53
+ return globalAPI.__internal__.getConfig()
54
+ }
55
+
46
56
  let dataset = createDataset('$global')
47
57
  globalAPI.dataset = dataset
48
58
  globalAPI.state.dataset = dataset
@@ -51,16 +61,6 @@ function createGlboalApi() {
51
61
  globalAPI.utils.set(globalAPI.dataset.state, keyPath, userSetState[keyPath]);
52
62
  });
53
63
  };
54
- /**
55
- * 内部通用的设置状态变量值的方法
56
- * varPath 结构为 $global.<变量名> 即全局变量
57
- * $page.<变量名> 即当前页面变量
58
- * <pageId>.<变量名> 指定页面 pageId 的变量 (应当避免修改非当前页面的变量值)
59
- */
60
- globalAPI._setStateVal = (config) => {
61
- // @ts-ignore
62
- EXTRA_API.setState(config.varPath, config.val);
63
- };
64
64
 
65
65
  const subPackageName = '<%= subPackageName %>'
66
66
  if (subPackageName) {
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
  import { findForItemsOfWidget, getWidget } from './widget'
3
- import lodashGet from 'lodash.get';
4
- import lodashSet from 'lodash.set';
3
+ import { observable } from 'mobx';
5
4
  import { getAccessToken } from '../datasources/index'
6
5
 
7
6
  /**
@@ -353,3 +352,46 @@ export function redirectToLogin(currentPage) {
353
352
  });
354
353
  }
355
354
  }
355
+
356
+ let loading = {};
357
+ export let enumOptions = observable({});
358
+ export function formatEnum(path, optionname) {
359
+ // 判断是单选还是多选
360
+ let isSingle = Array.isArray(path);
361
+ // 获取到options
362
+ let parseOptions = getEnumOptions(optionname);
363
+ if (parseOptions === '') {
364
+ return !isSingle ? path : path.join(',');
365
+ }
366
+ let multiTmp = [];
367
+ let value = !isSingle
368
+ ? JSON.parse(parseOptions)?.find((item) => item?.key === path)?.value
369
+ : JSON.parse(parseOptions)
370
+ ?.filter((item) => path.some((pathValue) => item?.key === pathValue))
371
+ .map((item) => multiTmp.push(item?.value));
372
+ // 对多选或者单选有不同处理
373
+ return !isSingle ? value : multiTmp?.join(',');
374
+ }
375
+ function getEnumOptions(optionName) {
376
+ if (enumOptions[optionName]) {
377
+ return enumOptions[optionName];
378
+ }
379
+ if (!loading[optionName]) {
380
+ loading[optionName] = true;
381
+ getGeneralOptions(optionName).then((data) => {
382
+ enumOptions[optionName] = data?.Items[0]?.Config;
383
+ });
384
+ }
385
+ return '';
386
+ }
387
+ async function getGeneralOptions(optionName) {
388
+ const { app } = getApp();
389
+ return app.cloud.callWedaApi({
390
+ action: 'DescribeGeneralOptionsDetailList',
391
+ data: {
392
+ PageSize: 1,
393
+ PageIndex: 1,
394
+ LikeNameOrTitle: optionName,
395
+ },
396
+ });
397
+ }
@@ -63,11 +63,11 @@ export function createComponent(key, behaviors, properties, events, handler, dat
63
63
 
64
64
  try {
65
65
  lifeCycle.onAttached && lifeCycle.onAttached.call($comp)
66
- this.__handlerAttached__ = (e) => {
66
+ this.__mnt__ = (e) => {
67
67
  const widget = lodashGet(widgets, e.target.id);
68
68
  widget._methods = e.detail.methods;
69
69
  }
70
- this.__handlerDetached__ = (e) => {
70
+ this.__unmnt__ = (e) => {
71
71
  const widget = lodashGet(widgets, e.target.id);
72
72
  delete widget._methods;
73
73
  }
@@ -44,15 +44,17 @@ export function createPage(
44
44
  if (res?.from === 'button' && res?.target?.dataset?.weda_share_info) {
45
45
  return res?.target?.dataset?.weda_share_info;
46
46
  }
47
- else if (pageAttributes?.appShareMessage) {
48
- let {pageId, params, imageUrl, title} = pageAttributes.appShareMessage;
49
- pageId = pageId ? pageId.replace(/^(\.)?\//,'') : pageId;
50
- let realPath = `/pages/${pageId}/index` + (params ? '?'+params.map(pair => pair.key + '=' + pair.value).join('&'):'');
51
- return {
52
- path:realPath,
47
+ else if (res?.from === 'menu' && pageAttributes?.appShareMessage) {
48
+ let { enable, pageId, params, imageUrl, title } = pageAttributes.appShareMessage;
49
+ if (enable) {
50
+ pageId = pageId ? pageId.replace(/^(\.)?\//, '') : pageId;
51
+ let realPath = `/pages/${pageId}/index` + (params ? '?' + params.map(pair => pair.key + '=' + pair.value).join('&') : '');
52
+ return {
53
+ path: realPath,
53
54
  imageUrl,
54
55
  title
55
- };
56
+ };
57
+ }
56
58
  }
57
59
  try {
58
60
  return lifecycle?.['onShareAppMessage']?.() || {};
@@ -71,7 +73,7 @@ export function createPage(
71
73
  attached() {
72
74
  const $page = this.getWeAppInst()
73
75
  this._pageActive = true;
74
- this.__handlerAttached__ = (e) => {
76
+ this.__mnt__ = (e) => {
75
77
  if (!$page.componentMethods) {
76
78
  $page.componentMethods = {};
77
79
  }
@@ -81,7 +83,7 @@ export function createPage(
81
83
  }
82
84
  $page.componentMethods[id][index] = e.detail.methods;
83
85
  };
84
- this.__handlerDetached__ = (e) => {
86
+ this.__unmnt__ = (e) => {
85
87
  const [id, index = 0] = e.target.id.split('-');
86
88
  if ($page.componentMethods) {
87
89
  const components = $page.componentMethods[id];
@@ -1 +1 @@
1
- export const $page = {};
1
+ export const $page = {}
@@ -3,7 +3,6 @@ import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
3
3
  import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
4
4
  import { app } from '<%= subLevelPath %>../../app/weapps-api'
5
5
  import { <%= pageName %> as handlers } from '../../app/handlers'
6
- // import index from '../../lowcode/<%= pageName %>/index'
7
6
  import lifecyle from '../../lowcode/<%= pageName %>/lifecycle'
8
7
  import state from '../../lowcode/<%= pageName %>/state'
9
8
  import computed from '../../lowcode/<%= pageName %>/computed'