@pisell/core 1.0.0 → 1.0.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.
Files changed (281) hide show
  1. package/es/app/app.d.ts +122 -0
  2. package/es/app/app.js +166 -0
  3. package/es/app/const.d.ts +4 -0
  4. package/es/app/const.js +6 -0
  5. package/es/app/index.d.ts +14 -0
  6. package/es/app/index.js +54 -0
  7. package/es/applicationManager/application.d.ts +50 -0
  8. package/es/applicationManager/application.js +226 -0
  9. package/es/applicationManager/index.d.ts +13 -0
  10. package/es/applicationManager/index.js +190 -0
  11. package/es/config.d.ts +3 -3
  12. package/es/cookie/index.d.ts +13 -0
  13. package/es/cookie/index.js +47 -0
  14. package/es/css/global.less +73 -0
  15. package/es/css/index.less +31 -0
  16. package/es/css/variables.css +84 -0
  17. package/es/data/index.d.ts +29 -0
  18. package/es/data/index.js +8 -0
  19. package/es/history/config.d.ts +24 -0
  20. package/es/history/config.js +43 -0
  21. package/es/history/index.d.ts +20 -0
  22. package/es/history/index.js +41 -0
  23. package/es/history/type.d.ts +2 -0
  24. package/es/hooks/index.d.ts +12 -0
  25. package/es/hooks/index.js +13 -0
  26. package/es/hooks/useDelayedValue/index.d.ts +2 -0
  27. package/es/hooks/useDelayedValue/index.js +26 -0
  28. package/es/hooks/useDispatch/index.d.ts +2 -0
  29. package/es/hooks/useDispatch/index.js +2 -0
  30. package/es/hooks/useLowCode/index.d.ts +13 -0
  31. package/es/hooks/useLowCode/index.js +74 -0
  32. package/es/hooks/useStore/index.d.ts +6 -0
  33. package/es/hooks/useStore/index.js +11 -0
  34. package/es/index.d.ts +7 -1
  35. package/es/index.js +8 -2
  36. package/es/indexDB/index.d.ts +176 -0
  37. package/es/indexDB/index.js +536 -0
  38. package/es/locales/config.js +10 -8
  39. package/es/locales/en.d.ts +2 -1
  40. package/es/locales/en.js +5 -1
  41. package/es/locales/index.d.ts +44 -1
  42. package/es/locales/index.js +192 -8
  43. package/es/locales/original.d.ts +3 -0
  44. package/es/locales/original.js +7 -0
  45. package/es/locales/type.d.ts +15 -5
  46. package/es/locales/zh-CN.d.ts +2 -1
  47. package/es/locales/zh-CN.js +5 -1
  48. package/es/locales/zh-HK.d.ts +2 -1
  49. package/es/locales/zh-HK.js +5 -1
  50. package/es/logger/feishu.d.ts +11 -0
  51. package/es/logger/feishu.js +50 -0
  52. package/es/logger/index.d.ts +122 -0
  53. package/es/logger/index.js +531 -0
  54. package/es/menuManager/hooks.d.ts +8 -0
  55. package/es/menuManager/hooks.js +138 -0
  56. package/es/menuManager/index.d.ts +28 -0
  57. package/es/menuManager/index.js +142 -0
  58. package/es/models/global.d.ts +32 -0
  59. package/es/models/global.js +65 -0
  60. package/es/models/index.d.ts +45 -0
  61. package/es/models/index.js +66 -0
  62. package/es/models/tasks.d.ts +31 -0
  63. package/es/models/tasks.js +331 -0
  64. package/es/models/tasksUtils.d.ts +65 -0
  65. package/es/models/tasksUtils.js +179 -0
  66. package/es/models/type.d.ts +2 -0
  67. package/es/models/type.js +1 -0
  68. package/es/plugin/index.d.ts +0 -0
  69. package/es/plugin/index.js +0 -0
  70. package/es/pubsub/example.d.ts +5 -0
  71. package/es/pubsub/example.js +92 -0
  72. package/es/pubsub/index.d.ts +63 -0
  73. package/es/pubsub/index.js +144 -0
  74. package/es/request/cache.d.ts +46 -0
  75. package/es/request/cache.js +310 -0
  76. package/es/request/cancelToken.d.ts +38 -0
  77. package/es/request/cancelToken.js +59 -0
  78. package/es/request/config.d.ts +3 -0
  79. package/es/request/config.js +58 -0
  80. package/es/request/constants.d.ts +2 -0
  81. package/es/request/constants.js +6 -0
  82. package/es/request/index.d.ts +24 -0
  83. package/es/request/index.js +175 -0
  84. package/es/request/pisell2Request.d.ts +6 -0
  85. package/es/request/pisell2Request.js +62 -0
  86. package/es/request/type.d.ts +40 -0
  87. package/es/request/type.js +1 -0
  88. package/es/request/utils.d.ts +46 -0
  89. package/es/request/utils.js +145 -0
  90. package/es/routes/config.d.ts +7 -0
  91. package/es/routes/config.js +17 -0
  92. package/es/routes/index.d.ts +28 -0
  93. package/es/routes/index.js +154 -0
  94. package/es/socket/components/SocketMonitorPage.d.ts +6 -0
  95. package/es/socket/components/SocketMonitorPage.js +692 -0
  96. package/es/socket/components/index.d.ts +2 -0
  97. package/es/socket/components/index.js +2 -0
  98. package/es/socket/constants.d.ts +33 -0
  99. package/es/socket/constants.js +39 -0
  100. package/es/socket/events.d.ts +31 -0
  101. package/es/socket/events.js +19 -0
  102. package/es/socket/heartbeat.d.ts +66 -0
  103. package/es/socket/heartbeat.js +185 -0
  104. package/es/socket/index.d.ts +61 -0
  105. package/es/socket/index.js +246 -0
  106. package/es/socket/monitor.d.ts +169 -0
  107. package/es/socket/monitor.js +438 -0
  108. package/es/socket/reconnect.d.ts +61 -0
  109. package/es/socket/reconnect.js +199 -0
  110. package/es/socket/socket.d.ts +129 -0
  111. package/es/socket/socket.js +597 -0
  112. package/es/socket/types.d.ts +84 -0
  113. package/es/socket/types.js +19 -0
  114. package/es/storage/config.d.ts +3 -0
  115. package/es/{date → storage}/config.js +1 -6
  116. package/es/storage/index.d.ts +42 -0
  117. package/es/storage/index.js +62 -0
  118. package/es/storage/type.d.ts +5 -0
  119. package/es/storage/type.js +1 -0
  120. package/es/tasks/index.d.ts +77 -0
  121. package/es/tasks/index.js +719 -0
  122. package/es/tasks/type.d.ts +62 -0
  123. package/es/tasks/type.js +1 -0
  124. package/es/tasks/useTasks.d.ts +4 -0
  125. package/es/tasks/useTasks.js +25 -0
  126. package/es/type.d.ts +1 -1
  127. package/es/variables/VariablesProvider.d.ts +7 -0
  128. package/es/variables/VariablesProvider.js +14 -0
  129. package/es/variables/config.d.ts +3 -0
  130. package/es/{date/index.js → variables/config.js} +8 -14
  131. package/es/variables/index.d.ts +6 -0
  132. package/es/variables/index.js +5 -0
  133. package/es/variables/type.d.ts +2 -0
  134. package/es/variables/type.js +1 -0
  135. package/es/website/index.d.ts +6 -0
  136. package/es/website/index.js +65 -0
  137. package/lib/app/app.d.ts +122 -0
  138. package/lib/app/app.js +128 -0
  139. package/lib/app/const.d.ts +4 -0
  140. package/lib/app/const.js +33 -0
  141. package/lib/app/index.d.ts +14 -0
  142. package/lib/app/index.js +76 -0
  143. package/lib/applicationManager/application.d.ts +50 -0
  144. package/lib/applicationManager/application.js +110 -0
  145. package/lib/applicationManager/index.d.ts +13 -0
  146. package/lib/applicationManager/index.js +76 -0
  147. package/lib/config.d.ts +3 -3
  148. package/lib/cookie/index.d.ts +13 -0
  149. package/lib/cookie/index.js +64 -0
  150. package/lib/css/global.less +73 -0
  151. package/lib/css/index.less +31 -0
  152. package/lib/css/variables.css +84 -0
  153. package/lib/data/index.d.ts +29 -0
  154. package/lib/{date → data}/index.js +19 -20
  155. package/lib/history/config.d.ts +24 -0
  156. package/lib/history/config.js +41 -0
  157. package/lib/history/index.d.ts +20 -0
  158. package/lib/history/index.js +58 -0
  159. package/lib/history/type.d.ts +2 -0
  160. package/lib/history/type.js +17 -0
  161. package/lib/hooks/index.d.ts +12 -0
  162. package/lib/hooks/index.js +44 -0
  163. package/lib/hooks/useDelayedValue/index.d.ts +2 -0
  164. package/lib/hooks/useDelayedValue/index.js +36 -0
  165. package/lib/hooks/useDispatch/index.d.ts +2 -0
  166. package/lib/hooks/useDispatch/index.js +26 -0
  167. package/lib/hooks/useLowCode/index.d.ts +13 -0
  168. package/lib/hooks/useLowCode/index.js +75 -0
  169. package/lib/hooks/useStore/index.d.ts +6 -0
  170. package/lib/hooks/useStore/index.js +33 -0
  171. package/lib/index.d.ts +7 -1
  172. package/lib/index.js +23 -5
  173. package/lib/indexDB/index.d.ts +176 -0
  174. package/lib/indexDB/index.js +287 -0
  175. package/lib/locales/config.js +10 -7
  176. package/lib/locales/en.d.ts +2 -1
  177. package/lib/locales/en.js +5 -1
  178. package/lib/locales/index.d.ts +44 -1
  179. package/lib/locales/index.js +106 -4
  180. package/lib/locales/original.d.ts +3 -0
  181. package/lib/locales/original.js +31 -0
  182. package/lib/locales/type.d.ts +15 -5
  183. package/lib/locales/zh-CN.d.ts +2 -1
  184. package/lib/locales/zh-CN.js +5 -1
  185. package/lib/locales/zh-HK.d.ts +2 -1
  186. package/lib/locales/zh-HK.js +5 -1
  187. package/lib/logger/feishu.d.ts +11 -0
  188. package/lib/logger/feishu.js +52 -0
  189. package/lib/logger/index.d.ts +122 -0
  190. package/lib/logger/index.js +288 -0
  191. package/lib/menuManager/hooks.d.ts +8 -0
  192. package/lib/menuManager/hooks.js +135 -0
  193. package/lib/menuManager/index.d.ts +28 -0
  194. package/lib/menuManager/index.js +110 -0
  195. package/lib/models/global.d.ts +32 -0
  196. package/lib/models/global.js +62 -0
  197. package/lib/models/index.d.ts +45 -0
  198. package/lib/models/index.js +70 -0
  199. package/lib/models/tasks.d.ts +31 -0
  200. package/lib/models/tasks.js +199 -0
  201. package/lib/models/tasksUtils.d.ts +65 -0
  202. package/lib/models/tasksUtils.js +160 -0
  203. package/lib/models/type.d.ts +2 -0
  204. package/lib/models/type.js +17 -0
  205. package/lib/plugin/index.d.ts +0 -0
  206. package/lib/plugin/index.js +0 -0
  207. package/lib/pubsub/example.d.ts +5 -0
  208. package/lib/pubsub/example.js +61 -0
  209. package/lib/pubsub/index.d.ts +63 -0
  210. package/lib/pubsub/index.js +129 -0
  211. package/lib/request/cache.d.ts +46 -0
  212. package/lib/request/cache.js +159 -0
  213. package/lib/request/cancelToken.d.ts +38 -0
  214. package/lib/request/cancelToken.js +59 -0
  215. package/lib/request/config.d.ts +3 -0
  216. package/lib/request/config.js +74 -0
  217. package/lib/request/constants.d.ts +2 -0
  218. package/lib/request/constants.js +34 -0
  219. package/lib/request/index.d.ts +24 -0
  220. package/lib/request/index.js +143 -0
  221. package/lib/request/pisell2Request.d.ts +6 -0
  222. package/lib/request/pisell2Request.js +75 -0
  223. package/lib/request/type.d.ts +40 -0
  224. package/lib/request/type.js +17 -0
  225. package/lib/request/utils.d.ts +46 -0
  226. package/lib/request/utils.js +111 -0
  227. package/lib/routes/config.d.ts +7 -0
  228. package/lib/routes/config.js +50 -0
  229. package/lib/routes/index.d.ts +28 -0
  230. package/lib/routes/index.js +118 -0
  231. package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
  232. package/lib/socket/components/SocketMonitorPage.js +346 -0
  233. package/lib/socket/components/index.d.ts +2 -0
  234. package/lib/socket/components/index.js +39 -0
  235. package/lib/socket/constants.d.ts +33 -0
  236. package/lib/socket/constants.js +62 -0
  237. package/lib/socket/events.d.ts +31 -0
  238. package/lib/socket/events.js +44 -0
  239. package/lib/socket/heartbeat.d.ts +66 -0
  240. package/lib/socket/heartbeat.js +152 -0
  241. package/lib/socket/index.d.ts +61 -0
  242. package/lib/socket/index.js +200 -0
  243. package/lib/socket/monitor.d.ts +169 -0
  244. package/lib/socket/monitor.js +346 -0
  245. package/lib/socket/reconnect.d.ts +61 -0
  246. package/lib/socket/reconnect.js +153 -0
  247. package/lib/socket/socket.d.ts +129 -0
  248. package/lib/socket/socket.js +410 -0
  249. package/lib/socket/types.d.ts +84 -0
  250. package/lib/socket/types.js +36 -0
  251. package/lib/storage/config.d.ts +3 -0
  252. package/lib/{date → storage}/config.js +2 -7
  253. package/lib/storage/index.d.ts +42 -0
  254. package/lib/storage/index.js +66 -0
  255. package/lib/storage/type.d.ts +5 -0
  256. package/lib/storage/type.js +17 -0
  257. package/lib/tasks/index.d.ts +77 -0
  258. package/lib/tasks/index.js +438 -0
  259. package/lib/tasks/type.d.ts +62 -0
  260. package/lib/{date → tasks}/type.js +1 -1
  261. package/lib/tasks/useTasks.d.ts +4 -0
  262. package/lib/tasks/useTasks.js +37 -0
  263. package/lib/type.d.ts +1 -1
  264. package/lib/variables/VariablesProvider.d.ts +7 -0
  265. package/lib/variables/VariablesProvider.js +51 -0
  266. package/lib/variables/config.d.ts +3 -0
  267. package/lib/variables/config.js +38 -0
  268. package/lib/variables/index.d.ts +6 -0
  269. package/lib/variables/index.js +29 -0
  270. package/lib/variables/type.d.ts +2 -0
  271. package/lib/variables/type.js +17 -0
  272. package/lib/website/index.d.ts +6 -0
  273. package/lib/website/index.js +75 -0
  274. package/package.json +13 -3
  275. package/es/date/config.d.ts +0 -3
  276. package/es/date/index.d.ts +0 -7
  277. package/es/date/type.d.ts +0 -7
  278. package/lib/date/config.d.ts +0 -3
  279. package/lib/date/index.d.ts +0 -7
  280. package/lib/date/type.d.ts +0 -7
  281. /package/es/{date → history}/type.js +0 -0
@@ -0,0 +1,138 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { createContext, useContext, useState, useEffect } from "react";
12
+ import { useApp } from "../app";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ // 是否 http https 前缀
15
+ export var isHttp = function isHttp(url) {
16
+ return /^http(s)?:\/\//.test(url);
17
+ };
18
+ /**
19
+ * 处理路由参数的工具函数
20
+ * @param targetPath 目标路径(可能包含动态参数)
21
+ * @param currentPath 当前路径
22
+ * @returns 处理后的实际路径
23
+ */
24
+ function handleRouteParams(targetPath, currentPath) {
25
+ // 如果目标路径不包含动态参数,直接返回
26
+ if (!targetPath.includes(':')) {
27
+ return targetPath;
28
+ }
29
+ var currentParams = {};
30
+ var pathSegments = currentPath.split('/');
31
+ var targetSegments = targetPath.split('/');
32
+
33
+ // 提取动态参数
34
+ targetSegments.forEach(function (segment, index) {
35
+ if (segment.startsWith(':')) {
36
+ var paramName = segment.slice(1);
37
+ currentParams[paramName] = pathSegments[index] || '';
38
+ }
39
+ });
40
+
41
+ // 替换动态参数
42
+ return targetPath.replace(/:(\w+)/g, function (match, key) {
43
+ var _currentParams$key;
44
+ return ((_currentParams$key = currentParams[key]) === null || _currentParams$key === void 0 ? void 0 : _currentParams$key.toString()) || match;
45
+ });
46
+ }
47
+ var MenuContext = /*#__PURE__*/createContext(undefined);
48
+ export var MenuProvider = function MenuProvider(_ref) {
49
+ var children = _ref.children,
50
+ menus = _ref.menus;
51
+ var _useApp = useApp(),
52
+ app = _useApp.app;
53
+ var menuManager = app.menuManager;
54
+ var location = app.history.useLocation();
55
+ var _useState = useState([]),
56
+ _useState2 = _slicedToArray(_useState, 2),
57
+ selectedKeys = _useState2[0],
58
+ setSelectedKeys = _useState2[1];
59
+ var _useState3 = useState([]),
60
+ _useState4 = _slicedToArray(_useState3, 2),
61
+ openKeys = _useState4[0],
62
+ setOpenKeys = _useState4[1];
63
+ var _useState5 = useState(menus),
64
+ _useState6 = _slicedToArray(_useState5, 2),
65
+ menuItems = _useState6[0],
66
+ setMenuItems = _useState6[1];
67
+
68
+ // 初始化菜单项
69
+ useEffect(function () {
70
+ app.menuManager.set(menuItems);
71
+ }, [menuItems]);
72
+
73
+ // 根据当前路由更新选中的菜单项和打开的子菜单
74
+ useEffect(function () {
75
+ var pathname = location.pathname;
76
+ // 如果 pathname 为空,则直接返回
77
+ if (!pathname) {
78
+ return;
79
+ }
80
+ var currentMenuItem = menuManager.findMenuItemByPath(menuItems, pathname);
81
+ if (currentMenuItem) {
82
+ setSelectedKeys([currentMenuItem.key]);
83
+ var parent = menuManager.findParent(menuItems, currentMenuItem.key);
84
+ if (parent) {
85
+ var _children = menuManager.getShowChildren(parent.children || []);
86
+ if (_children !== null && _children !== void 0 && _children.length) {
87
+ setOpenKeys(function (prevKeys) {
88
+ return _toConsumableArray(new Set([].concat(_toConsumableArray(prevKeys), [parent.key])));
89
+ });
90
+ } else {
91
+ setSelectedKeys([parent.key]);
92
+ }
93
+ }
94
+ }
95
+ }, [location, menuItems]);
96
+
97
+ // 处理菜单项点击
98
+ var handleClick = function handleClick(key) {
99
+ try {
100
+ if (!key) {
101
+ return;
102
+ }
103
+ // 处理外部链接
104
+ if (isHttp(key)) {
105
+ window.open(key, '_blank');
106
+ return;
107
+ }
108
+ // 处理内部路由
109
+ var newPath = handleRouteParams(key, location.pathname);
110
+ if (newPath !== location.pathname) {
111
+ app.history.push(newPath);
112
+ }
113
+ } catch (error) {
114
+ console.error('Menu navigation error:', error);
115
+ }
116
+ };
117
+ return /*#__PURE__*/_jsx(MenuContext.Provider, {
118
+ value: {
119
+ selectedKeys: selectedKeys,
120
+ openKeys: openKeys,
121
+ setOpenKeys: setOpenKeys,
122
+ handleClick: handleClick,
123
+ menuItems: menuItems,
124
+ getShowChildren: menuManager.getShowChildren,
125
+ setMenuItems: setMenuItems
126
+ },
127
+ children: children
128
+ });
129
+ };
130
+
131
+ // 自定义hook,用于获取菜单上下文
132
+ export var useMenu = function useMenu() {
133
+ var context = useContext(MenuContext);
134
+ if (context === undefined) {
135
+ throw new Error("useMenu must be used within a MenuProvider");
136
+ }
137
+ return context;
138
+ };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import App from '../app';
3
+ export interface MenuItem {
4
+ key: string;
5
+ label: string;
6
+ path: string;
7
+ children?: MenuItem[];
8
+ icon?: string | React.ReactNode;
9
+ hide?: boolean;
10
+ }
11
+ export declare class MenuManager {
12
+ private menuItems;
13
+ private menuMaps;
14
+ private app;
15
+ useMenu: () => any;
16
+ MenuProvider: React.FC<{
17
+ children: React.ReactNode;
18
+ menus: MenuItem[];
19
+ }>;
20
+ constructor(items: MenuItem[], app: App);
21
+ set(items: MenuItem[]): void;
22
+ getMenus(): MenuItem[];
23
+ getMenuMaps(): void;
24
+ findMenuItemByPath(items: MenuItem[], path: string): MenuItem | null;
25
+ findParent(items: MenuItem[], key: string, parent?: MenuItem | null): MenuItem | null;
26
+ getShowChildren(items: MenuItem[]): MenuItem[];
27
+ findMenuItemByKey(items: MenuItem[], key: string): MenuItem | null;
28
+ }
@@ -0,0 +1,142 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ import { useMenu, MenuProvider } from "./hooks";
12
+ export var MenuManager = /*#__PURE__*/function () {
13
+ function MenuManager(items, app) {
14
+ _classCallCheck(this, MenuManager);
15
+ _defineProperty(this, "menuItems", []);
16
+ _defineProperty(this, "menuMaps", {});
17
+ _defineProperty(this, "app", void 0);
18
+ _defineProperty(this, "useMenu", useMenu);
19
+ _defineProperty(this, "MenuProvider", MenuProvider);
20
+ this.app = app;
21
+ this.set(items);
22
+ }
23
+
24
+ // 设置菜单项
25
+ _createClass(MenuManager, [{
26
+ key: "set",
27
+ value: function set(items) {
28
+ this.menuItems = items;
29
+ this.getMenuMaps();
30
+ }
31
+
32
+ // 获取菜单项
33
+ }, {
34
+ key: "getMenus",
35
+ value: function getMenus() {
36
+ return this.menuItems;
37
+ }
38
+ }, {
39
+ key: "getMenuMaps",
40
+ value: function getMenuMaps() {
41
+ var maps = {}; // 将菜单项存储在map中,方便后续查找
42
+ var fn = function fn(items) {
43
+ items.forEach(function (item) {
44
+ maps[item.path] = item;
45
+ if (item.children) {
46
+ fn(item.children);
47
+ }
48
+ });
49
+ };
50
+ fn(this.menuItems);
51
+ this.menuMaps = maps;
52
+ }
53
+
54
+ // 根据路径查找菜单项
55
+ }, {
56
+ key: "findMenuItemByPath",
57
+ value: function findMenuItemByPath(items, path) {
58
+ var menu = this.menuMaps[path];
59
+ if (menu) {
60
+ return menu;
61
+ }
62
+ var _iterator = _createForOfIteratorHelper(items),
63
+ _step;
64
+ try {
65
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
66
+ var _item$path;
67
+ var item = _step.value;
68
+ // 特殊处理 /workspaces/:id 类型的路由
69
+ if (item !== null && item !== void 0 && (_item$path = item.path) !== null && _item$path !== void 0 && _item$path.includes('/:') && path.startsWith(item.path.split('/:')[0])) {
70
+ return item;
71
+ }
72
+ if (item.children) {
73
+ var found = this.findMenuItemByPath(item.children, path);
74
+ if (found) return found;
75
+ }
76
+ }
77
+ } catch (err) {
78
+ _iterator.e(err);
79
+ } finally {
80
+ _iterator.f();
81
+ }
82
+ return null;
83
+ }
84
+
85
+ // 查找给定key的父级菜单key
86
+ }, {
87
+ key: "findParent",
88
+ value: function findParent(items, key) {
89
+ var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
90
+ var _iterator2 = _createForOfIteratorHelper(items),
91
+ _step2;
92
+ try {
93
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
94
+ var item = _step2.value;
95
+ if (item.key === key) return parent;
96
+ if (item.children) {
97
+ var found = this.findParent(item.children, key, item);
98
+ if (found) return found;
99
+ }
100
+ }
101
+ } catch (err) {
102
+ _iterator2.e(err);
103
+ } finally {
104
+ _iterator2.f();
105
+ }
106
+ return null;
107
+ }
108
+ }, {
109
+ key: "getShowChildren",
110
+ value: function getShowChildren(items) {
111
+ return items.filter(function (item) {
112
+ return !item.hide;
113
+ });
114
+ }
115
+
116
+ // 根据key查找菜单项
117
+ }, {
118
+ key: "findMenuItemByKey",
119
+ value: function findMenuItemByKey(items, key) {
120
+ var _iterator3 = _createForOfIteratorHelper(items),
121
+ _step3;
122
+ try {
123
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
124
+ var item = _step3.value;
125
+ if (item.key === key) {
126
+ return item;
127
+ }
128
+ if (item.children) {
129
+ var found = this.findMenuItemByKey(item.children, key);
130
+ if (found) return found;
131
+ }
132
+ }
133
+ } catch (err) {
134
+ _iterator3.e(err);
135
+ } finally {
136
+ _iterator3.f();
137
+ }
138
+ return null;
139
+ }
140
+ }]);
141
+ return MenuManager;
142
+ }();
@@ -0,0 +1,32 @@
1
+ import { Effect, Subscription } from 'dva';
2
+ import { Reducer } from 'redux';
3
+ export interface GlobalModal {
4
+ namespace: 'global';
5
+ state: {
6
+ isLogin: boolean;
7
+ account: any;
8
+ core: any;
9
+ isInstallAPP: boolean;
10
+ app: {
11
+ status: {
12
+ login: boolean;
13
+ storage: boolean;
14
+ network: boolean;
15
+ materials: boolean;
16
+ pisell2: boolean;
17
+ };
18
+ };
19
+ };
20
+ effects: {
21
+ init: Effect;
22
+ };
23
+ reducers: {
24
+ saveGlobalState: Reducer<any>;
25
+ setInit: Reducer<any>;
26
+ };
27
+ subscriptions: {
28
+ _init: Subscription;
29
+ };
30
+ }
31
+ declare const modal: GlobalModal;
32
+ export default modal;
@@ -0,0 +1,65 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
8
+ var modal = {
9
+ namespace: 'global',
10
+ state: {
11
+ /* 测试登录逻辑状态 */
12
+ isLogin: false,
13
+ account: null,
14
+ core: null,
15
+ isInstallAPP: false,
16
+ app: {
17
+ status: {
18
+ login: false,
19
+ storage: false,
20
+ network: false,
21
+ materials: false,
22
+ pisell2: false
23
+ }
24
+ }
25
+ },
26
+ effects: {
27
+ init: function init(_ref, _ref2) {
28
+ var params = _ref.params;
29
+ var put = _ref2.put,
30
+ call = _ref2.call;
31
+ return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
32
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
33
+ while (1) switch (_context.prev = _context.next) {
34
+ case 0:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ })();
40
+ }
41
+ },
42
+ reducers: {
43
+ saveGlobalState: function saveGlobalState(state, _ref3) {
44
+ var params = _ref3.params;
45
+ console.log('params', params);
46
+ return _objectSpread(_objectSpread({}, state), params);
47
+ },
48
+ setInit: function setInit(state, _ref4) {
49
+ var payload = _ref4.payload;
50
+ console.log(payload);
51
+ return _objectSpread(_objectSpread({}, state), {}, {
52
+ isInstallAPP: payload
53
+ });
54
+ }
55
+ },
56
+ subscriptions: {
57
+ _init: function _init(_ref5) {
58
+ var dispatch = _ref5.dispatch;
59
+ } // dispatch({
60
+ // type: 'init',
61
+ // })
62
+ }
63
+ };
64
+
65
+ export default modal;
@@ -0,0 +1,45 @@
1
+ import hooks from '../hooks';
2
+ import { Provider as StoreProvider } from "react-redux";
3
+ declare const models: (import("./global").GlobalModal | import("./tasks").TasksModal)[];
4
+ declare type ModalsType = (typeof models[number]);
5
+ export interface Store {
6
+ getDataByModel: typeof getDataByModel;
7
+ useStore: typeof hooks.useStore;
8
+ useDispatch: typeof hooks.useDispatch;
9
+ setDataByModel: typeof setDataByModel;
10
+ dispatch: any;
11
+ getState: any;
12
+ }
13
+ export declare type ModelsNames = ModalsType['namespace'];
14
+ export declare type ModelsState = {
15
+ [K in (ModalsType['namespace'])]: Extract<ModalsType, {
16
+ namespace: K;
17
+ }>['state'];
18
+ };
19
+ /**
20
+ * @title: 从store内获取数据
21
+ * @description:
22
+ * @param {string} model
23
+ * @param {string} key
24
+ * @return {*}
25
+ * @Author: zhiwei.Wang
26
+ * @Date: 2024-09-03 11:07
27
+ */
28
+ declare const getDataByModel: <T extends "tasks" | "global", D extends keyof ModelsState[T]>(model: string, key?: D | undefined) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
29
+ /**
30
+ * @title: 设置数据到store
31
+ * @description:
32
+ * @param {string} model
33
+ * @param {string} key
34
+ * @param {string} value
35
+ * @return {*}
36
+ * @Author: zhiwei.Wang
37
+ * @Date: 2024-09-08 15:17
38
+ */
39
+ declare const setDataByModel: <T extends "tasks" | "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
40
+ declare const _default: {
41
+ getStore: () => Store;
42
+ StoreProvider: typeof StoreProvider;
43
+ setConfig: (models: any[]) => void;
44
+ };
45
+ export default _default;
@@ -0,0 +1,66 @@
1
+ //@ts-ignore
2
+ import { create } from 'dva-core';
3
+ import hooks from "../hooks";
4
+ import global from "./global";
5
+ import tasks from "./tasks";
6
+ import { Provider as StoreProvider } from "react-redux";
7
+ var models = [global, tasks];
8
+ var app = create();
9
+ models.forEach(function (item) {
10
+ return app.model(item);
11
+ });
12
+
13
+ // 获取_store 实例
14
+ var getStore = function getStore() {
15
+ return app._store;
16
+ };
17
+
18
+ /**
19
+ * @title: 从store内获取数据
20
+ * @description:
21
+ * @param {string} model
22
+ * @param {string} key
23
+ * @return {*}
24
+ * @Author: zhiwei.Wang
25
+ * @Date: 2024-09-03 11:07
26
+ */
27
+ var getDataByModel = function getDataByModel(model, key) {
28
+ var _getStore$getState;
29
+ var modelData = (_getStore$getState = getStore().getState()) === null || _getStore$getState === void 0 ? void 0 : _getStore$getState[model];
30
+ if (key !== undefined) {
31
+ return modelData === null || modelData === void 0 ? void 0 : modelData[key];
32
+ }
33
+ return modelData;
34
+ };
35
+
36
+ /**
37
+ * @title: 设置数据到store
38
+ * @description:
39
+ * @param {string} model
40
+ * @param {string} key
41
+ * @param {string} value
42
+ * @return {*}
43
+ * @Author: zhiwei.Wang
44
+ * @Date: 2024-09-08 15:17
45
+ */
46
+ var setDataByModel = function setDataByModel(model, key, value) {
47
+ getStore().dispatch({
48
+ type: "".concat(model, "/").concat(String(key)),
49
+ payload: value
50
+ });
51
+ };
52
+ var setConfig = function setConfig(models) {
53
+ models.forEach(function (item) {
54
+ return app.model(item);
55
+ });
56
+ app.start();
57
+ getStore().getDataByModel = getDataByModel;
58
+ getStore().setDataByModel = setDataByModel;
59
+ getStore().useStore = hooks.useStore;
60
+ getStore().useDispatch = hooks.useDispatch;
61
+ };
62
+ export default {
63
+ getStore: getStore,
64
+ StoreProvider: StoreProvider,
65
+ setConfig: setConfig
66
+ };
@@ -0,0 +1,31 @@
1
+ import { Effect, Subscription } from 'dva';
2
+ import { Reducer } from 'redux';
3
+ import { Task } from './tasksUtils';
4
+ export interface TasksModal {
5
+ namespace: 'tasks';
6
+ state: {
7
+ global: {
8
+ [key: string]: {
9
+ status: "uncompleted" | "completed";
10
+ tasks: Task[];
11
+ };
12
+ };
13
+ };
14
+ effects: {
15
+ init: Effect;
16
+ executeQueue: Effect;
17
+ retryTask: Effect;
18
+ addTasks: Effect;
19
+ };
20
+ reducers: {
21
+ setState: Reducer<any>;
22
+ updateTask: Reducer<any>;
23
+ updateQueueStatus: Reducer<any>;
24
+ setTasks: Reducer<any>;
25
+ };
26
+ subscriptions: {
27
+ _init: Subscription;
28
+ };
29
+ }
30
+ declare const TaskQueueModel: TasksModal;
31
+ export default TaskQueueModel;