@cloud-app-dev/vidc 2.0.0-alpha.9 → 2.1.0-alpha.2

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 (198) hide show
  1. package/.fatherrc.js +11 -4
  2. package/.umirc.ts +1 -1
  3. package/es/Api/index.js +7 -7
  4. package/es/AppRedirect/index.d.ts +1 -1
  5. package/es/AppRedirect/index.js +7 -12
  6. package/es/Auth/index.js +1 -1
  7. package/es/AutoExit/index.js +12 -10
  8. package/es/{ContentBox → Box}/BetweenBox/index.css +0 -0
  9. package/es/{ContentBox → Box}/BetweenBox/index.d.ts +0 -0
  10. package/es/{ContentBox → Box}/BetweenBox/index.js +0 -0
  11. package/es/{ContentBox → Box}/InfoBox/index.css +0 -0
  12. package/es/{ContentBox → Box}/InfoBox/index.d.ts +0 -0
  13. package/es/{ContentBox → Box}/InfoBox/index.js +0 -0
  14. package/es/{ContentBox → Box}/TwoColumnBox/index.css +0 -0
  15. package/es/{ContentBox → Box}/TwoColumnBox/index.d.ts +0 -0
  16. package/es/{ContentBox → Box}/TwoColumnBox/index.js +0 -0
  17. package/es/{ContentBox → Box}/deps/content-grid.d.ts +0 -0
  18. package/es/{ContentBox → Box}/deps/content-grid.js +0 -0
  19. package/es/{ContentBox → Box}/deps/grid-factory.d.ts +0 -0
  20. package/es/{ContentBox → Box}/deps/grid-factory.js +0 -0
  21. package/es/{ContentBox → Box}/deps/simple-grid.d.ts +0 -0
  22. package/es/{ContentBox → Box}/deps/simple-grid.js +0 -0
  23. package/es/{ContentBox → Box}/index.css +0 -0
  24. package/es/{ContentBox → Box}/index.d.ts +3 -3
  25. package/es/{ContentBox → Box}/index.js +5 -5
  26. package/es/CheckGroupFixed/index.js +4 -2
  27. package/es/Config/index.js +12 -12
  28. package/es/Config/interface.d.ts +6 -4
  29. package/es/ConfigContext/index.d.ts +15 -2
  30. package/es/ConfigContext/index.js +25 -3
  31. package/es/DeviceSelect/TreeType.d.ts +6 -0
  32. package/es/DeviceSelect/TreeType.js +36 -0
  33. package/es/DeviceSelect/demo.js +2 -2
  34. package/es/DeviceSelect/index.css +6 -1
  35. package/es/DeviceSelect/index.d.ts +5 -0
  36. package/es/DeviceSelect/index.js +22 -54
  37. package/es/Dict/desc.js +3 -3
  38. package/es/Dict/utils.js +3 -3
  39. package/es/HightLevel/index.js +1 -2
  40. package/es/IconFont/index.d.ts +0 -1
  41. package/es/IconFont/index.js +12 -13
  42. package/es/InitialConfig/index.js +7 -4
  43. package/es/InitialConfig/utils.d.ts +5 -0
  44. package/es/InitialConfig/utils.js +33 -6
  45. package/es/InitialRequest/index.d.ts +3 -1
  46. package/es/InitialRequest/index.js +20 -18
  47. package/es/InitialRequest/utils.d.ts +4 -3
  48. package/es/InitialRequest/utils.js +26 -27
  49. package/es/Input/index.js +3 -2
  50. package/es/InstanceHistory/index.d.ts +3 -0
  51. package/es/InstanceHistory/index.js +9 -0
  52. package/es/List/CheckExt.d.ts +3 -5
  53. package/es/List/CheckExt.js +21 -13
  54. package/es/{AppRoute → List/DeviceList}/index.css +0 -0
  55. package/es/List/DeviceList/index.d.ts +11 -0
  56. package/es/{DeviceList → List/DeviceList}/index.js +6 -18
  57. package/es/{DynamicDeviceList → List/DynamicDeviceList}/Demo.d.ts +0 -0
  58. package/es/{DynamicList/demo.js → List/DynamicDeviceList/Demo.js} +25 -42
  59. package/es/{DynamicDeviceList → List/DynamicDeviceList}/index.css +5 -17
  60. package/es/List/DynamicDeviceList/index.d.ts +11 -0
  61. package/es/List/DynamicDeviceList/index.js +205 -0
  62. package/es/List/DynamicDeviceList/interface.d.ts +37 -0
  63. package/es/List/DynamicDeviceList/utils.d.ts +16 -0
  64. package/es/List/DynamicDeviceList/utils.js +61 -0
  65. package/es/{DynamicList/demo.d.ts → List/DynamicGridList/Demo.d.ts} +0 -0
  66. package/es/List/DynamicGridList/Demo.js +70 -0
  67. package/es/List/DynamicGridList/index.d.ts +26 -0
  68. package/es/List/DynamicGridList/index.js +73 -0
  69. package/es/List/GridList/Demo.d.ts +2 -0
  70. package/es/List/GridList/Demo.js +91 -0
  71. package/es/List/GridList/hook.d.ts +13 -0
  72. package/es/List/GridList/hook.js +301 -0
  73. package/es/List/GridList/index.css +7 -0
  74. package/es/List/GridList/index.d.ts +15 -0
  75. package/es/List/GridList/index.js +47 -0
  76. package/es/List/GridList/interface.d.ts +59 -0
  77. package/es/List/GridList/utils.d.ts +9 -0
  78. package/es/List/GridList/utils.js +43 -0
  79. package/es/List/ListExt/index.css +3 -0
  80. package/es/{ListExt → List/ListExt}/index.d.ts +1 -1
  81. package/es/{ListExt → List/ListExt}/index.js +3 -3
  82. package/es/List/VList/index.css +6 -0
  83. package/es/List/VList/index.d.ts +18 -0
  84. package/es/List/VList/index.js +51 -0
  85. package/es/List/VList/utils.d.ts +14 -0
  86. package/es/{VList → List/VList}/utils.js +0 -0
  87. package/es/List/index.css +11 -12
  88. package/es/List/index.d.ts +5 -70
  89. package/es/List/index.js +32 -25
  90. package/es/List/interface.d.ts +87 -0
  91. package/es/List/renderItem.d.ts +1 -1
  92. package/es/List/renderItem.js +13 -10
  93. package/es/LoaderApp/index.d.ts +1 -1
  94. package/es/LoaderApp/index.js +18 -18
  95. package/es/LoaderApp/utils.d.ts +2 -1
  96. package/es/LoaderApp/utils.js +6 -3
  97. package/es/LoaderScript/index.js +7 -89
  98. package/es/LoaderScript/utils.d.ts +2 -0
  99. package/es/LoaderScript/utils.js +170 -33
  100. package/es/Picture/component/MoveContent/index.js +3 -3
  101. package/es/Picture/index.js +1 -1
  102. package/es/Picture/utils.js +1 -1
  103. package/es/RefDrawer/index.js +1 -1
  104. package/es/RefModal/index.js +1 -1
  105. package/es/Service/http.d.ts +6 -4
  106. package/es/Service/http.js +20 -22
  107. package/es/Service/index.d.ts +3 -3
  108. package/es/Service/index.js +7 -11
  109. package/es/Service/interface.d.ts +5 -11
  110. package/es/Service/middleware.d.ts +1 -1
  111. package/es/Service/middleware.js +1 -1
  112. package/es/TableLayout/index.d.ts +3 -0
  113. package/es/TableLayout/index.js +14 -45
  114. package/es/{TreeTitle → Title}/index.css +5 -5
  115. package/es/{TreeTitle → Title}/index.d.ts +2 -2
  116. package/es/{TreeTitle → Title}/index.js +7 -4
  117. package/es/{TreeMode → Tree/BaseTree}/demo.d.ts +0 -0
  118. package/es/Tree/BaseTree/demo.js +69 -0
  119. package/es/Tree/BaseTree/index.css +64 -0
  120. package/es/Tree/BaseTree/index.d.ts +24 -0
  121. package/es/Tree/BaseTree/index.js +83 -0
  122. package/es/Tree/demo.js +19 -56
  123. package/es/Tree/index.css +29 -55
  124. package/es/Tree/index.d.ts +19 -20
  125. package/es/Tree/index.js +185 -70
  126. package/es/UserSelect/index.js +7 -8
  127. package/es/WorkerFlow/Form/Condition.js +2 -4
  128. package/es/WorkerFlow/Form/EmptyUserSet.js +1 -1
  129. package/es/WorkerFlow/Form/FormAuth.js +3 -3
  130. package/es/WorkerFlow/Form/GroupList.js +2 -2
  131. package/es/WorkerFlow/Form/GroupSelect.js +1 -1
  132. package/es/WorkerFlow/Form/GroupSelectModalContent.js +2 -3
  133. package/es/WorkerFlow/Form/LevelGroupSelect.js +2 -2
  134. package/es/WorkerFlow/Form/UserAndGroupSelect.js +1 -1
  135. package/es/WorkerFlow/Form/UserSelect.js +1 -1
  136. package/es/WorkerFlow/Form/UserSelectModalContent.js +3 -6
  137. package/es/WorkerFlow/Form/UserSet.js +3 -3
  138. package/es/WorkerFlow/Nodes/TitleElement.js +71 -34
  139. package/es/WorkerFlow/index.css +9 -3
  140. package/es/WorkerFlow/index.js +14 -9
  141. package/es/WorkerFlow/utils.js +1 -1
  142. package/es/index.d.ts +3 -11
  143. package/es/index.js +3 -11
  144. package/es/useDrawer/index.d.ts +1 -1
  145. package/es/useDrawer/index.js +3 -2
  146. package/es/useHistory/index.d.ts +2 -2
  147. package/es/useHistory/index.js +3 -6
  148. package/es/useHttp/index.js +1 -1
  149. package/es/useModal/index.d.ts +1 -1
  150. package/es/useModal/index.js +3 -2
  151. package/es/utils.d.ts +9 -0
  152. package/es/utils.js +36 -1
  153. package/package.json +10 -11
  154. package/tsconfig.json +1 -1
  155. package/es/AppRoute/Render.d.ts +0 -23
  156. package/es/AppRoute/Render.js +0 -111
  157. package/es/AppRoute/Rendered.d.ts +0 -4
  158. package/es/AppRoute/Rendered.js +0 -11
  159. package/es/AppRoute/index.d.ts +0 -14
  160. package/es/AppRoute/index.js +0 -106
  161. package/es/AppRoute/interface.d.ts +0 -18
  162. package/es/AppRoute/utils.d.ts +0 -1
  163. package/es/AppRoute/utils.js +0 -28
  164. package/es/DeviceList/index.css +0 -32
  165. package/es/DeviceList/index.d.ts +0 -14
  166. package/es/DynamicDeviceList/CheckExt.d.ts +0 -8
  167. package/es/DynamicDeviceList/CheckExt.js +0 -36
  168. package/es/DynamicDeviceList/Demo.js +0 -17
  169. package/es/DynamicDeviceList/index.d.ts +0 -35
  170. package/es/DynamicDeviceList/index.js +0 -224
  171. package/es/DynamicDeviceList/utils.d.ts +0 -2
  172. package/es/DynamicDeviceList/utils.js +0 -15
  173. package/es/DynamicList/index.css +0 -7
  174. package/es/DynamicList/index.d.ts +0 -31
  175. package/es/DynamicList/index.js +0 -132
  176. package/es/IconFont/index.css +0 -0
  177. package/es/List/utils.d.ts +0 -5
  178. package/es/List/utils.js +0 -18
  179. package/es/ListExt/index.css +0 -9
  180. package/es/ScrollList/index.css +0 -73
  181. package/es/ScrollList/index.d.ts +0 -24
  182. package/es/ScrollList/index.js +0 -262
  183. package/es/ScrollList/utils.js +0 -84
  184. package/es/Service/logger.d.ts +0 -3
  185. package/es/Service/logger.js +0 -13
  186. package/es/Service/utils.d.ts +0 -3
  187. package/es/Service/utils.js +0 -11
  188. package/es/TreeMode/demo.js +0 -32
  189. package/es/TreeMode/index.css +0 -38
  190. package/es/TreeMode/index.d.ts +0 -23
  191. package/es/TreeMode/index.js +0 -201
  192. package/es/VList/index.css +0 -4
  193. package/es/VList/index.d.ts +0 -16
  194. package/es/VList/index.js +0 -56
  195. package/es/VList/utils.d.ts +0 -10
  196. package/es/useChangeEffect/index.d.ts +0 -3
  197. package/es/useChangeEffect/index.js +0 -32
  198. package/es/useHistory/index.css +0 -0
@@ -1,74 +1,5 @@
1
- import React from 'react';
1
+ import { CheckListProps } from './interface';
2
2
  import './index.less';
3
- export interface CheckListProps<T> {
4
- /**
5
- * @description 列表数据
6
- * @default []
7
- */
8
- list?: Array<T>;
9
- /**
10
- * @description 列表类名
11
- * @default ''
12
- */
13
- className?: string;
14
- /**
15
- * @description 列表样式
16
- * @default -
17
- */
18
- style?: React.CSSProperties;
19
- /**
20
- * @description 列表自定义渲染
21
- * @default -
22
- */
23
- CustomRender?: () => JSX.Element;
24
- /**
25
- * @description 列表渲染key字段
26
- * @default id
27
- */
28
- itemKey?: string;
29
- /**
30
- * @description 列表渲染label字段
31
- * @default name
32
- */
33
- itemNameKey?: string;
34
- /**
35
- * @description 激活列表key
36
- * @default -
37
- */
38
- activeKey?: string;
39
- /**
40
- * @description 列表拓展内容
41
- * @default -
42
- */
43
- checkExt?: React.ReactNode;
44
- /**
45
- * @description 选中事件,影响是否有checkbox
46
- * @default -
47
- */
48
- onChecked?: (ids: Array<string>) => void;
49
- /**
50
- * @description 选中的key
51
- * @default []
52
- */
53
- checkedKeys?: string[];
54
- /**
55
- * @description 默认选中的key
56
- * @default []
57
- */
58
- defaultCheckedIds?: string[];
59
- /**
60
- * @description 高亮关键字
61
- * @default -
62
- */
63
- keywords?: string;
64
- rowHeight?: number;
65
- whatIcon?: (item: T) => JSX.Element;
66
- renderItemExt?: (item: T) => JSX.Element;
67
- onClickItem?: (item: T) => void;
68
- onMouseOutItem?: (item: T) => void;
69
- onMouseOverItem?: (item: T) => void;
70
- renderHeader?: () => JSX.Element;
71
- }
72
3
  declare function List(props: CheckListProps<any>): JSX.Element;
73
4
  declare namespace List {
74
5
  var defaultProps: {
@@ -77,5 +8,9 @@ declare namespace List {
77
8
  itemKey: string;
78
9
  itemNameKey: string;
79
10
  };
11
+ var VList: typeof import("./VList").default;
12
+ var DeviceList: typeof import("./DeviceList").default;
13
+ var ListExt: typeof import("./ListExt").default;
14
+ var DynamicDeviceList: typeof import("./DynamicDeviceList").default;
80
15
  }
81
16
  export default List;
package/es/List/index.js CHANGED
@@ -21,12 +21,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
21
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
22
 
23
23
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
24
- import difference from 'lodash-es/difference';
25
- import uniq from 'lodash-es/uniq';
26
- import VList from '../VList';
24
+ import VList from './VList';
27
25
  import { RenderItem } from './renderItem';
28
- import { computedCheckStatus } from './utils';
29
26
  import CheckExt from './CheckExt';
27
+ import DeviceList from './DeviceList';
28
+ import ListExt from './ListExt';
29
+ import DynamicDeviceList from './DynamicDeviceList';
30
30
  import "./index.css";
31
31
 
32
32
  function List(props) {
@@ -51,13 +51,6 @@ function List(props) {
51
51
  state = _useState2[0],
52
52
  setState = _useState2[1];
53
53
 
54
- var _useMemo = useMemo(function () {
55
- return computedCheckStatus(list, state.checkedKeys, itemKey);
56
- }, [itemKey, list, state.checkedKeys]),
57
- checkHalfStatus = _useMemo.checkHalfStatus,
58
- checkAllStatus = _useMemo.checkAllStatus,
59
- listKey = _useMemo.listKey;
60
-
61
54
  var checkable = useMemo(function () {
62
55
  return !!onChecked;
63
56
  }, []);
@@ -85,17 +78,14 @@ function List(props) {
85
78
  });
86
79
  onChecked && onChecked(ids);
87
80
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
88
- [listKey, state.checkedKeys]);
81
+ [state.checkedKeys]);
89
82
  /**
90
83
  * 列表渲染
91
84
  */
92
85
 
93
- var renderRow = useCallback(function (_ref) {
94
- var key = _ref.key,
95
- index = _ref.index,
96
- style = _ref.style;
86
+ var renderRow = useCallback(function (data, index) {
97
87
  var options = Object.assign(Object.assign({}, state), {
98
- item: list[index],
88
+ item: data,
99
89
  onChecked: onCheckedAction,
100
90
  checkable: !!onChecked,
101
91
  index: index,
@@ -112,7 +102,7 @@ function List(props) {
112
102
  });
113
103
  var ItemRender = CustomRender ? CustomRender : RenderItem;
114
104
  return /*#__PURE__*/React.createElement(ItemRender, Object.assign({
115
- key: key
105
+ key: index
116
106
  }, options));
117
107
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
118
108
  [list, state, onChecked, CustomRender, activeKey]);
@@ -120,15 +110,29 @@ function List(props) {
120
110
  * 列表全选处理
121
111
  */
122
112
 
123
- var onChangeCheckAll = useCallback(function () {
124
- var ids = checkAllStatus ? difference(state.checkedKeys, listKey) : uniq([].concat(state.checkedKeys, listKey));
113
+ var onCheck = useCallback(function () {
114
+ var ids = list.map(function (v) {
115
+ return v[itemKey];
116
+ });
125
117
  setState(function (old) {
126
118
  return Object.assign(Object.assign({}, old), {
127
119
  checkedKeys: _toConsumableArray(ids)
128
120
  });
129
121
  });
130
122
  props.onChecked && props.onChecked(ids); // eslint-disable-next-line react-hooks/exhaustive-deps
131
- }, [checkAllStatus, state.checkedKeys, listKey]);
123
+ }, [itemKey, list]);
124
+ /**
125
+ * 列表取消
126
+ */
127
+
128
+ var onCancel = useCallback(function () {
129
+ setState(function (old) {
130
+ return Object.assign(Object.assign({}, old), {
131
+ checkedKeys: []
132
+ });
133
+ });
134
+ props.onChecked && props.onChecked([]); // eslint-disable-next-line react-hooks/exhaustive-deps
135
+ }, [itemKey, list]);
132
136
  /**
133
137
  * 同步选中更新
134
138
  */
@@ -147,18 +151,17 @@ function List(props) {
147
151
  className: "lm-c-check-list-wrapper ".concat(className),
148
152
  style: style
149
153
  }, renderHeader && renderHeader(), checkExt, checkable && /*#__PURE__*/React.createElement(CheckExt, {
150
- checkHalfStatus: checkHalfStatus,
151
154
  selectCount: state.checkedKeys.length,
152
155
  count: list.length,
153
- onChange: onChangeCheckAll,
154
- checkAllStatus: checkAllStatus
156
+ onCheck: onCheck,
157
+ onCancel: onCancel
155
158
  }), /*#__PURE__*/React.createElement("div", {
156
159
  className: "lm-c-base-list-layout"
157
160
  }, /*#__PURE__*/React.createElement(VList, {
158
161
  className: "lm-c-virtual-layout",
159
162
  data: list,
160
163
  rowHeight: rowHeight || 30,
161
- rowRenderer: renderRow
164
+ renderItem: renderRow
162
165
  })));
163
166
  }
164
167
 
@@ -168,4 +171,8 @@ List.defaultProps = {
168
171
  itemKey: 'id',
169
172
  itemNameKey: 'name'
170
173
  };
174
+ List.VList = VList;
175
+ List.DeviceList = DeviceList;
176
+ List.ListExt = ListExt;
177
+ List.DynamicDeviceList = DynamicDeviceList;
171
178
  export default List;
@@ -0,0 +1,87 @@
1
+ export interface CheckListProps<T> {
2
+ /**
3
+ * @description 列表数据
4
+ * @default []
5
+ */
6
+ list?: Array<T>;
7
+
8
+ /**
9
+ * @description 列表类名
10
+ * @default ''
11
+ */
12
+ className?: string;
13
+
14
+ /**
15
+ * @description 列表样式
16
+ * @default -
17
+ */
18
+ style?: React.CSSProperties;
19
+
20
+ /**
21
+ * @description 列表自定义渲染
22
+ * @default -
23
+ */
24
+ CustomRender?: () => JSX.Element;
25
+
26
+ /**
27
+ * @description 列表渲染key字段
28
+ * @default id
29
+ */
30
+ itemKey?: string;
31
+
32
+ /**
33
+ * @description 列表渲染label字段
34
+ * @default name
35
+ */
36
+ itemNameKey?: string;
37
+
38
+ /**
39
+ * @description 激活列表key
40
+ * @default -
41
+ */
42
+ activeKey?: string;
43
+
44
+ /**
45
+ * @description 列表拓展内容
46
+ * @default -
47
+ */
48
+ checkExt?: React.ReactNode;
49
+
50
+ /**
51
+ * @description 选中事件,影响是否有checkbox
52
+ * @default -
53
+ */
54
+ onChecked?: (ids: Array<string>) => void;
55
+
56
+ /**
57
+ * @description 选中的key
58
+ * @default []
59
+ */
60
+ checkedKeys?: string[];
61
+
62
+ /**
63
+ * @description 默认选中的key
64
+ * @default []
65
+ */
66
+ defaultCheckedIds?: string[];
67
+
68
+ /**
69
+ * @description 高亮关键字
70
+ * @default -
71
+ */
72
+ keywords?: string;
73
+
74
+ rowHeight?: number;
75
+
76
+ whatIcon?: (item: T) => JSX.Element;
77
+
78
+ renderItemExt?: (item: T) => JSX.Element;
79
+
80
+ onClickItem?: (item: T) => void;
81
+
82
+ onMouseOutItem?: (item: T) => void;
83
+
84
+ onMouseOverItem?: (item: T) => void;
85
+
86
+ renderHeader?: () => JSX.Element;
87
+ }
@@ -16,5 +16,5 @@ interface IRenderItempProps<T> {
16
16
  onMouseOverItem?: (item: T) => void;
17
17
  onMouseOutItem?: (item: T) => void;
18
18
  }
19
- export declare function RenderItem(props: IRenderItempProps<any>): JSX.Element;
19
+ export declare function RenderItem({ item, checkedKeys, activeKey, style, itemNameKey, itemKey, checkable, keywords, ...props }: IRenderItempProps<any>): JSX.Element;
20
20
  export {};
@@ -1,18 +1,21 @@
1
1
  import "antd/lib/checkbox/style";
2
2
  import _Checkbox from "antd/lib/checkbox";
3
+ import { __rest } from "tslib";
3
4
  import React, { useCallback, useMemo } from 'react';
4
5
  import HightLevel from '../HightLevel';
5
- export function RenderItem(props) {
6
- var item = props.item,
7
- checkedKeys = props.checkedKeys,
8
- activeKey = props.activeKey,
9
- style = props.style,
10
- itemNameKey = props.itemNameKey,
11
- renderItemExt = props.renderItemExt,
6
+ export function RenderItem(_a) {
7
+ var item = _a.item,
8
+ checkedKeys = _a.checkedKeys,
9
+ activeKey = _a.activeKey,
10
+ style = _a.style,
11
+ itemNameKey = _a.itemNameKey,
12
+ itemKey = _a.itemKey,
13
+ checkable = _a.checkable,
14
+ keywords = _a.keywords,
15
+ props = __rest(_a, ["item", "checkedKeys", "activeKey", "style", "itemNameKey", "itemKey", "checkable", "keywords"]);
16
+
17
+ var renderItemExt = props.renderItemExt,
12
18
  whatIcon = props.whatIcon,
13
- itemKey = props.itemKey,
14
- checkable = props.checkable,
15
- keywords = props.keywords,
16
19
  onChecked = props.onChecked,
17
20
  onClickItem = props.onClickItem,
18
21
  onMouseOverItem = props.onMouseOverItem,
@@ -12,7 +12,6 @@ interface ILoaderAppProps {
12
12
  * @default {}
13
13
  */
14
14
  appProps: {
15
- updateTime?: number;
16
15
  [key: string]: any;
17
16
  };
18
17
  /**
@@ -26,6 +25,7 @@ declare namespace LoaderApp {
26
25
  var defaultProps: {
27
26
  appConfig: {};
28
27
  appProps: {};
28
+ style: {};
29
29
  };
30
30
  }
31
31
  export default LoaderApp;
@@ -41,18 +41,29 @@ function LoaderApp(_ref) {
41
41
  var config = getMicroConfig(appConfig, appProps, domRef.current);
42
42
 
43
43
  if (!config) {
44
- console.debug('微应用不存在', 'config ->', appConfig, 'appProps ->', appProps);
44
+ console.error('微应用不存在', 'config ->', appConfig, 'appProps ->', appProps);
45
+ return undefined;
46
+ }
47
+
48
+ if (!domRef.current || !styleRef.current) {
49
+ console.error('LoaderApp组件未正常初始化!', 'config ->', appConfig, 'appProps ->', appProps);
45
50
  return undefined;
46
51
  }
47
52
 
48
53
  var props = Object.assign(Object.assign({}, appProps), {
49
54
  container: domRef.current
50
55
  });
56
+ var routerPrefix = config.routerPrefix;
57
+
58
+ var _appConfig$resource = _slicedToArray(appConfig.resource, 2),
59
+ script = _appConfig$resource[0],
60
+ style = _appConfig$resource[1];
61
+
51
62
  var options = {
52
- script: appConfig.resource[0],
53
- style: appConfig.resource[1],
54
- name: config.name,
55
- prefix: ".".concat(appConfig.name, "-").concat(id),
63
+ script: script,
64
+ style: style,
65
+ name: routerPrefix,
66
+ prefix: ".".concat(routerPrefix, "-").concat(id),
56
67
  styleNode: styleRef.current
57
68
  };
58
69
  LoaderModule(options).then(function (mod) {
@@ -98,18 +109,6 @@ function LoaderApp(_ref) {
98
109
  }
99
110
  };
100
111
  }, []);
101
- useEffect(function () {
102
- var currentId = appProps.currentId,
103
- tabId = appProps.tabId;
104
-
105
- if (currentId === tabId && loadedAppRef.current) {
106
- var props = Object.assign(Object.assign({}, appProps), {
107
- container: domRef.current
108
- });
109
- console.debug('执行更新!', appProps);
110
- loadedAppRef.current.update && loadedAppRef.current.update(props);
111
- }
112
- }, [appProps.currentId, appProps.tabId, appProps.updateTime]);
113
112
  return /*#__PURE__*/React.createElement("main", {
114
113
  ref: domRef,
115
114
  className: "loaded-app-layout ".concat(appConfig.routerPrefix, "-").concat(id),
@@ -127,6 +126,7 @@ function LoaderApp(_ref) {
127
126
 
128
127
  LoaderApp.defaultProps = {
129
128
  appConfig: {},
130
- appProps: {}
129
+ appProps: {},
130
+ style: {}
131
131
  };
132
132
  export default LoaderApp;
@@ -1,6 +1,7 @@
1
1
  import { AppItemType } from '../Config/interface';
2
2
  export declare const getMicroConfig: (appConfig: AppItemType, appProps: any, container: HTMLDivElement) => {
3
- name: string;
3
+ title: string;
4
+ routerPrefix: string;
4
5
  container: HTMLDivElement;
5
6
  props: any;
6
7
  entry: {
@@ -3,14 +3,16 @@ export var getMicroConfig = function getMicroConfig() {
3
3
  var appProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4
4
  var container = arguments.length > 2 ? arguments[2] : undefined;
5
5
  var routerPrefix = appConfig.routerPrefix,
6
- resource = appConfig.resource;
6
+ resource = appConfig.resource,
7
+ name = appConfig.name;
7
8
  var microAppEntry = {
8
9
  scripts: [resource[0]],
9
10
  styles: [resource[1]],
10
11
  html: "<div id=\"".concat(routerPrefix, "\" style=\"height:100%\"></div>")
11
12
  };
12
13
  return {
13
- name: routerPrefix,
14
+ title: name,
15
+ routerPrefix: routerPrefix,
14
16
  container: container,
15
17
  props: appProps,
16
18
  entry: microAppEntry
@@ -68,7 +70,8 @@ function ruleStyle(rule, prefix) {
68
70
  // handle :root { ... }
69
71
 
70
72
  if (selector === 'html' || selector === 'body' || selector === ':root') {
71
- return cssText.replace(rootSelectorRE, prefix);
73
+ return ''; //微应用模式下清楚顶层样式
74
+ // return cssText.replace(rootSelectorRE, prefix);
72
75
  } // handle html body { ... }
73
76
  // handle html > body { ... }
74
77
 
@@ -10,14 +10,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import { __asyncValues, __awaiter } from "tslib";
14
13
  import React, { useEffect, useState } from 'react';
15
- import { createAsyncIterable } from './utils';
16
- import { nextTick, tryCatch } from '../utils';
14
+ import { createAsyncIterable, runAsyncIterable } from './utils';
17
15
 
18
16
  function LoaderScripts(_ref) {
19
- var _this = this;
20
-
21
17
  var _ref$options = _ref.options,
22
18
  options = _ref$options === void 0 ? [] : _ref$options,
23
19
  children = _ref.children,
@@ -35,90 +31,12 @@ function LoaderScripts(_ref) {
35
31
  return setInitStatus(true);
36
32
  }
37
33
 
38
- var asyncIter = createAsyncIterable(options);
39
- tryCatch(function () {
40
- return __awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
41
- var e_1, _a, asyncIter_1, asyncIter_1_1, x;
42
-
43
- return regeneratorRuntime.wrap(function _callee$(_context) {
44
- while (1) {
45
- switch (_context.prev = _context.next) {
46
- case 0:
47
- _context.prev = 0;
48
- asyncIter_1 = __asyncValues(asyncIter);
49
-
50
- case 2:
51
- _context.next = 4;
52
- return asyncIter_1.next();
53
-
54
- case 4:
55
- asyncIter_1_1 = _context.sent;
56
-
57
- if (asyncIter_1_1.done) {
58
- _context.next = 10;
59
- break;
60
- }
61
-
62
- x = asyncIter_1_1.value;
63
- console.log('加载完成!', options[x]);
64
-
65
- case 8:
66
- _context.next = 2;
67
- break;
68
-
69
- case 10:
70
- _context.next = 15;
71
- break;
72
-
73
- case 12:
74
- _context.prev = 12;
75
- _context.t0 = _context["catch"](0);
76
- e_1 = {
77
- error: _context.t0
78
- };
79
-
80
- case 15:
81
- _context.prev = 15;
82
- _context.prev = 16;
83
-
84
- if (!(asyncIter_1_1 && !asyncIter_1_1.done && (_a = asyncIter_1.return))) {
85
- _context.next = 20;
86
- break;
87
- }
88
-
89
- _context.next = 20;
90
- return _a.call(asyncIter_1);
91
-
92
- case 20:
93
- _context.prev = 20;
94
-
95
- if (!e_1) {
96
- _context.next = 23;
97
- break;
98
- }
99
-
100
- throw e_1.error;
101
-
102
- case 23:
103
- return _context.finish(20);
104
-
105
- case 24:
106
- return _context.finish(15);
107
-
108
- case 25:
109
- nextTick(function () {
110
- return onLoadEnd ? onLoadEnd().then(function () {
111
- return setInitStatus(true);
112
- }) : setInitStatus(true);
113
- });
114
-
115
- case 26:
116
- case "end":
117
- return _context.stop();
118
- }
119
- }
120
- }, _callee, null, [[0, 12, 15, 25], [16,, 20, 24]]);
121
- }));
34
+ runAsyncIterable(createAsyncIterable(options), function (option) {
35
+ return console.debug('LoaderScript -> Iterable加载完成!', option);
36
+ }, function () {
37
+ return onLoadEnd ? onLoadEnd().then(function () {
38
+ return setInitStatus(true);
39
+ }) : setInitStatus(true);
122
40
  });
123
41
  }, [options]);
124
42
  return /*#__PURE__*/React.createElement(React.Fragment, null, !initStatus ? Spin : children);
@@ -10,3 +10,5 @@ export declare function createAsyncIterable(options: IOptionsLoader[]): {
10
10
  }>;
11
11
  };
12
12
  };
13
+ export declare function tryCatch(resolveFn: () => Promise<any>, rejectFn?: (e: unknown) => void): Promise<void>;
14
+ export declare function runAsyncIterable(Iterables: any, runtime?: (conf: any) => void, callback?: () => void): void;