@luck-design-biz/luckda 1.0.6-13tl → 1.0.7

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 (169) hide show
  1. package/es/components/Builder/index.js +37 -27
  2. package/es/components/ComplexItem/index.js +5 -3
  3. package/es/components/ComplexItem/service.js +6 -3
  4. package/es/components/LdAutoForm/index.js +25 -12
  5. package/es/components/LdCard/index.js +10 -8
  6. package/es/components/LdCom/index.js +3 -2
  7. package/es/components/LdFormList/index.js +5 -4
  8. package/es/components/LdGrid/index.js +29 -20
  9. package/es/components/LdGridForm/index.js +16 -7
  10. package/es/components/LdInfoPanel/index.js +16 -10
  11. package/es/helper/FromItems.js +64 -5
  12. package/es/helper/form.js +8 -2
  13. package/es/helper/ldBuilder.js +9 -5
  14. package/es/helper/ldComBuild.js +16 -11
  15. package/es/locales/zh-CN.js +40 -4
  16. package/es/lowcode/constants/api-url.js +202 -175
  17. package/es/lowcode/constants/event-topics.js +2 -0
  18. package/es/lowcode/constants/index.js +5 -4
  19. package/es/lowcode/engine/meta/components-list.json +6 -0
  20. package/es/lowcode/engine/meta/fielddate.props.default.json +1 -0
  21. package/es/lowcode/engine/meta/fielddate.props.json +48 -0
  22. package/es/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  23. package/es/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  24. package/es/lowcode/engine/meta/pagecomponent.props.json +41 -0
  25. package/es/lowcode/engine/meta/proxy.props.default.json +15 -0
  26. package/es/lowcode/engine/meta/proxy.props.json +66 -0
  27. package/es/lowcode/engine/provider/ContextProvider/index.js +45 -9
  28. package/es/lowcode/engine/provider/ContextProvider/usePageDataStore.js +36 -30
  29. package/es/lowcode/engine/provider/ContextProvider/usePageVar.js +11 -5
  30. package/es/lowcode/engine/provider/ContextProvider/useTodo.js +2 -4
  31. package/es/lowcode/engine/provider/EventBusProvider.js +14 -4
  32. package/es/lowcode/engine/provider/PageProxyProvider.js +95 -0
  33. package/es/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  34. package/es/lowcode/engine/tools/helper.js +44 -5
  35. package/es/lowcode/engine/tools/initDS.js +4 -4
  36. package/es/lowcode/painter/Design.js +1 -0
  37. package/es/lowcode/painter/DesignOperator.js +129 -27
  38. package/es/lowcode/painter/DesignToolbar.js +88 -173
  39. package/es/lowcode/painter/components/AdvancePanel.js +28 -10
  40. package/es/lowcode/painter/components/TipIcon.js +12 -4
  41. package/es/lowcode/painter/components/field-setting/SettingUI.js +56 -4
  42. package/es/lowcode/painter/components/field-setting/index.js +24 -1
  43. package/es/lowcode/painter/components/shortcut-modal/KeyIcon.js +11 -0
  44. package/es/lowcode/painter/components/shortcut-modal/index.js +208 -0
  45. package/es/lowcode/painter/panel-section/BlockEditor/index.js +10 -19
  46. package/es/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  47. package/es/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  48. package/es/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  49. package/es/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  50. package/es/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  51. package/es/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  52. package/es/lowcode/painter/panel-section/JSEditor/index.js +15 -5
  53. package/es/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  54. package/es/lowcode/painter/panel-section/ProxyLinker.js +137 -0
  55. package/es/lowcode/painter/panel-section/ProxyParams.js +28 -0
  56. package/es/lowcode/painter/panel-section/ProxyParamsSetter.js +240 -0
  57. package/es/lowcode/painter/style/panel-item.less +1 -0
  58. package/es/lowcode/preview/DebugTool.js +78 -0
  59. package/es/lowcode/preview/DebugToolDetail.js +103 -0
  60. package/es/lowcode/preview/index.js +10 -17
  61. package/es/lowcode/preview/useDebugSettings.js +62 -0
  62. package/es/lowcode/view/Canvas.js +5 -1
  63. package/es/lowcode/view/Page.js +8 -3
  64. package/es/lowcode/view/lc-components/CardList/index.js +3 -0
  65. package/es/lowcode/view/lc-components/Dialog/index.js +9 -7
  66. package/es/lowcode/view/lc-components/Drawer/index.js +2 -0
  67. package/es/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  68. package/es/lowcode/view/lc-components/Form/index.js +3 -0
  69. package/es/lowcode/view/lc-components/Proxy/FunctionDesign.js +17 -0
  70. package/es/lowcode/view/lc-components/Proxy/FunctionLive.js +23 -0
  71. package/es/lowcode/view/lc-components/Proxy/FunctionPreview.js +23 -0
  72. package/es/lowcode/view/lc-components/Proxy/index.js +42 -0
  73. package/es/lowcode/view/lc-components/Proxy/index.less +5 -0
  74. package/es/lowcode/view/lc-components/Proxy/meta.json +66 -0
  75. package/es/lowcode/view/lc-components/Table/components/TopImex.js +5 -23
  76. package/es/lowcode/view/lc-components/Table/index.js +12 -6
  77. package/es/lowcode/view/lc-components/Tabs/index.js +6 -2
  78. package/es/lowcode/view/lc-components/Tree/index.js +3 -0
  79. package/es/lowcode/view/lc-components/Wrapper.js +7 -1
  80. package/es/services.js +25 -7
  81. package/es/utils/action.js +3 -2
  82. package/es/utils/form.js +37 -4
  83. package/es/utils/grid.js +2 -1
  84. package/lib/components/Builder/index.js +36 -26
  85. package/lib/components/ComplexItem/index.js +5 -3
  86. package/lib/components/ComplexItem/service.js +6 -3
  87. package/lib/components/LdAutoForm/index.js +22 -9
  88. package/lib/components/LdCard/index.js +10 -8
  89. package/lib/components/LdCom/index.js +3 -2
  90. package/lib/components/LdFormList/index.js +4 -3
  91. package/lib/components/LdGrid/index.js +29 -20
  92. package/lib/components/LdGridForm/index.js +13 -4
  93. package/lib/components/LdInfoPanel/index.js +15 -9
  94. package/lib/helper/FromItems.js +64 -5
  95. package/lib/helper/form.js +8 -2
  96. package/lib/helper/ldBuilder.js +8 -5
  97. package/lib/helper/ldComBuild.js +14 -9
  98. package/lib/locales/zh-CN.js +40 -4
  99. package/lib/lowcode/constants/api-url.js +204 -175
  100. package/lib/lowcode/constants/event-topics.js +3 -1
  101. package/lib/lowcode/constants/index.js +6 -5
  102. package/lib/lowcode/engine/meta/components-list.json +6 -0
  103. package/lib/lowcode/engine/meta/fielddate.props.default.json +1 -0
  104. package/lib/lowcode/engine/meta/fielddate.props.json +48 -0
  105. package/lib/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  106. package/lib/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  107. package/lib/lowcode/engine/meta/pagecomponent.props.json +41 -0
  108. package/lib/lowcode/engine/meta/proxy.props.default.json +15 -0
  109. package/lib/lowcode/engine/meta/proxy.props.json +66 -0
  110. package/lib/lowcode/engine/provider/ContextProvider/index.js +50 -13
  111. package/lib/lowcode/engine/provider/ContextProvider/usePageDataStore.js +37 -31
  112. package/lib/lowcode/engine/provider/ContextProvider/usePageVar.js +10 -4
  113. package/lib/lowcode/engine/provider/ContextProvider/useTodo.js +1 -3
  114. package/lib/lowcode/engine/provider/EventBusProvider.js +14 -4
  115. package/lib/lowcode/engine/provider/PageProxyProvider.js +103 -0
  116. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  117. package/lib/lowcode/engine/tools/helper.js +44 -4
  118. package/lib/lowcode/engine/tools/initDS.js +4 -4
  119. package/lib/lowcode/painter/Design.js +1 -0
  120. package/lib/lowcode/painter/DesignOperator.js +126 -24
  121. package/lib/lowcode/painter/DesignToolbar.js +84 -169
  122. package/lib/lowcode/painter/components/AdvancePanel.js +27 -9
  123. package/lib/lowcode/painter/components/TipIcon.js +12 -4
  124. package/lib/lowcode/painter/components/field-setting/SettingUI.js +55 -3
  125. package/lib/lowcode/painter/components/field-setting/index.js +24 -1
  126. package/lib/lowcode/painter/components/shortcut-modal/KeyIcon.js +18 -0
  127. package/lib/lowcode/painter/components/shortcut-modal/index.js +215 -0
  128. package/lib/lowcode/painter/panel-section/BlockEditor/index.js +9 -18
  129. package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  130. package/lib/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  131. package/lib/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  132. package/lib/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  133. package/lib/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  134. package/lib/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  135. package/lib/lowcode/painter/panel-section/JSEditor/index.js +14 -4
  136. package/lib/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  137. package/lib/lowcode/painter/panel-section/ProxyLinker.js +145 -0
  138. package/lib/lowcode/painter/panel-section/ProxyParams.js +35 -0
  139. package/lib/lowcode/painter/panel-section/ProxyParamsSetter.js +248 -0
  140. package/lib/lowcode/painter/style/panel-item.less +1 -0
  141. package/lib/lowcode/preview/DebugTool.js +86 -0
  142. package/lib/lowcode/preview/DebugToolDetail.js +111 -0
  143. package/lib/lowcode/preview/index.js +10 -18
  144. package/lib/lowcode/preview/useDebugSettings.js +69 -0
  145. package/lib/lowcode/view/Canvas.js +5 -1
  146. package/lib/lowcode/view/Page.js +8 -3
  147. package/lib/lowcode/view/lc-components/CardList/index.js +3 -0
  148. package/lib/lowcode/view/lc-components/Dialog/index.js +9 -7
  149. package/lib/lowcode/view/lc-components/Drawer/index.js +2 -0
  150. package/lib/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  151. package/lib/lowcode/view/lc-components/Form/index.js +3 -0
  152. package/lib/lowcode/view/lc-components/Proxy/FunctionDesign.js +24 -0
  153. package/lib/lowcode/view/lc-components/Proxy/FunctionLive.js +30 -0
  154. package/lib/lowcode/view/lc-components/Proxy/FunctionPreview.js +30 -0
  155. package/lib/lowcode/view/lc-components/Proxy/index.js +50 -0
  156. package/lib/lowcode/view/lc-components/Proxy/index.less +5 -0
  157. package/lib/lowcode/view/lc-components/Proxy/meta.json +66 -0
  158. package/lib/lowcode/view/lc-components/Table/components/TopImex.js +4 -22
  159. package/lib/lowcode/view/lc-components/Table/index.js +12 -6
  160. package/lib/lowcode/view/lc-components/Tabs/index.js +5 -1
  161. package/lib/lowcode/view/lc-components/Tree/index.js +3 -0
  162. package/lib/lowcode/view/lc-components/Wrapper.js +6 -0
  163. package/lib/services.js +26 -7
  164. package/lib/utils/action.js +6 -0
  165. package/lib/utils/form.js +38 -4
  166. package/lib/utils/grid.js +2 -1
  167. package/package.json +1 -1
  168. package/es/lowcode/engine/meta/button.api.json +0 -0
  169. package/lib/lowcode/engine/meta/button.api.json +0 -0
@@ -32,6 +32,8 @@ export var COMPONENT_DRAG_OVER = 'component-drag-over';
32
32
  export var COMPONENT_DRAG_END = 'component-drag-end';
33
33
  // 保存事件
34
34
  export var DESIGN_OPERATE_SAVE = 'design-operate-save';
35
+ // 快捷键触发事件
36
+ export var DESIGN_SHORTCUT_EMIT = 'desdign-shortcut-emit';
35
37
 
36
38
  /******************************* Design Topic结束 *******************************/
37
39
 
@@ -5,10 +5,11 @@ export var RUNTIME = {
5
5
  };
6
6
  export var META_TAG_NAME = 'luckda-lcpage';
7
7
  export var COOKIE_VIRTUAL_ACCOUNT_KEY = 'Lowcode-Account';
8
- export var LC_RUNTIME_KEY = 'Lowcode-Runtime';
9
- export var LC_COMPONENT_UNIT_KEY = 'luckda-unitmark';
10
- export var LC_COMPONENT_UNIT = 'lc-component';
11
- export var LC_FORMITEM_UNIT = 'lc-formitem';
8
+ export var LC_RUNTIME_KEY = 'LD-Runtime';
9
+ export var LC_COMPONENT_UNIT_KEY = 'LD-__unitmark';
10
+ export var LC_PAGEPROXY_KEY = 'LD-__pageproxy';
11
+ export var LC_COMPONENT_UNIT = 'LD-__component';
12
+ export var LC_FORMITEM_UNIT = 'LD-__formitem';
12
13
  export var LC_BUILDIN_UNIT_KEY = {
13
14
  PAGE_ROOT: 'page_root',
14
15
  PAGE_HEADER: 'page_header',
@@ -123,6 +123,12 @@
123
123
  "desc": "用于展示组织维度层级结构的数据。它提供了层级结构、节点展开/折叠、节点选择、节点操作和展示样式等功能。",
124
124
  "icon": "icon-tree"
125
125
  },
126
+ {
127
+ "component": "Proxy",
128
+ "name": "页面代理",
129
+ "desc": "用于代理其他页面的内容,用于实现已有页面的服用。",
130
+ "icon": "icon-proxy"
131
+ },
126
132
  {
127
133
  "component": "Table",
128
134
  "name": "表格",
@@ -8,6 +8,7 @@
8
8
  "order": 1,
9
9
  "showTime": false,
10
10
  "allowClear": true,
11
+ "format": 16,
11
12
  "col": 1,
12
13
  "row": 1,
13
14
  "state": {
@@ -29,6 +29,54 @@
29
29
  "name": "日期格式",
30
30
  "type": "string"
31
31
  },
32
+ {
33
+ "key": "format",
34
+ "name": "日期格式",
35
+ "type": "select",
36
+ "options": [
37
+ {
38
+ "label": "年-月-日 时:分:秒",
39
+ "value": "YYYY-MM-DD HH:mm:ss"
40
+ },
41
+ {
42
+ "label": "年-月-日 时:分",
43
+ "value": "YYYY-MM-DD HH:mm"
44
+ },
45
+ {
46
+ "label": "年-月-日 时",
47
+ "value": "YYYY-MM-DD HH"
48
+ },
49
+ {
50
+ "label": "年-月-日",
51
+ "value": "YYYY-MM-DD"
52
+ },
53
+ {
54
+ "label": "年-月",
55
+ "value": "YYYY-MM"
56
+ },
57
+ {
58
+ "label": "年",
59
+ "value": "YYYY"
60
+ },
61
+ {
62
+ "label": "时:分:秒",
63
+ "value": "HH:mm:ss"
64
+ },
65
+ {
66
+ "label": "时:分",
67
+ "value": "HH:mm"
68
+ },
69
+ {
70
+ "label": "分:秒",
71
+ "value": "mm:ss"
72
+ },
73
+ {
74
+ "label": "年-周",
75
+ "value": "YYYY-wo"
76
+ }
77
+ ],
78
+ "default": 16
79
+ },
32
80
  {
33
81
  "key": "disabledDate",
34
82
  "name": "不可选日期",
@@ -165,6 +165,11 @@
165
165
  "triggerWord": "pagemodal",
166
166
  "completions": []
167
167
  },
168
+ {
169
+ "name": "Proxy",
170
+ "triggerWord": "proxy",
171
+ "completions": []
172
+ },
168
173
  {
169
174
  "name": "Section",
170
175
  "triggerWord": "section",
@@ -0,0 +1,8 @@
1
+ {
2
+ "component": "PageComponent",
3
+ "name": "关联页面组件",
4
+ "group": "build-in",
5
+ "advance": {
6
+ "events": {}
7
+ }
8
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "component": "PageComponent",
3
+ "name": "关联页面组件",
4
+ "group": "build-in",
5
+ "props": [
6
+ {
7
+ "key": "id",
8
+ "name": "唯一标识",
9
+ "type": "string",
10
+ "disabled": true
11
+ },
12
+ {
13
+ "key": "linkName",
14
+ "name": "页面名称",
15
+ "type": "string",
16
+ "disabled": true
17
+ },
18
+ {
19
+ "key": "linkCode",
20
+ "name": "页面编码",
21
+ "type": "string",
22
+ "disabled": true
23
+ }
24
+ ],
25
+ "advance": {
26
+ "events": [
27
+ {
28
+ "key": "onMount",
29
+ "name": "组件首次渲染完成",
30
+ "desc": "在组件首次渲染完成时,执行方法",
31
+ "func": "function onPageMount(){\n\t\n}"
32
+ },
33
+ {
34
+ "key": "onUnmount",
35
+ "name": "组件卸载时",
36
+ "desc": "在组件卸载时,执行方法。",
37
+ "func": "function onPageUnmount(){\n\t\n}"
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "component": "Proxy",
3
+ "name": "页面代理",
4
+ "desc": "用于代理其他页面的内容,用于实现已有页面的服用。",
5
+ "icon": "icon-proxy",
6
+ "group": "advance",
7
+ "groupName": "高级",
8
+ "order": 6,
9
+ "css": "width: 100%; height: 100%; background-color: transparent;",
10
+ "destroyOnUnmount": false,
11
+ "proxyParams": [],
12
+ "advance": {
13
+ "events": {}
14
+ }
15
+ }
@@ -0,0 +1,66 @@
1
+ {
2
+ "component": "Proxy",
3
+ "name": "页面代理",
4
+ "desc": "用于代理其他页面的内容,用于实现已有页面的服用。",
5
+ "icon": "icon-proxy",
6
+ "group": "advance",
7
+ "groupName": "高级",
8
+ "order": 6,
9
+ "props": [
10
+ {
11
+ "key": "id",
12
+ "name": "唯一标识",
13
+ "type": "string",
14
+ "disabled": true
15
+ },
16
+ {
17
+ "key": "destroyOnUnmount",
18
+ "name": "卸载时销毁",
19
+ "type": "switch",
20
+ "default": false
21
+ },
22
+ {
23
+ "key": "proxyCode",
24
+ "name": "页面编码",
25
+ "type": "_ProxyLinker"
26
+ },
27
+ {
28
+ "key": "proxyParams",
29
+ "name": "页面参数",
30
+ "type": "_ProxyParams",
31
+ "wrapper": "collapse",
32
+ "wrapperProps": {
33
+ "suppressIcon": true
34
+ },
35
+ "next": {
36
+ "name": "页面参数对象",
37
+ "autoClose": true,
38
+ "props": [
39
+ {
40
+ "key": "proxyParams",
41
+ "name": "#页面参数对象",
42
+ "type": "_ProxyParamsSetter",
43
+ "default": []
44
+ }
45
+ ]
46
+ }
47
+ }
48
+ ],
49
+ "css": "width: 100%; height: 100%; background-color: transparent;",
50
+ "advance": {
51
+ "events": [
52
+ {
53
+ "key": "onMount",
54
+ "name": "组件首次渲染完成",
55
+ "desc": "在组件首次渲染完成时,执行方法",
56
+ "func": "function onPageMount(){\n\t\n}"
57
+ },
58
+ {
59
+ "key": "onUnmount",
60
+ "name": "组件卸载时",
61
+ "desc": "在组件卸载时,执行方法。",
62
+ "func": "function onPageUnmount(){\n\t\n}"
63
+ }
64
+ ]
65
+ }
66
+ }
@@ -1,4 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
6
  import React, { createContext, useContext as useReactContext, useRef } from 'react';
4
7
  import { useMemoizedFn } from 'ahooks';
@@ -7,7 +10,6 @@ import { useLDEventBus } from "../EventBusProvider";
7
10
  import RemoteSourceProvider, { RemoteSourceContext } from "../RemoteSourceProvider";
8
11
  import usePageVar from "./usePageVar";
9
12
  import useTodo from "./useTodo";
10
- import { getModuleData } from "./usePageDataStore";
11
13
  import API_PREFIX from "@/services/ApiConfig";
12
14
  import { getBehaviorUrl } from "../../../constants/api-url";
13
15
  import * as topics from "../../../constants/event-topics";
@@ -60,10 +62,27 @@ export default (function (_ref) {
60
62
  if (index !== -1) {
61
63
  _componentList.current.splice(index, 1);
62
64
  }
63
- ;
64
65
  });
65
- var _initRemoteApiMap = useMemoizedFn(function (_apiMap) {
66
- _remoteApiMap.current = _apiMap;
66
+ var _initRemoteApiMap = useMemoizedFn(function (_apiMap, append) {
67
+ if (append) {
68
+ _remoteApiMap.current = new Map([].concat(_toConsumableArray(_remoteApiMap.current), _toConsumableArray(_apiMap)));
69
+ } else {
70
+ _remoteApiMap.current = _apiMap;
71
+ }
72
+ });
73
+ var _deleteRemoteApis = useMemoizedFn(function (keys) {
74
+ var _iterator = _createForOfIteratorHelper(keys),
75
+ _step;
76
+ try {
77
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
78
+ var key = _step.value;
79
+ _remoteApiMap.current.delete(key);
80
+ }
81
+ } catch (err) {
82
+ _iterator.e(err);
83
+ } finally {
84
+ _iterator.f();
85
+ }
67
86
  });
68
87
  var getElementById = useMemoizedFn(function (compId) {
69
88
  var _componentList$curren;
@@ -81,10 +100,9 @@ export default (function (_ref) {
81
100
  if (!_parentId) return null;
82
101
  return compMap.get(_parentId);
83
102
  });
84
- var want = useMemoizedFn(function (wanted) {
85
- var _getModuleData;
103
+ var want = useMemoizedFn(function (wanted, _serials) {
86
104
  if (isNil(wanted)) return false;
87
- var serials = ((_getModuleData = getModuleData()) === null || _getModuleData === void 0 ? void 0 : _getModuleData.resources) || [];
105
+ var serials = _serials || [];
88
106
  var serialMap = serials.reduce(function (acc, cur, index) {
89
107
  if (!acc[cur]) {
90
108
  acc[cur] = Math.pow(2, index);
@@ -101,6 +119,7 @@ export default (function (_ref) {
101
119
  _register: _register,
102
120
  _unregister: _unregister,
103
121
  _initRemoteApiMap: _initRemoteApiMap,
122
+ _deleteRemoteApis: _deleteRemoteApis,
104
123
  /**
105
124
  * @property {boolean} loading - loading状态
106
125
  */
@@ -179,9 +198,26 @@ export default (function (_ref) {
179
198
  var _privateGetter$curren;
180
199
  return (_privateGetter$curren = _privateGetter.current) === null || _privateGetter$curren === void 0 ? void 0 : _privateGetter$curren[property]();
181
200
  } else if (property === 'state') {
182
- return getState();
201
+ var state = getState();
202
+ return new Proxy(Object.assign({}, state), {
203
+ get: function get(stateTarget, stateProperty, stateReceiver) {
204
+ return Reflect.get(stateTarget, stateProperty, stateReceiver);
205
+ },
206
+ set: function set(stateTarget, stateProperty, stateReceiver) {
207
+ setState(_defineProperty({}, stateProperty, stateReceiver));
208
+ return true;
209
+ }
210
+ });
183
211
  } else if (property === 'global') {
184
- return global.current;
212
+ return new Proxy(Object.assign({}, global.current), {
213
+ get: function get(globalTarget, globalProperty, globalReceiver) {
214
+ return Reflect.get(globalTarget, globalProperty, globalReceiver);
215
+ },
216
+ set: function set(globalTarget, globalProperty, globalReceiver) {
217
+ setGlobal(_defineProperty({}, globalProperty, globalReceiver));
218
+ return true;
219
+ }
220
+ });
185
221
  }
186
222
  return Reflect.get(target, property, receiver);
187
223
  },
@@ -7,6 +7,7 @@ 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 { usePageProxyContext } from "../PageProxyProvider";
10
11
  import { getPathNodesById, findNodeAndParent } from "../../tools/dataProcess";
11
12
  import { LC_BUILDIN_UNIT_KEY } from "../../../constants";
12
13
  var temporalStateCreator = function temporalStateCreator(userSet, userGet, options) {
@@ -141,18 +142,12 @@ var findNode = function findNode(obj, id) {
141
142
  var usePageDataStore = create()(immer(subscribeWithSelector(temporal(function (set) {
142
143
  return {
143
144
  pageData: null,
144
- moduleData: null,
145
145
  needPrompt: false,
146
146
  initialize: function initialize(data) {
147
147
  return set(function (state) {
148
148
  state.pageData = data;
149
149
  });
150
150
  },
151
- initializeModule: function initializeModule(data) {
152
- return set(function (state) {
153
- state.moduleData = data;
154
- });
155
- },
156
151
  reset: function reset(data) {
157
152
  return set(function (state) {
158
153
  state.pageData = data || null;
@@ -260,20 +255,20 @@ export var modifyNode = function modifyNode(id, data) {
260
255
 
261
256
  /**
262
257
  * 移动页面中的一个节点到另一个位置。
263
- *
258
+ *
264
259
  * @param {string} sid - 源节点的ID。
265
260
  * @param {string} tid - 目标节点的ID。
266
261
  * @param {string} action - 移动类型,可以是 'inside', 'left', 'right' 中的一个。
267
262
  * @param {string} newid - 新节点的ID,仅在创建新节点时使用。
268
263
  * @param {Object} json - 新节点的初始属性,仅在创建新节点时使用。
269
- *
264
+ *
270
265
  * @description
271
266
  * 此函数会更新页面数据状态,根据提供的动作类型(`action`),将源节点(`sourceNode`)移动到目标节点(`targetNode`)的相应位置。
272
267
  * - 'inside': 将源节点作为目标节点的子节点。
273
268
  * - 'left': 将源节点放在目标节点的左边(同一父节点下)。
274
269
  * - 'right': 将源节点放在目标节点的右边(同一父节点下)。
275
270
  * 如果 `sid` 是空但提供了 `newid`,则函数会创建一个新的节点。
276
- *
271
+ *
277
272
  */
278
273
  export var moveNode = function moveNode(sid, tid, action, newid, json) {
279
274
  usePageDataStore.setState(function (state) {
@@ -387,30 +382,41 @@ export var useTask = function useTask(type) {
387
382
  }, []);
388
383
  return task;
389
384
  };
390
- export var useGet = function useGet(_) {
391
- var result = usePageDataStore(useShallow(function (state) {
392
- if (isNil(_)) {
393
- return state.pageData;
394
- } else if (isFunction(_)) {
395
- return _(state.pageData);
396
- } else if (isArray(_)) {
397
- return _.map(function (k) {
398
- var _findNode;
399
- return k.includes('.') ? get(state.pageData, k) : (_findNode = findNode(state.pageData, k)) === null || _findNode === void 0 ? void 0 : _findNode.target;
385
+ var getTargetData = function getTargetData(_, source) {
386
+ if (isNil(_)) {
387
+ return source;
388
+ } else if (isFunction(_)) {
389
+ return _(source);
390
+ } else if (isArray(_)) {
391
+ return _.map(function (k) {
392
+ var _findNode;
393
+ return k.includes('.') ? get(source, k) : (_findNode = findNode(source, k)) === null || _findNode === void 0 ? void 0 : _findNode.target;
394
+ });
395
+ } else if (isObject(_) && _.id) {
396
+ var _findNode2;
397
+ var path = _.path;
398
+ var _target = _.id === LC_BUILDIN_UNIT_KEY.PAGE_ROOT ? source : (_findNode2 = findNode(source, _.id)) === null || _findNode2 === void 0 ? void 0 : _findNode2.target;
399
+ if (isNil(path)) {
400
+ return _target;
401
+ } else if (isString(path)) {
402
+ return get(_target, path);
403
+ } else if (isArray(path)) {
404
+ return path.map(function (k) {
405
+ return get(_target, k);
400
406
  });
401
- } else if (isObject(_) && _.id) {
402
- var _findNode2;
403
- var path = _.path;
404
- var _target = _.id === LC_BUILDIN_UNIT_KEY.PAGE_ROOT ? state.pageData : (_findNode2 = findNode(state.pageData, _.id)) === null || _findNode2 === void 0 ? void 0 : _findNode2.target;
405
- return isNil(path) ? _target : get(_target, path);
406
- } else if (isString(_)) {
407
- return get(state.pageData, _);
408
407
  }
409
- }));
410
- return result;
408
+ } else if (isString(_)) {
409
+ return get(state.pageData, _);
410
+ }
411
411
  };
412
- export var getModuleData = function getModuleData() {
413
- return usePageDataStore.getState().moduleData;
412
+ export var useGet = function useGet(_) {
413
+ var ppCtx = usePageProxyContext();
414
+ if (ppCtx !== null && ppCtx !== void 0 && ppCtx.proxyCode) {
415
+ return getTargetData(_, usePageDataStore.getState()[ppCtx.proxyCode]);
416
+ }
417
+ return usePageDataStore(useShallow(function (state) {
418
+ return getTargetData(_, state.pageData);
419
+ }));
414
420
  };
415
421
  export var setNeedPrompt = function setNeedPrompt(_need) {
416
422
  usePageDataStore.setState(function (state) {
@@ -3,18 +3,24 @@ import { useMemoizedFn } from 'ahooks';
3
3
  import { create } from 'zustand';
4
4
  import { immer } from 'zustand/middleware/immer';
5
5
  import { subscribeWithSelector } from 'zustand/middleware';
6
- import { forOwn, isNil, isString, isObject } from 'lodash';
6
+ import { forOwn, isNil, isString, isObject, omit } from 'lodash';
7
7
  export var useStateStore = create()(immer(subscribeWithSelector(function (set) {
8
8
  return {
9
9
  state: {},
10
- initialize: function initialize(init) {
10
+ initialize: function initialize(init, append) {
11
11
  return set(function (store) {
12
- store.state = init;
12
+ if (append) {
13
+ forOwn(init, function (value, key) {
14
+ store.state[key] = value;
15
+ });
16
+ } else {
17
+ store.state = init;
18
+ }
13
19
  });
14
20
  },
15
- clear: function clear() {
21
+ clear: function clear(_vars) {
16
22
  return set(function (store) {
17
- store.state = {};
23
+ store.state = omit(store.state, _vars);
18
24
  });
19
25
  }
20
26
  };
@@ -6,8 +6,7 @@ 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 { getModuleData } from "./usePageDataStore";
10
- import { executeCode } from "../../tools/helper";
9
+ import { executeCode, getLDMetaAttr } from "../../tools/helper";
11
10
  import { fetchCallBehavior } from "../../../constants/api-url";
12
11
  var useTodo = function useTodo() {
13
12
  var _useBoolean = useBoolean(),
@@ -54,8 +53,7 @@ var useTodo = function useTodo() {
54
53
  params = _ref4.params,
55
54
  data = _ref4.data,
56
55
  after = _ref4.after;
57
- var moduleData = getModuleData();
58
- var _moduleCode = moduleCode || moduleData.moduleCode;
56
+ var _moduleCode = moduleCode || getLDMetaAttr('moduleCode');
59
57
  var _dscode = datasetCode || dsCode;
60
58
  if (!_moduleCode || !_dscode) {
61
59
  message.warning('接口重要参数(模块编码或数据集编码)丢失');
@@ -58,7 +58,7 @@ export default (function (_ref) {
58
58
  var _ref4 = _slicedToArray(_ref3, 2),
59
59
  _id = _ref4[0],
60
60
  _subscriber = _ref4[1];
61
- var temp = _subscriber._before ? _subscriber._before(payload) : null;
61
+ var temp = _subscriber._before ? _subscriber._before(payload, _id) : null;
62
62
  if (_subscriber._before && !isPromise(temp)) {
63
63
  console.error('before hook must return a promise');
64
64
  return;
@@ -68,10 +68,10 @@ export default (function (_ref) {
68
68
  if (!flag) return flag;
69
69
  var func = _subscriber._once || _subscriber._on;
70
70
  if (!func) return;
71
- return func(payload);
71
+ return func(payload, _id);
72
72
  }).then(function (flag) {
73
73
  if (flag === false || !_subscriber._after) return;
74
- return _subscriber._after(payload);
74
+ return _subscriber._after(payload, _id);
75
75
  }).finally(function () {
76
76
  if (_subscriber._once) {
77
77
  $unsubscriber(topic, _id);
@@ -85,6 +85,15 @@ export default (function (_ref) {
85
85
  runtime: runtime
86
86
  }, payload));
87
87
  });
88
+ var $publisherOnce = useMemoizedFn(function (topic, payload) {
89
+ return new Promise(function (resolve) {
90
+ event$.emit(_objectSpread({
91
+ topic: topic,
92
+ runtime: runtime
93
+ }, payload));
94
+ $subscriber(topic).once(resolve).watch();
95
+ });
96
+ });
88
97
  var $subscriber = useMemoizedFn(function (topic) {
89
98
  if (!subscriberPool.has(topic)) subscriberPool.set(topic, []);
90
99
  var id = suid();
@@ -104,7 +113,7 @@ export default (function (_ref) {
104
113
  if (!subscriberPool.get(topic).length) {
105
114
  subscriberPool.delete(topic);
106
115
  }
107
- (_subscriber$_off = (_subscriber2 = _subscriber)._off) === null || _subscriber$_off === void 0 || _subscriber$_off.call(_subscriber2);
116
+ (_subscriber$_off = (_subscriber2 = _subscriber)._off) === null || _subscriber$_off === void 0 || _subscriber$_off.call(_subscriber2, _id);
108
117
  _subscriber = null;
109
118
  }
110
119
  });
@@ -113,6 +122,7 @@ export default (function (_ref) {
113
122
  value: {
114
123
  runtime: runtime,
115
124
  $publisher: $publisher,
125
+ $publisherOnce: $publisherOnce,
116
126
  $subscriber: $subscriber,
117
127
  $unsubscriber: $unsubscriber
118
128
  }
@@ -0,0 +1,95 @@
1
+ import React, { createContext, useContext as useReactContext, useEffect } from 'react';
2
+ import { useRequest, useCreation } from 'ahooks';
3
+ import { Empty, Spin } from 'luck-design/antd';
4
+ import { isNil, reduce } from 'lodash';
5
+ import { formatMessage } from '@luck-design-biz/base/utils';
6
+ import { useContext } from "./ContextProvider";
7
+ import usePageDataStore from "./ContextProvider/usePageDataStore";
8
+ import { decompress } from "../tools/dataProcess";
9
+ import { fetchPageData } from "../../constants/api-url";
10
+ export var Context = /*#__PURE__*/createContext(null);
11
+ export var usePageProxyContext = function usePageProxyContext() {
12
+ return useReactContext(Context);
13
+ };
14
+ export default (function (_ref) {
15
+ var children = _ref.children,
16
+ id = _ref.id,
17
+ proxyCode = _ref.proxyCode,
18
+ destroyOnUnmount = _ref.destroyOnUnmount,
19
+ proxyParams = _ref.proxyParams;
20
+ if (isNil(proxyCode)) return /*#__PURE__*/React.createElement(Empty, {
21
+ description: formatMessage({
22
+ id: 'luckda.lowcode.view.lc-component.design.nocode',
23
+ label: '缺少页面代理编码配置'
24
+ })
25
+ });
26
+ var ctx = useContext();
27
+ var _useRequest = useRequest(fetchPageData, {
28
+ defaultParams: [{
29
+ code: proxyCode
30
+ }],
31
+ ready: !usePageDataStore.getState()[proxyCode],
32
+ onFinally: function onFinally() {
33
+ ctx.$publisher(ctx.topics.PAGE_LOAD_MOUNT, {
34
+ proxyCode: proxyCode
35
+ });
36
+ },
37
+ onSuccess: function onSuccess(_ref2) {
38
+ var code = _ref2.code,
39
+ data = _ref2.data,
40
+ list = _ref2.list,
41
+ detail = _ref2.detail;
42
+ if (code === 1) {
43
+ usePageDataStore.setState(function (state) {
44
+ var source = detail[list[0]].source;
45
+ state[proxyCode] = decompress(source);
46
+ });
47
+ }
48
+ }
49
+ }),
50
+ loading = _useRequest.loading;
51
+ useEffect(function () {
52
+ if (usePageDataStore.getState()[proxyCode]) {
53
+ ctx.$publisher(ctx.topics.PAGE_LOAD_MOUNT, {
54
+ proxyCode: proxyCode
55
+ });
56
+ }
57
+ return function () {
58
+ if (destroyOnUnmount) {
59
+ usePageDataStore.setState(function (state) {
60
+ state[proxyCode] = null;
61
+ });
62
+ }
63
+ };
64
+ }, []);
65
+ var _proxyParams = useCreation(function () {
66
+ return reduce(proxyParams, function (ret, param) {
67
+ switch (param.origin) {
68
+ case 'state':
69
+ ret[param.name] = ctx.state[param.value];
70
+ return ret;
71
+ case 'golbal':
72
+ ret[param.name] = ctx.global[param.value];
73
+ return ret;
74
+ case 'url':
75
+ ret[param.name] = ctx.router.getQuery(param.value);
76
+ return ret;
77
+ case 'string':
78
+ case 'num':
79
+ case 'bool':
80
+ default:
81
+ ret[param.name] = param.value;
82
+ return ret;
83
+ }
84
+ }, {});
85
+ }, []);
86
+ return /*#__PURE__*/React.createElement(Context.Provider, {
87
+ value: {
88
+ id: id,
89
+ proxyCode: proxyCode,
90
+ params: _proxyParams
91
+ }
92
+ }, /*#__PURE__*/React.createElement(Spin, {
93
+ spinning: loading
94
+ }, children));
95
+ });