@chaoswise/ui 3.0.12 → 3.0.13

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 (40) hide show
  1. package/lib/AppHolder/index.js +19 -0
  2. package/lib/Badge/index.style.js +42 -10
  3. package/lib/BasicLayout/Sider.js +6 -2
  4. package/lib/BasicLayout/style/sider.js +53 -49
  5. package/lib/CWMessage/MessageContent/TabList/index.js +2 -2
  6. package/lib/CWMessage/MessageContent/index.js +6 -6
  7. package/lib/CWMessage/index.js +80 -90
  8. package/lib/CWMessage/index.style.js +1 -3
  9. package/lib/CWRangePicker/DropdownMenu/index.js +39 -35
  10. package/lib/CWRangePicker/DropdownMenu/index.style.js +129 -130
  11. package/lib/CWRangePicker/Refresh/index.js +6 -2
  12. package/lib/CWRangePicker/Refresh/index.style.js +16 -19
  13. package/lib/CWRangePicker/TimeSpan/index.js +7 -2
  14. package/lib/CWRangePicker/TimeSpan/index.style.js +9 -12
  15. package/lib/CWRangePicker/index.js +6 -2
  16. package/lib/CWRangePicker/index.style.js +47 -52
  17. package/lib/CWTable/CWTable.js +1 -1
  18. package/lib/CWTree/index.js +6 -2
  19. package/lib/CWTree/index.style.js +97 -99
  20. package/lib/ChangeIcon/index.js +1 -1
  21. package/lib/ConfigProvider/ConfigProvider.js +15 -3
  22. package/lib/Exception/index.js +1 -1
  23. package/lib/FilterDropDown/index.js +1 -1
  24. package/lib/Header/TopNavigationMenu/index.js +1 -1
  25. package/lib/Header/UserSetting/index.js +1 -1
  26. package/lib/Header/index.js +1 -1
  27. package/lib/IconSelect/index.js +1 -1
  28. package/lib/LayoutWrapper/Footer.js +5 -1
  29. package/lib/LayoutWrapper/Header.js +5 -1
  30. package/lib/LayoutWrapper/index.js +5 -2
  31. package/lib/LeftNavigation/index.js +1 -1
  32. package/lib/QuickTransfer/index.js +5 -1
  33. package/lib/SearchBar/index.js +1 -1
  34. package/lib/SimplePagination/index.js +1 -1
  35. package/lib/Tag/index.style.js +41 -9
  36. package/lib/Tooltip/index.js +2 -2
  37. package/lib/TooltipText/index.js +1 -1
  38. package/lib/UniversalLayout/index.js +5 -1
  39. package/lib/antd-style/functions/index.js +6 -5
  40. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ import _App from "@chaoswise/ui/lib/App";
2
+ var message;
3
+ var notification;
4
+ var modal;
5
+ var AppHolder = function AppHolder() {
6
+ var staticFunction = _App.useApp();
7
+ message = staticFunction.message;
8
+ modal = staticFunction.modal;
9
+ notification = staticFunction.notification;
10
+ return null;
11
+ };
12
+ export default AppHolder;
13
+ // 这里的问题是 AppHolder 组件在首次定义的时候,message、modal 和 notification 还没有被赋值。当你在其他地方尝试访问 AppHolder.message 时,这些属性是 undefined 的。
14
+ // AppHolder.message = message;
15
+ // AppHolder.modal = modal;
16
+ // AppHolder.notification = notification;
17
+
18
+ // 具名导出的方式可以保证AppHolder组件在渲染时正确赋值这些变量,并且在其他模块中可以正确导入和使用这些变量
19
+ export { message, notification, modal };
@@ -1,15 +1,43 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3
2
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
5
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
7
5
  import { genStyleHooks } from "../Antd5/theme/internal";
8
- import { keyframes } from "../antd-style";
9
- var k_loadingK = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n left: 0;\n transform: scale(1.1)\n }\n\n 50% {\n left: 100%;\n transform: scale(1)\n }\n\n 100% {\n left: 0;\n transform: scale(1.1)\n }\n"])));
10
- var k_loadingM = keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n z-index: 0\n }\n\n 50% {\n z-index: 1\n }\n\n 100% {\n z-index: 0\n }\n"])));
11
- var k_loadingL = keyframes(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n 0% {\n left: 100%;\n transform: scale(1.1)\n }\n\n 50% {\n left: 0;\n transform: scale(1)\n }\n\n 100% {\n left: 100%;\n transform: scale(1.1)\n }\n"])));
12
- var k_loadingN = keyframes(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n 0% {\n z-index: 1\n }\n\n 50% {\n z-index: 0\n }\n\n 100% {\n z-index: 1\n }\n"])));
6
+ import { Keyframes } from "@ant-design/cssinjs";
7
+ var k_loadingK = new Keyframes("k_loadingK", {
8
+ "0%": {
9
+ left: 0,
10
+ transform: "scale(1.1)",
11
+ zIndex: 0
12
+ },
13
+ "50%": {
14
+ left: "100%",
15
+ transform: "scale(1)",
16
+ zIndex: 1
17
+ },
18
+ "100%": {
19
+ left: 0,
20
+ transform: 'scale(1.1)',
21
+ zIndex: 0
22
+ }
23
+ });
24
+ var k_loadingL = new Keyframes("k_loadingL", {
25
+ "0%": {
26
+ left: "100%",
27
+ transform: 'scale(1.1)',
28
+ zIndex: 1
29
+ },
30
+ "50%": {
31
+ left: 0,
32
+ transform: "scale(1)",
33
+ zIndex: 1
34
+ },
35
+ "100%": {
36
+ left: "100%",
37
+ transform: 'scale(1.1)',
38
+ zIndex: 0
39
+ }
40
+ });
13
41
  var genCustomBadgeStyle = function genCustomBadgeStyle(token) {
14
42
  var prefixCls = token.antCls;
15
43
  var badgePrefix = "".concat(prefixCls, "-badge");
@@ -35,11 +63,15 @@ var genCustomBadgeStyle = function genCustomBadgeStyle(token) {
35
63
  },
36
64
  "&::before": {
37
65
  background: token.colorPrimary,
38
- animation: "".concat(k_loadingK, " 1s ease-in-out infinite, ").concat(k_loadingM, " 0.33s ease-in-out infinite")
66
+ animationName: k_loadingK,
67
+ animationDuration: '1s',
68
+ animationIterationCount: 'infinite'
39
69
  },
40
70
  "&:after": {
41
71
  background: token.colorSuccess,
42
- animation: "".concat(k_loadingL, " 1s ease-in-out infinite, ").concat(k_loadingN, " 0.33s ease-in-out infinite")
72
+ animationName: k_loadingL,
73
+ animationDuration: '1s',
74
+ animationIterationCount: 'infinite'
43
75
  }
44
76
  }), "".concat(badgePrefix, "-processing-text"), {
45
77
  display: "inline-block",
@@ -62,6 +94,6 @@ var genCustomBadgeStyle = function genCustomBadgeStyle(token) {
62
94
  // ============================== Export ==============================
63
95
  export default genStyleHooks("CWBadge", function (token) {
64
96
  return [
65
- //
97
+ //
66
98
  genCustomBadgeStyle(token)];
67
99
  });
@@ -23,6 +23,7 @@ import { Resizable } from "re-resizable";
23
23
  import { MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons";
24
24
  import { useTheme } from '../antd-style';
25
25
  import classnames from 'classnames';
26
+ import useConfigContext from "../useConfigContext";
26
27
  import useStyle from "./style/sider";
27
28
  var AntSider = _Layout.Sider;
28
29
  function Sider(_ref) {
@@ -37,7 +38,10 @@ function Sider(_ref) {
37
38
  _setSiderDragWidth = _ref._setSiderDragWidth,
38
39
  menuOptions = _ref.menuOptions,
39
40
  onCollapse = _ref.onCollapse;
40
- var _useStyle = useStyle("cw-side"),
41
+ var _useConfigContext = useConfigContext(),
42
+ getPrefixCls = _useConfigContext.getPrefixCls;
43
+ var prefixCls = getPrefixCls("basic-layout");
44
+ var _useStyle = useStyle("".concat(prefixCls, "-cw-side")),
41
45
  _useStyle2 = _slicedToArray(_useStyle, 3),
42
46
  wrapCSSVar = _useStyle2[0],
43
47
  hashId = _useStyle2[1],
@@ -116,7 +120,7 @@ function Sider(_ref) {
116
120
  width: selfCollapsed ? siderCollapsedWidth : _siderDragWidth
117
121
  }
118
122
  }), /*#__PURE__*/React.createElement(AntSider, {
119
- className: classnames(hashId, cssVarCls, "cw-side"),
123
+ className: classnames(hashId, cssVarCls, "".concat(prefixCls, "-cw-side")),
120
124
  width: canDrag ? "100%" : _siderDragWidth,
121
125
  collapsed: selfCollapsed,
122
126
  collapsedWidth: siderCollapsedWidth,
@@ -1,3 +1,7 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
5
  import { genStyleHooks } from "../../Antd5/theme/internal";
2
6
  var prepareComponentToken = function prepareComponentToken(token) {
3
7
  return {
@@ -8,62 +12,62 @@ var prepareComponentToken = function prepareComponentToken(token) {
8
12
  };
9
13
  };
10
14
  var genCustomSiderStyle = function genCustomSiderStyle(token) {
11
- return {
12
- ".cw-side": {
13
- fontSize: "14px",
15
+ var prefixCls = token.antCls;
16
+ var basicLayoutPrefixCls = "".concat(prefixCls, "-basic-layout");
17
+ return _defineProperty({}, "".concat(basicLayoutPrefixCls, "-cw-side"), {
18
+ fontSize: "14px",
19
+ height: "100%",
20
+ boxShadow: "none",
21
+ overflow: "auto",
22
+ overflowX: "hidden",
23
+ ".cw-side-menu-box": {
14
24
  height: "100%",
15
- boxShadow: "none",
16
- overflow: "auto",
17
- overflowX: "hidden",
18
- ".cw-side-menu-box": {
19
- height: "100%",
25
+ width: "100%",
26
+ ".cw-side-menu": {
27
+ height: "calc(100% - 40px)",
28
+ width: "100%",
29
+ overflow: "auto"
30
+ },
31
+ ".cw-sider-bottom-box": {
32
+ position: "relative",
33
+ borderTop: "1px solid transparent",
34
+ height: "40px",
20
35
  width: "100%",
21
- ".cw-side-menu": {
22
- height: "calc(100% - 40px)",
23
- width: "100%",
24
- overflow: "auto"
36
+ backgroundColor: "#fff",
37
+ display: "flex",
38
+ justifyContent: "space-between",
39
+ alignItems: "center",
40
+ padding: "0 12px",
41
+ ".cw-sider-setting": {
42
+ color: token.siderBtnColor,
43
+ "&:hover": {
44
+ color: token.siderBtnHoverColor
45
+ }
25
46
  },
26
- ".cw-sider-bottom-box": {
27
- position: "relative",
28
- borderTop: "1px solid transparent",
29
- height: "40px",
30
- width: "100%",
31
- backgroundColor: "#fff",
32
- display: "flex",
33
- justifyContent: "space-between",
34
- alignItems: "center",
35
- padding: "0 12px",
36
- ".cw-sider-setting": {
37
- color: token.siderBtnColor,
38
- "&:hover": {
39
- color: token.siderBtnHoverColor
40
- }
41
- },
42
- ".cw-sider-collapsed-btn": {
43
- background: token.collapsedBtnBg,
44
- display: "inline-block",
45
- width: "24px",
46
- height: "24px",
47
- cursor: "pointer",
48
- lineHeight: "24px",
49
- fontSize: "16px",
50
- textAlign: "center",
51
- color: token.siderBtnColor,
52
- "&:hover": {
53
- color: token.siderBtnHoverColor
54
- }
55
- },
56
- ".cw-sider-version": {
57
- fontSize: "12px",
58
- color: token.versionColor,
59
- "&:hover": {
60
- color: token.siderBtnHoverColor
61
- }
47
+ ".cw-sider-collapsed-btn": {
48
+ background: token.collapsedBtnBg,
49
+ display: "inline-block",
50
+ width: "24px",
51
+ height: "24px",
52
+ cursor: "pointer",
53
+ lineHeight: "24px",
54
+ fontSize: "16px",
55
+ textAlign: "center",
56
+ color: token.siderBtnColor,
57
+ "&:hover": {
58
+ color: token.siderBtnHoverColor
59
+ }
60
+ },
61
+ ".cw-sider-version": {
62
+ fontSize: "12px",
63
+ color: token.versionColor,
64
+ "&:hover": {
65
+ color: token.siderBtnHoverColor
62
66
  }
63
67
  }
64
68
  }
65
69
  }
66
- };
70
+ });
67
71
  };
68
72
  // ============================== Export ==============================
69
73
  export default genStyleHooks(["BasicLayout", "Sider"], function (token) {
@@ -64,9 +64,9 @@ var TabList = function TabList(props) {
64
64
  return _regeneratorRuntime().wrap(function _callee$(_context) {
65
65
  while (1) switch (_context.prev = _context.next) {
66
66
  case 0:
67
- resRequestApi = _readInnerMessageApi ? _readInnerMessageApi(params) : readInnerMessageApi(params, gatewayPrefix);
67
+ resRequestApi = _readInnerMessageApi || readInnerMessageApi;
68
68
  _context.next = 3;
69
- return resRequestApi;
69
+ return resRequestApi(params, gatewayPrefix);
70
70
  case 3:
71
71
  res = _context.sent;
72
72
  if (res.status == 'success') {
@@ -82,9 +82,9 @@ var MessageContent = function MessageContent(props) {
82
82
  return _regeneratorRuntime().wrap(function _callee$(_context) {
83
83
  while (1) switch (_context.prev = _context.next) {
84
84
  case 0:
85
- resRequestApi = _getMessageTypeApi ? _getMessageTypeApi() : getMessageTypeApi(gatewayPrefix);
85
+ resRequestApi = _getMessageTypeApi || getMessageTypeApi;
86
86
  _context.next = 3;
87
- return resRequestApi;
87
+ return resRequestApi(gatewayPrefix);
88
88
  case 3:
89
89
  res = _context.sent;
90
90
  if (res && res.status == "success") {
@@ -115,9 +115,9 @@ var MessageContent = function MessageContent(props) {
115
115
  case 0:
116
116
  setLoading(true);
117
117
  conditionsRef.current = _objectSpread(_objectSpread({}, conditionsRef.current), params);
118
- resRequestApi = _getMessageListApi ? _getMessageListApi(conditionsRef.current) : getMessageListApi(conditionsRef.current, gatewayPrefix);
118
+ resRequestApi = _getMessageListApi || getMessageListApi;
119
119
  _context2.next = 5;
120
- return resRequestApi;
120
+ return resRequestApi(conditionsRef.current, gatewayPrefix);
121
121
  case 5:
122
122
  res = _context2.sent;
123
123
  if (res && res.status == "success") {
@@ -143,9 +143,9 @@ var MessageContent = function MessageContent(props) {
143
143
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
144
144
  while (1) switch (_context3.prev = _context3.next) {
145
145
  case 0:
146
- resRequestApi = _getMessageUnreadCountApi ? _getMessageUnreadCountApi() : getMessageUnreadCountApi(gatewayPrefix);
146
+ resRequestApi = _getMessageUnreadCountApi || getMessageUnreadCountApi;
147
147
  _context3.next = 3;
148
- return resRequestApi;
148
+ return resRequestApi(gatewayPrefix);
149
149
  case 3:
150
150
  res = _context3.sent;
151
151
  if (res && res.status == "success") {
@@ -99,6 +99,8 @@ function Message(props) {
99
99
  setTotal = _useState8[1];
100
100
  // 保存消息配置
101
101
  var messageOptionRef = useRef({});
102
+ // 获取socket信息
103
+ var socketConnectInfo = useRef();
102
104
  // 分页配置初始化
103
105
  var _useState9 = useState({
104
106
  current: 1,
@@ -124,6 +126,11 @@ function Message(props) {
124
126
  useEffect(function () {
125
127
  getMessageQuerySettings();
126
128
  connectSocket();
129
+ return function () {
130
+ if (socketConnectInfo.current) {
131
+ socketConnectInfo.current.disconnect && socketConnectInfo.current.disconnect();
132
+ }
133
+ };
127
134
  }, []);
128
135
  useEffect(function () {
129
136
  setPageInfo(function (pre) {
@@ -166,9 +173,9 @@ function Message(props) {
166
173
  userMessageId: id,
167
174
  clientType: "BROWSER"
168
175
  };
169
- resRequestApi = _getMessageDetailApi ? _getMessageDetailApi(params) : getMessageDetailApi(params, gatewayPrefix);
176
+ resRequestApi = _getMessageDetailApi || getMessageDetailApi;
170
177
  _context.next = 4;
171
- return resRequestApi;
178
+ return resRequestApi(params, gatewayPrefix);
172
179
  case 4:
173
180
  res = _context.sent;
174
181
  if (res && res.status == "success") {
@@ -203,24 +210,13 @@ function Message(props) {
203
210
  }();
204
211
  var readInnerMessage = /*#__PURE__*/function () {
205
212
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
206
- var resRequestApi, res;
213
+ var resRequestApi;
207
214
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
208
215
  while (1) switch (_context2.prev = _context2.next) {
209
216
  case 0:
210
- resRequestApi = _readInnerMessageApi ? _readInnerMessageApi(params) : readInnerMessageApi(params, gatewayPrefix);
211
- _context2.next = 3;
212
- return resRequestApi;
213
- case 3:
214
- res = _context2.sent;
215
- if (res.status == "success") {
216
- // if (pageInfo.current > 1 && dataSource.length === 1) {
217
- // let _params = { current: pageInfo.current - 1 };
218
- // setPageInfo((pre) => ({ ...pre, current: pre.current - 1 }));
219
- // conditionsRef.current = { ...conditionsRef.current, ..._params };
220
- // }
221
- // 已读消息
222
- }
223
- case 5:
217
+ resRequestApi = _readInnerMessageApi || readInnerMessageApi;
218
+ resRequestApi(params, gatewayPrefix);
219
+ case 2:
224
220
  case "end":
225
221
  return _context2.stop();
226
222
  }
@@ -230,17 +226,53 @@ function Message(props) {
230
226
  return _ref3.apply(this, arguments);
231
227
  };
232
228
  }();
229
+ var getSocketPostMessage = function getSocketPostMessage(data) {
230
+ var _JSON$parse = JSON.parse(data),
231
+ count = _JSON$parse.count,
232
+ message = _JSON$parse.message;
233
+ var _ref4 = count || {},
234
+ _ref4$total = _ref4.total,
235
+ total = _ref4$total === void 0 ? 0 : _ref4$total;
236
+ setMessageTotal(total);
237
+ onSocketChange(JSON.parse(data));
238
+ if (message) {
239
+ var noticeMessage = message.noticeMessage,
240
+ action = message.action;
241
+ var _ref5 = noticeMessage || {},
242
+ userMessageId = _ref5.id,
243
+ type = _ref5.type;
244
+ if (!userMessageId) return;
245
+ if (action && action.mode === "recall") {
246
+ // 销毁强提醒
247
+ api.destroy(userMessageId);
248
+ // 销毁后如果弹窗开启关闭弹窗
249
+ setVisible(false);
250
+ } else {
251
+ // 生成强提醒
252
+ var _ref6 = messageOptionRef.current[type] || {},
253
+ enable = _ref6.enable,
254
+ _mode = _ref6.mode,
255
+ _ref6$time = _ref6.time,
256
+ time = _ref6$time === void 0 ? 5 : _ref6$time;
257
+ setMode(_mode);
258
+ if (enable) {
259
+ openNotification(time, userMessageId);
260
+ }
261
+ }
262
+ }
263
+ };
233
264
  var connectSocket = /*#__PURE__*/function () {
234
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
265
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
235
266
  var resRequestApi, res, finalOrigin, socket;
236
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
237
- while (1) switch (_context5.prev = _context5.next) {
267
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
268
+ while (1) switch (_context4.prev = _context4.next) {
238
269
  case 0:
239
- resRequestApi = _getSessionId ? _getSessionId() : getSessionId(gatewayPrefix);
240
- _context5.next = 3;
241
- return resRequestApi;
270
+ // 获取sessionId
271
+ resRequestApi = _getSessionId || getSessionId;
272
+ _context4.next = 3;
273
+ return resRequestApi(gatewayPrefix);
242
274
  case 3:
243
- res = _context5.sent;
275
+ res = _context4.sent;
244
276
  if (res && res.status == "success") {
245
277
  finalOrigin = socketOrigin ? socketOrigin : "ws://".concat(window.location.host);
246
278
  socket = io(finalOrigin, {
@@ -250,62 +282,20 @@ function Message(props) {
250
282
  sessionId: res.data,
251
283
  clientType: "BROWSER"
252
284
  }
253
- });
254
- socket.on("push", /*#__PURE__*/function () {
255
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
256
- var _JSON$parse, count, message, _ref6, _ref6$total, total, noticeMessage, action, _ref7, userMessageId, type, _ref8, enable, _mode, _ref8$time, time;
257
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
258
- while (1) switch (_context3.prev = _context3.next) {
259
- case 0:
260
- _JSON$parse = JSON.parse(data), count = _JSON$parse.count, message = _JSON$parse.message;
261
- _ref6 = count || {}, _ref6$total = _ref6.total, total = _ref6$total === void 0 ? 0 : _ref6$total;
262
- setMessageTotal(total);
263
- onSocketChange(JSON.parse(data));
264
- if (!message) {
265
- _context3.next = 10;
266
- break;
267
- }
268
- noticeMessage = message.noticeMessage, action = message.action;
269
- _ref7 = noticeMessage || {}, userMessageId = _ref7.id, type = _ref7.type;
270
- if (userMessageId) {
271
- _context3.next = 9;
272
- break;
273
- }
274
- return _context3.abrupt("return");
275
- case 9:
276
- if (action && action.mode === "recall") {
277
- // 销毁强提醒
278
- api.destroy(userMessageId);
279
- // 销毁后如果弹窗开启关闭弹窗
280
- setVisible(false);
281
- } else {
282
- // 生成强提醒
283
- _ref8 = messageOptionRef.current[type] || {}, enable = _ref8.enable, _mode = _ref8.mode, _ref8$time = _ref8.time, time = _ref8$time === void 0 ? 5 : _ref8$time;
284
- setMode(_mode);
285
- if (enable) {
286
- openNotification(time, userMessageId);
287
- }
288
- }
289
- case 10:
290
- case "end":
291
- return _context3.stop();
292
- }
293
- }, _callee3);
294
- }));
295
- return function (_x4) {
296
- return _ref5.apply(this, arguments);
297
- };
298
- }());
285
+ }); // 记录socket连接信息,用于关闭socket连接
286
+ socketConnectInfo.current = socket;
287
+ // 监听从服务器传来的消息
288
+ socket.on("push", getSocketPostMessage);
299
289
  // socket重连
300
- socket.on("reconnect_attempt", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
290
+ socket.on("reconnect_attempt", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
301
291
  var res;
302
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
303
- while (1) switch (_context4.prev = _context4.next) {
292
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
293
+ while (1) switch (_context3.prev = _context3.next) {
304
294
  case 0:
305
- _context4.next = 2;
295
+ _context3.next = 2;
306
296
  return resRequestApi;
307
297
  case 2:
308
- res = _context4.sent;
298
+ res = _context3.sent;
309
299
  if (res && res.status == "success") {
310
300
  socket.io.opts.query = {
311
301
  sessionId: res.data,
@@ -314,44 +304,44 @@ function Message(props) {
314
304
  }
315
305
  case 4:
316
306
  case "end":
317
- return _context4.stop();
307
+ return _context3.stop();
318
308
  }
319
- }, _callee4);
309
+ }, _callee3);
320
310
  })));
321
311
  }
322
312
  case 5:
323
313
  case "end":
324
- return _context5.stop();
314
+ return _context4.stop();
325
315
  }
326
- }, _callee5);
316
+ }, _callee4);
327
317
  }));
328
318
  return function connectSocket() {
329
- return _ref4.apply(this, arguments);
319
+ return _ref7.apply(this, arguments);
330
320
  };
331
321
  }();
332
322
  var getMessageQuerySettings = /*#__PURE__*/function () {
333
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
323
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
334
324
  var resRequestApi, res, data;
335
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
336
- while (1) switch (_context6.prev = _context6.next) {
325
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
326
+ while (1) switch (_context5.prev = _context5.next) {
337
327
  case 0:
338
- resRequestApi = _getMessageQuerySettingsApi ? _getMessageQuerySettingsApi() : getMessageQuerySettingsApi(gatewayPrefix);
339
- _context6.next = 3;
340
- return resRequestApi;
328
+ resRequestApi = _getMessageQuerySettingsApi || getMessageQuerySettingsApi;
329
+ _context5.next = 3;
330
+ return resRequestApi(gatewayPrefix);
341
331
  case 3:
342
- res = _context6.sent;
332
+ res = _context5.sent;
343
333
  if (res && res.status === "success") {
344
334
  data = res.data;
345
335
  messageOptionRef.current = data || {};
346
336
  }
347
337
  case 5:
348
338
  case "end":
349
- return _context6.stop();
339
+ return _context5.stop();
350
340
  }
351
- }, _callee6);
341
+ }, _callee5);
352
342
  }));
353
343
  return function getMessageQuerySettings() {
354
- return _ref10.apply(this, arguments);
344
+ return _ref9.apply(this, arguments);
355
345
  };
356
346
  }();
357
347
  return wrapCSSVar( /*#__PURE__*/React.createElement("div", {
@@ -126,9 +126,7 @@ var genCustomCWMessageStyle = function genCustomCWMessageStyle(token) {
126
126
  }
127
127
  })), "".concat(messagePrefixCls, "-content-tabs-list"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({
128
128
  paddingTop: "16px"
129
- }, "&".concat(messagePrefixCls, "-content-tabs-list-invalid"), _defineProperty({
130
- color: "red"
131
- }, "".concat(messagePrefixCls, "-content-tabs-list-title,").concat(messagePrefixCls, "-content-tabs-list-desc,").concat(messagePrefixCls, "-content-tabs-list-date"), {
129
+ }, "&".concat(messagePrefixCls, "-content-tabs-list-invalid"), _defineProperty({}, "".concat(messagePrefixCls, "-content-tabs-list-title,").concat(messagePrefixCls, "-content-tabs-list-desc,").concat(messagePrefixCls, "-content-tabs-list-date"), {
132
130
  color: token.colorTextDisabled,
133
131
  "&:hover": {
134
132
  color: token.colorTextDisabled