@cloudbase/framework-plugin-low-code 0.7.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.7.0",
3
+ "version": "0.7.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",
@@ -448,7 +448,7 @@
448
448
  ></script>
449
449
  <script
450
450
  crossorigin="anonymous"
451
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.8-alpha.11/dist/h5.browser.js?v=1"
451
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.8-alpha.12/dist/h5.browser.js?v=1"
452
452
  ></script>
453
453
  <script>
454
454
  // zxing polifill
@@ -1,5 +1,5 @@
1
1
  import { observable } from 'mobx'
2
- import { createComputed, formatDate, getter, setter } from '<%= subLevelPath %>../common/util'
2
+ import { createComputed, formatDate, getter, setter, formatEnum, enumOptions} from '<%= subLevelPath %>../common/util'
3
3
  import process from '<%= subLevelPath %>../common/process'
4
4
  import { DS_SDK, CLOUD_SDK, createDataset, EXTRA_API } from '<%= subLevelPath %>../datasources/index'
5
5
  import appGlobal from '<%= subLevelPath %>../app/app-global'
@@ -33,6 +33,7 @@ function createGlboalApi() {
33
33
  //request: sdk.request,
34
34
  //getSessionId: sdk.getSessionId,
35
35
  },
36
+ enumOptions: enumOptions,
36
37
  state: observable(state),
37
38
  computed: createComputed(computed),
38
39
  common,
@@ -51,6 +52,7 @@ function createGlboalApi() {
51
52
  },
52
53
  utils: {
53
54
  formatDate,
55
+ formatEnum,
54
56
  get: getter,
55
57
  set: setter,
56
58
  _getConfig: function () {
@@ -3,6 +3,8 @@
3
3
  import { findForItemsOfWidget, mpCompToWidget } from './widget'
4
4
  import lodashGet from 'lodash.get';
5
5
  import lodashSet from 'lodash.set';
6
+ import { observable } from 'mobx';
7
+ import { app } from '../app/weapps-api'
6
8
  import { getAccessToken } from '@cloudbase/weda-cloud-sdk'
7
9
 
8
10
  /**
@@ -646,8 +648,52 @@ class CustomDate {
646
648
 
647
649
  const dataInstance = new CustomDate();
648
650
  export const formatDate = new CustomDate().format.bind(dataInstance);
651
+
652
+ let loading = {};
653
+ export let enumOptions = observable({});
654
+ export function formatEnum(path, optionname) {
655
+ // 判断是单选还是多选
656
+ let isSingle = Array.isArray(path);
657
+ // 获取到options
658
+ let parseOptions = getEnumOptions(optionname);
659
+ if (parseOptions === '') {
660
+ return !isSingle ? path : path.join(',');
661
+ }
662
+ let multiTmp = [];
663
+ let value = !isSingle
664
+ ? JSON.parse(parseOptions)?.find((item) => item?.key === path)?.value
665
+ : JSON.parse(parseOptions)
666
+ ?.filter((item) => path.some((pathValue) => item?.key === pathValue))
667
+ .map((item) => multiTmp.push(item?.value));
668
+ // 对多选或者单选有不同处理
669
+ return !isSingle ? value : multiTmp?.join(',');
670
+ }
671
+ function getEnumOptions(optionName) {
672
+ if (enumOptions[optionName]) {
673
+ return enumOptions[optionName];
674
+ }
675
+ if (!loading[optionName]) {
676
+ loading[optionName] = true;
677
+ getGeneralOptions(optionName).then((data) => {
678
+ enumOptions[optionName] = data?.Items[0]?.Config;
679
+ });
680
+ }
681
+ return '';
682
+ }
683
+ export async function getGeneralOptions(optionName) {
684
+ return app.cloud.callWedaApi({
685
+ action: 'DescribeGeneralOptionsDetailList',
686
+ data: {
687
+ PageSize: 1,
688
+ PageIndex: 1,
689
+ LikeNameOrTitle: optionName,
690
+ },
691
+ });
692
+ }
693
+
649
694
  export const utils = {
650
695
  formatDate,
651
696
  get: getter,
652
697
  set: setter,
698
+ formatEnum
653
699
  };
@@ -14,6 +14,7 @@ export function createPage(
14
14
  app,
15
15
  $page,
16
16
  context,
17
+ pageAttributes
17
18
  ) {
18
19
  const evtHandlers = createEventHandlers(evtListeners, context);
19
20
 
@@ -32,6 +33,18 @@ export function createPage(
32
33
  if (res?.from === 'button' && res?.target?.dataset?.weda_share_info) {
33
34
  return res?.target?.dataset?.weda_share_info;
34
35
  }
36
+ if (res?.from === 'menu' && pageAttributes?.appShareMessage) {
37
+ let { enable, pageId, params, imageUrl, title } = pageAttributes.appShareMessage;
38
+ if (enable) {
39
+ pageId = pageId ? pageId.replace(/^(\.)?\//, '') : pageId;
40
+ let realPath = `/pages/${pageId}/index` + (params ? '?' + params.map(pair => pair.key + '=' + pair.value).join('&') : '');
41
+ return {
42
+ path: realPath,
43
+ imageUrl,
44
+ title
45
+ };
46
+ }
47
+ }
35
48
  try {
36
49
  return lifecycle?.['onShareAppMessage']?.() || {};
37
50
  } catch (error) {
@@ -119,7 +132,7 @@ export function createPage(
119
132
  },
120
133
 
121
134
  getWeAppInst() {
122
- if(!this.$WEAPPS_PAGE){
135
+ if (!this.$WEAPPS_PAGE) {
123
136
  $page.state = observable(pageState);
124
137
  let dataset = createDataset($page.uuid);
125
138
  $page.dataset = dataset;
@@ -3,7 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "scripts": {},
5
5
  "dependencies": {
6
- "@cloudbase/weda-cloud-sdk": "1.0.8-alpha.11",
6
+ "@cloudbase/weda-cloud-sdk": "1.0.8-alpha.12",
7
7
  "@cloudbase/oauth": "0.1.1-alpha.2",
8
8
  "mobx": "^5.15.4",
9
9
  "lodash.get": "^4.4.2",
@@ -14,4 +14,4 @@
14
14
  })
15
15
  %>
16
16
  }
17
- }
17
+ }
@@ -34,7 +34,9 @@ const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
34
34
  },<%}) %>
35
35
  }
36
36
 
37
+ const pageAttributes = <%= pageAttributes?JSON.stringify(pageAttributes):'{}' %>
38
+
37
39
  $page.id = '<%= pageName %>'
38
40
  $page.uuid = '<%= pageUUID %>'
39
41
  $page.handler = handlers
40
- createPage(lifecyle, widgetProps, state, computed, evtListeners, dataBinds, app, $page, context)
42
+ createPage(lifecyle, widgetProps, state, computed, evtListeners, dataBinds, app, $page, context,pageAttributes)
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "dependencies": {
8
8
  "@cloudbase/js-sdk": "1.5.3-alpha.0",
9
- "@cloudbase/weda-cloud-sdk": "1.0.8-alpha.11",
9
+ "@cloudbase/weda-cloud-sdk": "1.0.8-alpha.12",
10
10
  "@tcwd/weapps-core": "2.2.6",
11
11
  "@tcwd/weapps-sdk": "1.2.9",
12
12
  "@zxing/library": "^0.18.6",
@@ -60,4 +60,4 @@
60
60
  "webpack-cli": "^4.2.0",
61
61
  "webpack-dev-server": "^3.11.0"
62
62
  }
63
- }
63
+ }
@@ -5,6 +5,7 @@ import store, { subPackageName } from '../store';
5
5
  import computed from '../store/computed';
6
6
  import common from './common';
7
7
  import { formatDate } from '../utils/date';
8
+ import { formatEnum, enumOptions } from '../utils/formatEnum';
8
9
  import { getter, setter, _isMobile } from '../utils';
9
10
  import actionMap from './material-actions';
10
11
  import { scanCodeApi } from '../utils/scan-code-action';
@@ -31,6 +32,7 @@ function createGlboalApi() {
31
32
  request: sdk.request,
32
33
  getSessionId: sdk.getSessionId,
33
34
  },
35
+ enumOptions: enumOptions,
34
36
  state: store,
35
37
  computed: createComputed(computed.global),
36
38
  common,
@@ -45,15 +47,16 @@ function createGlboalApi() {
45
47
  },
46
48
  utils: {
47
49
  formatDate,
50
+ formatEnum,
48
51
  get: getter,
49
52
  set: setter,
50
53
  _getConfig: function () {
51
54
  return <%= appConfig %>;
52
55
  },
53
- getWXContext: function() {
56
+ getWXContext: function () {
54
57
  return Promise.resolve({})
55
58
  },
56
- getCurrentPage: function(){
59
+ getCurrentPage: function () {
57
60
  return $page
58
61
  },
59
62
  },