@luck-design-biz/luckda 1.0.0-4-alpha → 1.0.0-6-alpha

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 (89) hide show
  1. package/es/components/ComplexItem/index.js +65 -49
  2. package/es/components/LdGridForm/index.js +2 -1
  3. package/es/helper/ldBuilder.js +8 -3
  4. package/es/locales/zh-CN.js +35 -0
  5. package/es/lowcode/engine/meta/fieldcomplex.props.default.json +1 -0
  6. package/es/lowcode/engine/meta/fieldcomplex.props.json +7 -0
  7. package/es/lowcode/engine/meta/form.props.json +3 -3
  8. package/es/lowcode/engine/meta/js-editor/auto-complete.json +18 -0
  9. package/es/lowcode/engine/meta/page.props.json +6 -0
  10. package/es/lowcode/engine/provider/ContextProvider/index.js +28 -5
  11. package/es/lowcode/engine/provider/ContextProvider/router.js +1 -1
  12. package/es/lowcode/engine/{tools → provider/ContextProvider}/usePageDataStore.js +9 -7
  13. package/es/lowcode/engine/{tools → provider/ContextProvider}/useTodo.js +4 -6
  14. package/es/lowcode/engine/provider/RemoteSourceProvider.js +2 -3
  15. package/es/lowcode/engine/tools/helper.js +7 -2
  16. package/es/lowcode/engine/tools/initDS.js +263 -0
  17. package/es/lowcode/engine/tools/useCombinedRefs.js +3 -2
  18. package/es/lowcode/painter/components/TipIcon.js +16 -0
  19. package/es/lowcode/painter/components/VarEditor.js +456 -0
  20. package/es/lowcode/painter/components/code-editor/JSEditor.js +3 -1
  21. package/es/lowcode/painter/components/code-editor/VisionEditor.js +81 -0
  22. package/es/lowcode/painter/components/field-setting/SettingUI.js +17 -3
  23. package/es/lowcode/painter/components/field-setting/index.js +1 -1
  24. package/es/lowcode/painter/index.js +1 -0
  25. package/es/lowcode/painter/panel-section/ComplexPop.js +241 -0
  26. package/es/lowcode/painter/panel-section/DataSetSelector.js +8 -0
  27. package/es/lowcode/painter/panel-section/FieldsSetting.js +9 -1
  28. package/es/lowcode/painter/panel-section/ImpExp.js +1 -27
  29. package/es/lowcode/painter/panel-section/PageVars.js +296 -0
  30. package/es/lowcode/painter/services/complexPop.js +21 -0
  31. package/es/lowcode/painter/style/page-vars.less +25 -0
  32. package/es/lowcode/preview/index.js +1 -0
  33. package/es/lowcode/view/Canvas.js +11 -34
  34. package/es/lowcode/view/Loading.js +5 -7
  35. package/es/lowcode/view/Page.js +37 -15
  36. package/es/lowcode/view/index.js +1 -0
  37. package/es/lowcode/view/lc-components/FieldComplex/meta.json +7 -0
  38. package/es/lowcode/view/lc-components/Form/index.js +11 -4
  39. package/es/lowcode/view/lc-components/Form/meta.json +3 -3
  40. package/es/lowcode/view/lc-components/Page/meta.json +6 -0
  41. package/es/lowcode/view/lc-components/Table/index.js +17 -3
  42. package/es/lowcode/view/style/loading.less +14 -0
  43. package/es/utils/form.js +3 -3
  44. package/es/utils/grid.js +1 -1
  45. package/lib/components/ComplexItem/index.js +62 -47
  46. package/lib/components/LdGridForm/index.js +2 -1
  47. package/lib/helper/ldBuilder.js +8 -3
  48. package/lib/locales/zh-CN.js +35 -0
  49. package/lib/lowcode/engine/meta/fieldcomplex.props.default.json +1 -0
  50. package/lib/lowcode/engine/meta/fieldcomplex.props.json +7 -0
  51. package/lib/lowcode/engine/meta/form.props.json +3 -3
  52. package/lib/lowcode/engine/meta/js-editor/auto-complete.json +18 -0
  53. package/lib/lowcode/engine/meta/page.props.json +6 -0
  54. package/lib/lowcode/engine/provider/ContextProvider/index.js +29 -12
  55. package/lib/lowcode/engine/provider/ContextProvider/router.js +1 -1
  56. package/lib/lowcode/engine/{tools → provider/ContextProvider}/usePageDataStore.js +9 -7
  57. package/lib/lowcode/engine/{tools → provider/ContextProvider}/useTodo.js +4 -6
  58. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +3 -4
  59. package/lib/lowcode/engine/tools/helper.js +7 -2
  60. package/lib/lowcode/engine/tools/initDS.js +270 -0
  61. package/lib/lowcode/engine/tools/useCombinedRefs.js +2 -1
  62. package/lib/lowcode/painter/components/TipIcon.js +23 -0
  63. package/lib/lowcode/painter/components/VarEditor.js +463 -0
  64. package/lib/lowcode/painter/components/code-editor/JSEditor.js +3 -1
  65. package/lib/lowcode/painter/components/code-editor/VisionEditor.js +88 -0
  66. package/lib/lowcode/painter/components/field-setting/SettingUI.js +17 -3
  67. package/lib/lowcode/painter/components/field-setting/index.js +1 -1
  68. package/lib/lowcode/painter/index.js +1 -0
  69. package/lib/lowcode/painter/panel-section/ComplexPop.js +249 -0
  70. package/lib/lowcode/painter/panel-section/DataSetSelector.js +8 -0
  71. package/lib/lowcode/painter/panel-section/FieldsSetting.js +9 -1
  72. package/lib/lowcode/painter/panel-section/ImpExp.js +0 -26
  73. package/lib/lowcode/painter/panel-section/PageVars.js +304 -0
  74. package/lib/lowcode/painter/services/complexPop.js +28 -0
  75. package/lib/lowcode/painter/style/page-vars.less +25 -0
  76. package/lib/lowcode/preview/index.js +1 -0
  77. package/lib/lowcode/view/Canvas.js +12 -35
  78. package/lib/lowcode/view/Loading.js +5 -7
  79. package/lib/lowcode/view/Page.js +35 -13
  80. package/lib/lowcode/view/index.js +1 -0
  81. package/lib/lowcode/view/lc-components/FieldComplex/meta.json +7 -0
  82. package/lib/lowcode/view/lc-components/Form/index.js +11 -4
  83. package/lib/lowcode/view/lc-components/Form/meta.json +3 -3
  84. package/lib/lowcode/view/lc-components/Page/meta.json +6 -0
  85. package/lib/lowcode/view/lc-components/Table/index.js +18 -4
  86. package/lib/lowcode/view/style/loading.less +14 -0
  87. package/lib/utils/form.js +2 -2
  88. package/lib/utils/grid.js +1 -1
  89. package/package.json +1 -1
@@ -1,22 +1,24 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
- var _excluded = ["wrapperRef", "config", "renderInfoMode", "complexConfig"];
7
- import React, { useState, forwardRef } from 'react';
8
- import { getDvaApp } from 'umi';
6
+ var _excluded = ["showPop"],
7
+ _excluded2 = ["wrapperRef", "config", "renderInfoMode", "complexConfig"];
8
+ import React, { forwardRef } from 'react';
9
+ import { useCreation } from 'ahooks';
9
10
  import { Tag } from 'luck-design/antd';
10
- import { isArray } from 'lodash';
11
- import { TreeSelector } from '@luck-design-biz/base';
12
- import { formatMessage, dataToTree } from '@luck-design-biz/base/utils';
13
- import { BasicFormItem } from 'luck-design';
14
- import api from "@/services/ApiConfig";
11
+ import { isArray, keyBy } from 'lodash';
12
+ import { TreeSelector, GridSelector } from '@luck-design-biz/base';
13
+ import { formatMessage } from '@luck-design-biz/base/utils';
15
14
  import { fetchContent } from "./service";
15
+ import { includes } from 'lodash';
16
16
  var Index = function Index(_ref) {
17
17
  var wrapperRef = _ref.wrapperRef,
18
18
  _ref$config = _ref.config,
19
- config = _ref$config === void 0 ? {} : _ref$config,
19
+ _ref$config2 = _ref$config === void 0 ? {} : _ref$config,
20
+ showPop = _ref$config2.showPop,
21
+ config = _objectWithoutProperties(_ref$config2, _excluded),
20
22
  renderInfoMode = _ref.renderInfoMode,
21
23
  _ref$complexConfig = _ref.complexConfig,
22
24
  _ref$complexConfig$is = _ref$complexConfig.isTree,
@@ -26,48 +28,57 @@ var Index = function Index(_ref) {
26
28
  dataSetCode = _ref$complexConfig.dataSetCode,
27
29
  keyField = _ref$complexConfig.keyField,
28
30
  valueField = _ref$complexConfig.valueField,
29
- props = _objectWithoutProperties(_ref, _excluded);
30
- var _useState = useState([]),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- dataSource = _useState2[0],
33
- setDataSource = _useState2[1];
34
- var handleFocus = function handleFocus() {
35
- if (!dataSource || dataSource.length === 0) {
36
- fetchContent(dataModel, {
37
- datasetCode: dataSetCode,
38
- moduleCode: moduleCode
39
- }).then(function (res) {
40
- var code = res.code,
41
- data = res.data;
42
- if (code === 1) {
43
- var formatData = data.map(function (i) {
44
- return _objectSpread(_objectSpread({}, i), {}, {
45
- key: i[keyField],
46
- value: i[keyField],
47
- label: valueField.length > 0 ? valueField.split(',').map(function (val) {
48
- return i[val];
49
- }).join('-') : '',
50
- title: valueField.length > 0 ? valueField.split(',').map(function (val) {
51
- return i[val];
52
- }).join('-') : ''
53
- });
54
- });
55
- if (isTree) {
56
- setDataSource(dataToTree(formatData, null, 'uid', 'parent_uid'));
57
- } else setDataSource(formatData);
58
- }
59
- });
60
- }
61
- };
31
+ props = _objectWithoutProperties(_ref, _excluded2);
32
+ var Selector = useCreation(function () {
33
+ return isTree ? TreeSelector : GridSelector;
34
+ }, [isTree]);
62
35
  return renderInfoMode ? renderInfoMode(function (value) {
63
36
  return (config.multiple || config.mode === 'multiple') && isArray(value) ? value.map(function (item) {
64
37
  return /*#__PURE__*/React.createElement(Tag, {
65
38
  key: item.key
66
39
  }, item.label || item.value || item.key);
67
40
  }) : /*#__PURE__*/React.createElement("span", null, value.label || value.value || value.key);
68
- }) : /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
69
- type: isTree ? 'treeSelect' : 'select',
41
+ }) : /*#__PURE__*/React.createElement(Selector, _extends({}, props, {
42
+ keyName: keyField,
43
+ titleKey: "title",
44
+ api: ( /*#__PURE__*/function () {
45
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(get) {
46
+ var res, formatData, detail;
47
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
48
+ while (1) switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.next = 2;
51
+ return fetchContent(dataModel, _objectSpread({
52
+ datasetCode: dataSetCode,
53
+ moduleCode: moduleCode
54
+ }, get));
55
+ case 2:
56
+ res = _context.sent;
57
+ formatData = (res === null || res === void 0 ? void 0 : res.data.map(function (i) {
58
+ return _objectSpread(_objectSpread({}, i), {}, {
59
+ title: valueField.length > 0 ? valueField.split(',').map(function (val) {
60
+ return i[val];
61
+ }).join('-') : ''
62
+ });
63
+ })) || [];
64
+ detail = keyBy(formatData, window.appConfig.constraintKeys.PRIMARY);
65
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, res), {}, {
66
+ list: Object.keys(detail),
67
+ detail: detail
68
+ }));
69
+ case 6:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee);
74
+ }));
75
+ return function (_x) {
76
+ return _ref2.apply(this, arguments);
77
+ };
78
+ }()),
70
79
  ref: wrapperRef,
80
+ max: config.multiple || config.mode === 'multiple' ? 0 : 1,
81
+ noAddon: !(showPop !== null && showPop !== void 0 && showPop.show),
71
82
  config: _objectSpread(_objectSpread({
72
83
  required: false,
73
84
  placeholder: formatMessage({
@@ -76,11 +87,16 @@ var Index = function Index(_ref) {
76
87
  message: formatMessage({
77
88
  id: 'app.base.tip.select'
78
89
  })
79
- }, config), {}, _defineProperty(_defineProperty({
80
- showSearch: true,
90
+ }, config), {}, {
81
91
  optionFilterProp: 'title',
82
92
  treeNodeFilterProp: 'label'
83
- }, isTree ? 'treeData' : 'dataSource', dataSource), "onFocus", handleFocus))
93
+ }),
94
+ selectorProps: {
95
+ columns: (showPop === null || showPop === void 0 ? void 0 : showPop.fields) || [],
96
+ resultColumns: ((showPop === null || showPop === void 0 ? void 0 : showPop.fields) || []).filter(function (i) {
97
+ return includes(valueField.split(','), i.field);
98
+ })
99
+ }
84
100
  }));
85
101
  };
86
102
  var RefCom = /*#__PURE__*/forwardRef(function (props, ref) {
@@ -92,7 +92,8 @@ var buildLdGridForm = function buildLdGridForm(_ref) {
92
92
  moduleCode: moduleCode,
93
93
  formRef: formRef,
94
94
  formMode: formMode,
95
- setting: omit(setting, [].concat(defaultSet, ['uid', 'field']))
95
+ render: setting === null || setting === void 0 ? void 0 : setting.render,
96
+ setting: omit(setting, [].concat(defaultSet, ['uid', 'field', 'render']))
96
97
  })
97
98
  })));
98
99
  }
@@ -1,7 +1,12 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext } from 'react';
3
+ import styled from 'styled-components';
3
4
  import { LuckDaContext } from "../components/Builder";
4
5
  import { formatMessage } from '@luck-design-biz/base/utils';
6
+ var ErrorWrapper = styled.span.withConfig({
7
+ displayName: "ErrorWrapper",
8
+ componentId: "luckda-6530__sc-ek28r3-0"
9
+ })(["display:inline-block;width:100%;height:auto;padding:24px 16px;color:#ff4d4f;"]);
5
10
  var builder = function builder(wrapped) {
6
11
  var LdCom = function LdCom(props) {
7
12
  var ldId = props.ldId,
@@ -19,7 +24,7 @@ var builder = function builder(wrapped) {
19
24
  doAction = _ref.doAction,
20
25
  moduleCode = _ref.moduleCode; // 读存储的模块信息,包括行为、行为执行方法、数据集
21
26
 
22
- if (!ldId) return /*#__PURE__*/React.createElement("span", {
27
+ if (!ldId) return /*#__PURE__*/React.createElement(ErrorWrapper, {
23
28
  ref: wrapper,
24
29
  className: className,
25
30
  style: style
@@ -27,7 +32,7 @@ var builder = function builder(wrapped) {
27
32
  id: 'luckda.paramMiss.ldId',
28
33
  label: '配置项缺少组件唯一标识(ldId)'
29
34
  }));
30
- if (!dataSetKey) return /*#__PURE__*/React.createElement("span", {
35
+ if (!dataSetKey) return /*#__PURE__*/React.createElement(ErrorWrapper, {
31
36
  ref: wrapper,
32
37
  className: className,
33
38
  style: style
@@ -37,7 +42,7 @@ var builder = function builder(wrapped) {
37
42
  }));
38
43
  if (!dataSets[dataSetKey])
39
44
  // 待获取数据源
40
- return /*#__PURE__*/React.createElement("span", {
45
+ return /*#__PURE__*/React.createElement(ErrorWrapper, {
41
46
  ref: wrapper,
42
47
  className: className,
43
48
  style: style
@@ -61,6 +61,14 @@ export default {
61
61
  "luckda.lowcode.painter.panel-section.splitdisplay.split": "分割方向",
62
62
  "luckda.lowcode.painter.panel-section.splitdisplay.ratio": "列比例",
63
63
  "luckda.lowcode.painter.panel-section.Layoutratio.placeholder": "请输入列比例",
64
+ "luckda.lowcode.painter.pageVars.var": "变量",
65
+ "luckda.lowcode.painter.pageVars.api": "远程 API",
66
+ "luckda.lowcode.painter.pageVars.edit": "编辑数据源",
67
+ "luckda.lowcode.painter.pageVars.copy": "拷贝",
68
+ "luckda.lowcode.painter.pageVars.delete": "删除",
69
+ "luckda.lowcode.painter.pageVars.all": "全部",
70
+ "luckda.lowcode.painter.pageVars.placeholder.search": "请输入",
71
+ "luckda.lowcode.painter.pageVars.add": "添加",
64
72
  "luckda.lowcode.painter.panel-section.Layoutratio.err": "必须是数字或者数字加:号的组合",
65
73
  "luckda.lowcode.painter.panel-section.Layoutratio.label": "列比例",
66
74
  "luckda.lowcode.painter.panel-section.style-panel.sourceedit": "源码编辑",
@@ -71,6 +79,10 @@ export default {
71
79
  "luckda.lowcode.painter.panel-section.fieldsSetting.field": "数据字段",
72
80
  "luckda.lowcode.painter.panel-section.fieldsSetting.title": "标题",
73
81
  "luckda.lowcode.painter.panel-section.fieldsSetting.batch": "批量设置",
82
+ "luckda.lowcode.painter.panel-section.complexPop.assisted": "辅助选择",
83
+ "luckda.lowcode.painter.panel-section.complexPop.assistedGrid": "辅助弹窗显示字段",
84
+ "luckda.lowcode.painter.panel-section.complexPop.assistedGridFields": "展示区",
85
+ "luckda.lowcode.painter.panel-section.complexPop.gridFields": "可选区",
74
86
  "luckda.lowcode.painter.panel-section.style-panel.box-shadow": "阴影",
75
87
  "luckda.lowcode.painter.panel-section.style-panel.box-shadow.big": "大",
76
88
  "luckda.lowcode.painter.panel-section.style-panel.box-shadow.middle": "中",
@@ -173,6 +185,28 @@ export default {
173
185
  "luckda.lowcode.painter.panel-section.actionEditor.serial": "资源串",
174
186
  "luckda.lowcode.painter.panel-section.actionEditor.serialEffect": "越权效果",
175
187
  "luckda.lowcode.painter.panel-section.actionEditor.riskLevel": "风险等级",
188
+ "luckda.lowcode.painter.pageVars.taskType.serial": "串行",
189
+ "luckda.lowcode.painter.pageVars.taskType.parallel": "并行",
190
+ "luckda.lowcode.painter.pageVars.method.jsonp": "JSONP",
191
+ "luckda.lowcode.painter.pageVars.method.get": "GET",
192
+ "luckda.lowcode.painter.pageVars.taskType.post": "POST",
193
+ "luckda.lowcode.painter.pageVars.taskType.put": "PUT",
194
+ "luckda.lowcode.painter.pageVars.taskType.delete": "DELETE",
195
+ "luckda.lowcode.painter.pageVars.name": "名称",
196
+ "luckda.lowcode.painter.pageVars.messag.name": "请输入变量名",
197
+ "luckda.lowcode.painter.pageVars.desc": "描述",
198
+ "luckda.lowcode.painter.pageVars.placeholder": "请输入",
199
+ "luckda.lowcode.painter.pageVars.data": "数据",
200
+ "luckda.lowcode.painter.pageVars.auto": "自动加载",
201
+ "luckda.lowcode.painter.pageVars.taskType": "加载方式",
202
+ "luckda.lowcode.painter.pageVars.url": "请求地址",
203
+ "luckda.lowcode.painter.pageVars.method": "请求方式",
204
+ "luckda.lowcode.painter.pageVars.urlParams": "请求参数",
205
+ "luckda.lowcode.painter.pageVars.tip.urlParams": "URL 请求参数,格式为 {key1:value1,key2:value2} ,等价于 ?key1=value1&key2=value2",
206
+ "luckda.lowcode.painter.pageVars.body": "请求体",
207
+ "luckda.lowcode.painter.pageVars.tip.body": "接口请求体(body),格式为 {key1:value1,key2:value2}",
208
+ "luckda.lowcode.painter.pageVars.process": "数据处理",
209
+ "luckda.lowcode.painter.pageVars.defaultValue": "默认数据",
176
210
  "luckda.lowcode.painter.panel-section.components.listeditor.add": "添加一项",
177
211
  "luckda.lowcode.painter.panel-section.field-selector.placeholder": "请选择字段",
178
212
  "luckda.lowcode.painter.advancePanel.render": "是否渲染",
@@ -206,6 +240,7 @@ export default {
206
240
  "luckda.lowcode.painter.panel-section.fieldsSetting.form.display": "表单中显示",
207
241
  "luckda.lowcode.painter.panel-section.fieldsSetting.writable": "是否可写",
208
242
  "luckda.lowcode.painter.panel-section.fieldsSetting.readonly": "是否只读",
243
+ "luckda.lowcode.painter.panel-section.fieldsSetting.render": "内容定制渲染",
209
244
  "luckda.lowcode.painter.panel-section.fieldsSetting.defaultValue": "默认值",
210
245
  "luckda.lowcode.painter.settingTo": "设置为",
211
246
  "luckda.lowcode.painter.setting": "设置",
@@ -7,6 +7,7 @@
7
7
  "groupName": "表单项",
8
8
  "order": 1,
9
9
  "allowClear": true,
10
+ "showPop": true,
10
11
  "col": 1,
11
12
  "row": 1,
12
13
  "state": {
@@ -18,6 +18,13 @@
18
18
  "type": "switch",
19
19
  "default": true
20
20
  },
21
+ {
22
+ "key": "showPop",
23
+ "name": "辅助选择",
24
+ "type": "_ComplexPop",
25
+ "wrapper": "hidden",
26
+ "default": true
27
+ },
21
28
  {
22
29
  "key": "generalSetting",
23
30
  "name": "通用配置",
@@ -261,7 +261,7 @@
261
261
  "name": "格式化默认数据",
262
262
  "desc": "格式化新增时默认数据",
263
263
  "type": "_JSEditor",
264
- "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return defaultValues; \n}",
264
+ "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return {}; \n}",
265
265
  "mustConfirm": true,
266
266
  "wrapper": "collapse",
267
267
  "wrapperProps": {
@@ -363,7 +363,7 @@
363
363
  "name": "格式化默认数据",
364
364
  "desc": "格式化新增时默认数据",
365
365
  "type": "_JSEditor",
366
- "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return defaultValues; \n}",
366
+ "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return {}; \n}",
367
367
  "mustConfirm": true,
368
368
  "wrapper": "collapse",
369
369
  "wrapperProps": {
@@ -489,7 +489,7 @@
489
489
  "name": "格式化默认数据",
490
490
  "desc": "格式化新增时默认数据",
491
491
  "type": "_JSEditor",
492
- "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return defaultValues; \n}",
492
+ "defaultCode": "function defaultDataSourceFormat(defaultValues) { \n return {}; \n}",
493
493
  "mustConfirm": true,
494
494
  "wrapper": "collapse",
495
495
  "wrapperProps": {
@@ -206,12 +206,24 @@
206
206
  "insertText": "topics",
207
207
  "documentation": " /**\r\n * @property {object} topics - 内置的事件话题\r\n */\r"
208
208
  },
209
+ {
210
+ "label": "API_PREFIX",
211
+ "kind": "property",
212
+ "insertText": "API_PREFIX",
213
+ "documentation": " /**\r\n * @property {object} topics - service api前缀\r\n */\r"
214
+ },
209
215
  {
210
216
  "label": "PRIMARY_KEY",
211
217
  "kind": "property",
212
218
  "insertText": "PRIMARY_KEY",
213
219
  "documentation": " /**\r\n * @property {string} PRIMARY_KEY - 主键key\r\n */\r"
214
220
  },
221
+ {
222
+ "label": "PARENT_KEY",
223
+ "kind": "property",
224
+ "insertText": "PARENT_KEY",
225
+ "documentation": " /**\r\n * @property {string} PARENT_KEY - 树组件主键key\r\n */\r"
226
+ },
215
227
  {
216
228
  "label": "getElementById",
217
229
  "kind": "method",
@@ -236,6 +248,12 @@
236
248
  "insertText": "want",
237
249
  "documentation": " /**\r\n * @method - 是否有权限\r\n * @return {string} wanted - 期望的资源串\r\n */\r"
238
250
  },
251
+ {
252
+ "label": "getBehaviorUrl",
253
+ "kind": "method",
254
+ "insertText": "getBehaviorUrl",
255
+ "documentation": " /**\r\n * @method - 获取执行行为请求的接口URL\r\n * @return {string} BEHAVIOR_URL - 执行行为请求的接口URL\r\n */\r"
256
+ },
239
257
  {
240
258
  "label": "utils",
241
259
  "kind": "property",
@@ -27,6 +27,12 @@
27
27
  "default": "false"
28
28
  }
29
29
  ]
30
+ },
31
+ {
32
+ "key": "vars",
33
+ "name": "页面数据源",
34
+ "type": "_PageVars",
35
+ "wrapper": "collapse"
30
36
  }
31
37
  ],
32
38
  "css": "background-color: transparent;",
@@ -6,8 +6,10 @@ import { isNil } from 'lodash';
6
6
  import { useLDEventBus } from "../EventBusProvider";
7
7
  import RemoteSourceProvider, { RemoteSourceContext } from "../RemoteSourceProvider";
8
8
  import usePageVar from "./usePageVar";
9
- import useTodo from "../../tools/useTodo";
10
- import { getModuleData } from "../../tools/usePageDataStore";
9
+ import useTodo from "./useTodo";
10
+ import { getModuleData } from "./usePageDataStore";
11
+ import API_PREFIX from "@/services/ApiConfig";
12
+ import { getBehaviorUrl } from "../../../constants/api-url";
11
13
  import * as topics from "../../../constants/event-topics";
12
14
  import * as utils from "./utils";
13
15
  import * as router from "./router";
@@ -18,9 +20,8 @@ export var useContext = function useContext() {
18
20
  export var useRemoteSource = function useRemoteSource() {
19
21
  return useReactContext(RemoteSourceContext);
20
22
  };
21
- export * from "../../tools/usePageDataStore";
22
- export { useStateStore } from "./usePageVar";
23
- var PRIVATE_KEYS = ['componentList', 'componentMap'];
23
+ export * from "./usePageDataStore";
24
+ var PRIVATE_KEYS = ['componentList', 'componentMap', 'remoteApiMap'];
24
25
  export default (function (_ref) {
25
26
  var children = _ref.children,
26
27
  code = _ref.code;
@@ -35,12 +36,16 @@ export default (function (_ref) {
35
36
  global = _usePageVar.global,
36
37
  setGlobal = _usePageVar.setGlobal;
37
38
  var _componentList = useRef([]);
39
+ var _remoteApiMap = useRef(new Map());
38
40
  var _privateGetter = useRef({
39
41
  componentList: function componentList() {
40
42
  return _componentList.current;
41
43
  },
42
44
  componentMap: function componentMap() {
43
45
  return new Map(_componentList.current);
46
+ },
47
+ remoteApiMap: function remoteApiMap() {
48
+ return Object.fromEntries(_remoteApiMap.current.entries());
44
49
  }
45
50
  });
46
51
  var _register = useMemoizedFn(function (id, component) {
@@ -53,6 +58,9 @@ export default (function (_ref) {
53
58
  return _id !== id;
54
59
  });
55
60
  });
61
+ var _initRemoteApiMap = useMemoizedFn(function (_apiMap) {
62
+ _remoteApiMap.current = _apiMap;
63
+ });
56
64
  var getElementById = useMemoizedFn(function (compId) {
57
65
  var _componentList$curren;
58
66
  return (_componentList$curren = _componentList.current.find(function (_ref4) {
@@ -88,6 +96,7 @@ export default (function (_ref) {
88
96
  var ctx = new Proxy(_objectSpread({
89
97
  _register: _register,
90
98
  _unregister: _unregister,
99
+ _initRemoteApiMap: _initRemoteApiMap,
91
100
  /**
92
101
  * @property {boolean} loading - loading状态
93
102
  */
@@ -96,10 +105,17 @@ export default (function (_ref) {
96
105
  * @property {object} topics - 内置的事件话题
97
106
  */
98
107
  topics: topics,
108
+ /**
109
+ * @property {object} topics - service api前缀
110
+ */
111
+ API_PREFIX: API_PREFIX,
99
112
  /**
100
113
  * @property {string} PRIMARY_KEY - 主键key
101
114
  */
102
115
  PRIMARY_KEY: window.appConfig.constraintKeys.PRIMARY,
116
+ /**
117
+ * @property {string} PARENT_KEY - 树组件主键key
118
+ */
103
119
  PARENT_KEY: window.appConfig.constraintKeys.PARENT,
104
120
  /**
105
121
  * @method - 根据组件ID获取实例
@@ -126,6 +142,11 @@ export default (function (_ref) {
126
142
  * @return {string} wanted - 期望的资源串
127
143
  */
128
144
  want: want,
145
+ /**
146
+ * @method - 获取执行行为请求的接口URL
147
+ * @return {string} BEHAVIOR_URL - 执行行为请求的接口URL
148
+ */
149
+ getBehaviorUrl: getBehaviorUrl,
129
150
  /**
130
151
  * @typedef {Object} Utils
131
152
  * @property {function(type, props): void} dialog - 弹出对话框
@@ -163,6 +184,8 @@ export default (function (_ref) {
163
184
  set: function set(target, property, receiver) {
164
185
  if (PRIVATE_KEYS.includes(property)) {
165
186
  throw new Error("\u5C5E\u6027 \"".concat(property, "\" \u662F\u53EA\u8BFB\u7684"));
187
+ } else if (property.startsWith('_')) {
188
+ throw new Error("\u5C5E\u6027 \"".concat(property, "\" \u662F\u79C1\u6709\u7684"));
166
189
  } else if (property === 'state') {
167
190
  setState(receiver);
168
191
  return true;
@@ -18,7 +18,7 @@ export function push(path, params) {
18
18
  } else if (type === 'sso') {
19
19
  window.openUrl("sso:".concat(path));
20
20
  } else {
21
- history[type](url, params);
21
+ history[type](path, params);
22
22
  }
23
23
  }
24
24
  export function replace(path, state) {
@@ -7,8 +7,8 @@ import { subscribeWithSelector } from 'zustand/middleware';
7
7
  import { useShallow } from 'zustand/react/shallow';
8
8
  import { isObject, isArray, isNil, isFunction, isString, get, set as _set, unset, assign, forOwn, forEach, omit, debounce } from 'lodash';
9
9
  import isDeepEqual from 'fast-deep-equal';
10
- import { getPathNodesById, findNodeAndParent } from "./dataProcess";
11
- import { LC_BUILDIN_UNIT_KEY } from "../../constants";
10
+ import { getPathNodesById, findNodeAndParent } from "../../tools/dataProcess";
11
+ import { LC_BUILDIN_UNIT_KEY } from "../../../constants";
12
12
  var temporalStateCreator = function temporalStateCreator(userSet, userGet, options) {
13
13
  var stateCreator = function stateCreator(set, get) {
14
14
  return {
@@ -184,11 +184,13 @@ export default usePageDataStore;
184
184
  usePageDataStore.subscribe(function (state) {
185
185
  return state.pageData;
186
186
  }, function (_, prev) {
187
- if (prev !== null) {
188
- usePageDataStore.setState(function (state) {
189
- if (state.needPrompt === false) state.needPrompt = true;
190
- });
191
- }
187
+ usePageDataStore.setState(function (state) {
188
+ if (prev === null) {
189
+ state.needPrompt = false;
190
+ } else if (state.needPrompt === false) {
191
+ state.needPrompt = true;
192
+ }
193
+ });
192
194
  });
193
195
  export var resetPageData = function resetPageData(data) {
194
196
  usePageDataStore.setState(function (state) {
@@ -6,9 +6,9 @@ var _excluded = ["datasetCode"];
6
6
  import { useBoolean, useMemoizedFn } from 'ahooks';
7
7
  import { message } from 'luck-design/antd';
8
8
  import { keys, isNil, isFunction } from 'lodash';
9
- import usePageDataStore from "./usePageDataStore";
10
- import { executeCode } from "./helper";
11
- import { fetchCallBehavior } from "../../constants/api-url";
9
+ import { getModuleData } from "./usePageDataStore";
10
+ import { executeCode } from "../../tools/helper";
11
+ import { fetchCallBehavior } from "../../../constants/api-url";
12
12
  var useTodo = function useTodo() {
13
13
  var _useBoolean = useBoolean(),
14
14
  _useBoolean2 = _slicedToArray(_useBoolean, 2),
@@ -26,9 +26,6 @@ var useTodo = function useTodo() {
26
26
  behaviorKey: behaviorKey
27
27
  }, params), data);
28
28
  });
29
- var moduleData = usePageDataStore(function (state) {
30
- return state.moduleData;
31
- });
32
29
  var todo = useMemoizedFn(function (ctx, actionPool) {
33
30
  var argsMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
34
31
  if (isNil(actionPool)) {
@@ -57,6 +54,7 @@ var useTodo = function useTodo() {
57
54
  params = _ref4.params,
58
55
  data = _ref4.data,
59
56
  after = _ref4.after;
57
+ var moduleData = getModuleData();
60
58
  var _moduleCode = moduleCode || moduleData.moduleCode;
61
59
  var _dscode = datasetCode || dsCode;
62
60
  if (!_moduleCode || !_dscode) {
@@ -9,8 +9,7 @@ import { history } from 'umi';
9
9
  import launcher from "../launcher";
10
10
  import { LuckDaContext } from "../../../components/Builder";
11
11
  import { doAction as doActionUtils } from "../../../helper/action";
12
- import usePageDataStore from "../tools/usePageDataStore";
13
- import { useTemporalStore } from "../provider/ContextProvider";
12
+ import usePageDataStore, { useTemporalStore } from "./ContextProvider/usePageDataStore";
14
13
  import { decompress } from "../tools/dataProcess";
15
14
  import { fetchPageData, fetchDesignModlueData, fetchPreviewModlueData, fetchModlueData, fetchAllDataset, fetchAllSerials, fetchAllBehaviorEx } from "../../constants/api-url";
16
15
  import { RUNTIME, LC_RUNTIME_KEY, META_TAG_NAME } from "../../constants";
@@ -173,7 +172,7 @@ export default (function (_ref) {
173
172
  _context.next = 9;
174
173
  break;
175
174
  }
176
- window.__INJECTED_FLOAT_MICRO_APP_BY_QIANKUN ? history.replace('/base/base/404') : history.replace('/404');
175
+ history.replace('/404');
177
176
  _context.next = 20;
178
177
  break;
179
178
  case 9:
@@ -120,8 +120,13 @@ export function executeCode(context, code, argsName) {
120
120
  throw new Error('executeCode参数不匹配');
121
121
  }
122
122
  var ctx = getCtx(context);
123
- var func = _construct(Function, _toConsumableArray(argsName || []).concat(['ctx', 'window', "\"use strict\"; ".concat(getFuncBody(code))]));
124
- return func.apply(void 0, args.concat([ctx, _objectSpread(_objectSpread({}, window.proxy), window)]));
123
+ try {
124
+ var func = _construct(Function, _toConsumableArray(argsName || []).concat(['ctx', 'window', "\"use strict\"; ".concat(getFuncBody(code))]));
125
+ return func.apply(void 0, args.concat([ctx, _objectSpread(_objectSpread({}, window.proxy), window)]));
126
+ } catch (e) {
127
+ console.error("".concat(code, "\u65E0\u6CD5\u88AB\u6267\u884C"), e);
128
+ return null;
129
+ }
125
130
  }
126
131
  export function parseCSS(cssString) {
127
132
  // 创建一个空对象来存储解析后的样式