@chaoswise/ui 2.7.11 → 2.8.0

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 (219) hide show
  1. package/lib/AlgorithmChart/common/chart.option.js +14 -11
  2. package/lib/AlgorithmChart/index.js +29 -26
  3. package/lib/Antd4/comment/index.js +1 -1
  4. package/lib/Antd4Form/FormItem.js +1 -1
  5. package/lib/BasicLayout/Nav.js +3 -5
  6. package/lib/BasicLayout/index.js +9 -10
  7. package/lib/CWCascader/rc-cascader/OptionList/Column.js +17 -18
  8. package/lib/CWMessage/MessageContent/TabList/index.js +19 -17
  9. package/lib/CWMessage/MessageContent/index.js +86 -73
  10. package/lib/CWMessage/index.js +62 -50
  11. package/lib/CWMessage/service/index.js +14 -14
  12. package/lib/CWMessage/utils/index.js +18 -11
  13. package/lib/CWRangePicker/DropdownMenu/MoreHistoryList/index.js +16 -10
  14. package/lib/CWRangePicker/DropdownMenu/MoreTimeList/index.js +4 -6
  15. package/lib/CWRangePicker/DropdownMenu/index.js +20 -13
  16. package/lib/CWRangePicker/Refresh/index.js +4 -7
  17. package/lib/CWRangePicker/TimeSpan/index.js +6 -9
  18. package/lib/CWRangePicker/index.js +39 -32
  19. package/lib/CWRangePicker/utils/index.js +45 -114
  20. package/lib/CWSelect/index.js +7 -10
  21. package/lib/CWTable/CWTable.js +23 -23
  22. package/lib/CWTable/EditLine.js +5 -8
  23. package/lib/CWTable/Filter.js +5 -8
  24. package/lib/CWTable/index.js +3 -0
  25. package/lib/CWTree/index.js +4 -7
  26. package/lib/CWUpload/upload/Dragger.js +4 -7
  27. package/lib/CWUpload/upload/UploadList.js +12 -15
  28. package/lib/CardSelect/index.js +16 -14
  29. package/lib/CitySelect/index.js +3 -1
  30. package/lib/ColorPicker/index.js +4 -7
  31. package/lib/ConfigProvider/ConfigProvider.js +143 -48
  32. package/lib/ConfigProvider/Switch.js +10 -2
  33. package/lib/ConfigProvider/context.js +8 -0
  34. package/lib/ConfigProvider/useLocale.js +1 -1
  35. package/lib/DatePicker/useLocale.js +17 -10
  36. package/lib/DateRangePicker/RangeDateTimePicker.js +3 -3
  37. package/lib/DateRangePicker/components/ExtraQuickFooter.js +5 -8
  38. package/lib/DateRangePicker/index.js +6 -5
  39. package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.js +4 -6
  40. package/lib/DropdownDatePicker/DropdownMenu/index.js +4 -7
  41. package/lib/DropdownDatePicker/index.js +12 -13
  42. package/lib/DropdownDatePicker/utils/index.js +5 -93
  43. package/lib/EchartsBar/index.js +1 -1
  44. package/lib/Empty/index.js +3 -6
  45. package/lib/ErrorBoundary/ErrorPage.js +8 -9
  46. package/lib/Exception/index.js +9 -12
  47. package/lib/FilterDropDown/index.js +3 -6
  48. package/lib/Flow/tools/index.js +4 -1
  49. package/lib/Header/Document/index.js +3 -8
  50. package/lib/Header/LocaleSwitcher.js +2 -0
  51. package/lib/Header/UserSetting/index.js +27 -45
  52. package/lib/IconSelect/components/CustomImg/index.js +8 -11
  53. package/lib/IconSelect/components/SearchIcon/index.js +9 -9
  54. package/lib/IconSelect/index.js +4 -7
  55. package/lib/ImagePreview/index.js +3 -1
  56. package/lib/Joyride/List.js +9 -8
  57. package/lib/Joyride/index.js +22 -25
  58. package/lib/ModuleFederation/react-dynamic-remote-component/RemoteComponent.js +38 -39
  59. package/lib/ModuleFederation/react-dynamic-remote-component/load-module.js +22 -23
  60. package/lib/Pagination/index.js +14 -14
  61. package/lib/PolymerizationSearch/DropdownMenu.js +4 -2
  62. package/lib/PolymerizationSearch/index.js +7 -7
  63. package/lib/Progress/index.js +3 -6
  64. package/lib/QuickTransfer/DragList.js +3 -6
  65. package/lib/QuickTransfer/index.js +19 -22
  66. package/lib/RangePicker/components/ExtraTimeFooter.js +4 -7
  67. package/lib/SearchBar/OutSearch.js +9 -2
  68. package/lib/SearchBar/index.js +13 -16
  69. package/lib/SimpleCard/index.js +3 -1
  70. package/lib/SingleSpa/index.js +30 -26
  71. package/lib/ThemeProvider/Switcher.js +3 -1
  72. package/lib/TimeRangeSlider/Refresh/index.js +4 -7
  73. package/lib/TimeRangeSlider/TimeRangeSliderCmp/hooks/useMouse.js +3 -3
  74. package/lib/TimeRangeSlider/TimeSpan/index.js +6 -9
  75. package/lib/TimeRangeSlider/index.js +28 -24
  76. package/lib/TimeRangeSlider/utils/index.js +20 -100
  77. package/lib/TimeZoneSelect/index.js +21 -22
  78. package/lib/TreeSelect111/index.js +3 -6
  79. package/lib/Upload-back/index.js +27 -25
  80. package/lib/VerticalLayout/index.js +3 -1
  81. package/lib/WangEditor/extraLanguage.js +19 -0
  82. package/lib/WangEditor/index.js +19 -13
  83. package/lib/WangEditor/messages.js +49 -0
  84. package/lib/WangEditor/wangEditor.js +47 -20
  85. package/lib/index.js +1 -0
  86. package/lib/locales/en_US.json +1 -0
  87. package/lib/locales/index.js +2 -0
  88. package/lib/locales/ja_JP.json +1 -0
  89. package/lib/locales/load.js +48 -0
  90. package/lib/locales/messages/antd.js +404 -0
  91. package/lib/locales/messages/editor.js +42 -0
  92. package/lib/locales/messages/timeRanges.js +36 -0
  93. package/lib/locales/messages/timeTypes.js +11 -0
  94. package/lib/locales/runtime.js +127 -0
  95. package/lib/locales/zh_CN.json +1 -0
  96. package/lib/locales/zh_HK.json +1 -0
  97. package/lib/locales/zh_TW.json +1 -0
  98. package/lib/useIntl/index.js +9 -0
  99. package/lib/useLocale/index.js +16 -13
  100. package/lib/utils/index.js +4 -1
  101. package/package.json +14 -3
  102. package/lib/BasicLayout/locale/en_US.js +0 -4
  103. package/lib/BasicLayout/locale/index.js +0 -13
  104. package/lib/BasicLayout/locale/ja_JP.js +0 -4
  105. package/lib/BasicLayout/locale/zh_CN.js +0 -4
  106. package/lib/BasicLayout/locale/zh_TW.js +0 -4
  107. package/lib/CWMessage/locale/en_US.js +0 -8
  108. package/lib/CWMessage/locale/index.js +0 -13
  109. package/lib/CWMessage/locale/ja_JP.js +0 -8
  110. package/lib/CWMessage/locale/zh_CN.js +0 -8
  111. package/lib/CWMessage/locale/zh_TW.js +0 -8
  112. package/lib/CWRangePicker/locale/en_US.js +0 -29
  113. package/lib/CWRangePicker/locale/index.js +0 -13
  114. package/lib/CWRangePicker/locale/ja_JP.js +0 -29
  115. package/lib/CWRangePicker/locale/zh_CN.js +0 -29
  116. package/lib/CWRangePicker/locale/zh_TW.js +0 -29
  117. package/lib/CWSelect/locale/en_US.js +0 -4
  118. package/lib/CWSelect/locale/index.js +0 -13
  119. package/lib/CWSelect/locale/ja_JP.js +0 -4
  120. package/lib/CWSelect/locale/zh_CN.js +0 -4
  121. package/lib/CWSelect/locale/zh_TW.js +0 -4
  122. package/lib/CWTable/locale/en_US.js +0 -6
  123. package/lib/CWTable/locale/index.js +0 -13
  124. package/lib/CWTable/locale/ja_JP.js +0 -6
  125. package/lib/CWTable/locale/zh_CN.js +0 -6
  126. package/lib/CWTable/locale/zh_TW.js +0 -6
  127. package/lib/CWTree/locale/en_US.js +0 -3
  128. package/lib/CWTree/locale/index.js +0 -13
  129. package/lib/CWTree/locale/ja_JP.js +0 -3
  130. package/lib/CWTree/locale/zh_CN.js +0 -3
  131. package/lib/CWTree/locale/zh_TW.js +0 -3
  132. package/lib/CWUpload/locale/en_US.js +0 -6
  133. package/lib/CWUpload/locale/index.js +0 -13
  134. package/lib/CWUpload/locale/ja_JP.js +0 -6
  135. package/lib/CWUpload/locale/zh_CN.js +0 -6
  136. package/lib/CWUpload/locale/zh_TW.js +0 -6
  137. package/lib/Card/index.less +0 -10
  138. package/lib/ColorPicker/locale/en_US.js +0 -4
  139. package/lib/ColorPicker/locale/index.js +0 -13
  140. package/lib/ColorPicker/locale/ja_JP.js +0 -4
  141. package/lib/ColorPicker/locale/zh_CN.js +0 -4
  142. package/lib/ColorPicker/locale/zh_TW.js +0 -4
  143. package/lib/DateRangePicker/locale/en_US.js +0 -5
  144. package/lib/DateRangePicker/locale/index.js +0 -13
  145. package/lib/DateRangePicker/locale/ja_JP.js +0 -5
  146. package/lib/DateRangePicker/locale/zh_CN.js +0 -5
  147. package/lib/DateRangePicker/locale/zh_TW.js +0 -5
  148. package/lib/DropdownDatePicker/locale/en_US.js +0 -21
  149. package/lib/DropdownDatePicker/locale/index.js +0 -13
  150. package/lib/DropdownDatePicker/locale/ja_JP.js +0 -21
  151. package/lib/DropdownDatePicker/locale/zh_CN.js +0 -21
  152. package/lib/DropdownDatePicker/locale/zh_TW.js +0 -21
  153. package/lib/Empty/locale/en_US.js +0 -3
  154. package/lib/Empty/locale/index.js +0 -13
  155. package/lib/Empty/locale/ja_JP.js +0 -3
  156. package/lib/Empty/locale/zh_CN.js +0 -3
  157. package/lib/Empty/locale/zh_TW.js +0 -3
  158. package/lib/ErrorBoundary/index.less +0 -15
  159. package/lib/ErrorBoundary/locale/en_US.js +0 -5
  160. package/lib/ErrorBoundary/locale/index.js +0 -13
  161. package/lib/ErrorBoundary/locale/ja_JP.js +0 -5
  162. package/lib/ErrorBoundary/locale/zh_CN.js +0 -5
  163. package/lib/ErrorBoundary/locale/zh_TW.js +0 -5
  164. package/lib/Exception/locale/en_US.js +0 -9
  165. package/lib/Exception/locale/index.js +0 -13
  166. package/lib/Exception/locale/ja_JP.js +0 -9
  167. package/lib/Exception/locale/zh_CN.js +0 -9
  168. package/lib/Exception/locale/zh_TW.js +0 -9
  169. package/lib/FilterDropDown/locale/en_US.js +0 -3
  170. package/lib/FilterDropDown/locale/index.js +0 -13
  171. package/lib/FilterDropDown/locale/ja_JP.js +0 -3
  172. package/lib/FilterDropDown/locale/zh_CN.js +0 -3
  173. package/lib/FilterDropDown/locale/zh_TW.js +0 -3
  174. package/lib/IconSelect/locale/en_US.js +0 -11
  175. package/lib/IconSelect/locale/index.js +0 -13
  176. package/lib/IconSelect/locale/ja_JP.js +0 -11
  177. package/lib/IconSelect/locale/zh_CN.js +0 -11
  178. package/lib/IconSelect/locale/zh_TW.js +0 -11
  179. package/lib/Joyride/locale/en_US.js +0 -25
  180. package/lib/Joyride/locale/index.js +0 -13
  181. package/lib/Joyride/locale/ja_JP.js +0 -25
  182. package/lib/Joyride/locale/zh_CN.js +0 -25
  183. package/lib/Joyride/locale/zh_TW.js +0 -25
  184. package/lib/Pagination/locale/en_US.js +0 -8
  185. package/lib/Pagination/locale/index.js +0 -13
  186. package/lib/Pagination/locale/ja_JP.js +0 -8
  187. package/lib/Pagination/locale/zh_CN.js +0 -8
  188. package/lib/Pagination/locale/zh_TW.js +0 -8
  189. package/lib/Progress/locale/en_US.js +0 -3
  190. package/lib/Progress/locale/index.js +0 -13
  191. package/lib/Progress/locale/ja_JP.js +0 -3
  192. package/lib/Progress/locale/zh_CN.js +0 -3
  193. package/lib/Progress/locale/zh_TW.js +0 -3
  194. package/lib/QuickTransfer/locale/en_US.js +0 -8
  195. package/lib/QuickTransfer/locale/index.js +0 -13
  196. package/lib/QuickTransfer/locale/ja_JP.js +0 -8
  197. package/lib/QuickTransfer/locale/zh_CN.js +0 -8
  198. package/lib/QuickTransfer/locale/zh_TW.js +0 -8
  199. package/lib/RangePicker/locale/en_US.js +0 -5
  200. package/lib/RangePicker/locale/index.js +0 -13
  201. package/lib/RangePicker/locale/ja_JP.js +0 -5
  202. package/lib/RangePicker/locale/zh_CN.js +0 -5
  203. package/lib/RangePicker/locale/zh_TW.js +0 -5
  204. package/lib/SearchBar/locale/en_US.js +0 -6
  205. package/lib/SearchBar/locale/index.js +0 -13
  206. package/lib/SearchBar/locale/ja_JP.js +0 -6
  207. package/lib/SearchBar/locale/zh_CN.js +0 -6
  208. package/lib/SearchBar/locale/zh_TW.js +0 -6
  209. package/lib/TimeRangeSlider/locale/en_US.js +0 -31
  210. package/lib/TimeRangeSlider/locale/index.js +0 -13
  211. package/lib/TimeRangeSlider/locale/ja_JP.js +0 -31
  212. package/lib/TimeRangeSlider/locale/zh_CN.js +0 -31
  213. package/lib/TimeRangeSlider/locale/zh_TW.js +0 -31
  214. package/lib/TreeSelect111/locale/en_US.js +0 -3
  215. package/lib/TreeSelect111/locale/index.js +0 -13
  216. package/lib/TreeSelect111/locale/ja_JP.js +0 -3
  217. package/lib/TreeSelect111/locale/zh_CN.js +0 -3
  218. package/lib/TreeSelect111/locale/zh_TW.js +0 -3
  219. package/lib/WangEditor/locale/index.js +0 -93
@@ -7,7 +7,6 @@ import _Empty from "@chaoswise/ui/lib/Empty";
7
7
  import _Spin from "@chaoswise/ui/lib/Spin";
8
8
  import "@chaoswise/ui/lib/Badge/index.less";
9
9
  import _Badge from "@chaoswise/ui/lib/Badge";
10
- import _useLocale2 from "@chaoswise/ui/lib/useLocale";
11
10
  import "@chaoswise/ui/lib/Tabs/index.less";
12
11
  import _Tabs from "@chaoswise/ui/lib/Tabs";
13
12
  import _ThemeProvider from "@chaoswise/ui/lib/ThemeProvider";
@@ -17,7 +16,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
17
16
  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; }
18
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
18
  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); }
20
- 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
19
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
20
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
21
21
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
22
22
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
23
23
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
@@ -26,40 +26,15 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
26
26
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
27
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
28
28
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
29
+ import useIntl from '../../useIntl';
30
+ import useConfigLocale from '../../ConfigProvider/useLocale';
29
31
  import React, { useState, useEffect, useRef } from "react";
30
32
  import { getMessageTypeApi, getMessageListApi, getMessageUnreadCountApi } from "../service";
31
33
  import TabList from "./TabList";
32
34
  import { useHistory } from "react-router-dom";
33
- import langConfig from "../locale";
34
- import { formatMessage } from "../../utils";
35
35
  import "./index.less";
36
36
  var useThemeSwitcher = _ThemeProvider.useThemeSwitcher;
37
37
  var TabPane = _Tabs.TabPane;
38
- var localOptionsMap = {
39
- en: "enName",
40
- en_US: "enName",
41
- zh_TW: "name",
42
- zh: "name",
43
- zh_CN: "name",
44
- ja: "jaName",
45
- ja_JP: "jaName"
46
- };
47
-
48
- // 获取本地化字段名的方法,提供兜底逻辑
49
- var getLocalizedField = function getLocalizedField(locale) {
50
- return localOptionsMap[locale];
51
- };
52
-
53
- // 获取本地化的 tab 名称,最终兜底到 name 字段
54
- var getLocalizedTabName = function getLocalizedTabName(item, locale) {
55
- var fieldName = getLocalizedField(locale);
56
- // 判断 item 中是否包含转换后的字段
57
- if (fieldName && fieldName in item) {
58
- return item[fieldName];
59
- }
60
- // 否则使用 name 字段
61
- return item.name;
62
- };
63
38
  var MessageContent = function MessageContent(props) {
64
39
  var hideOnSinglePage = props.hideOnSinglePage,
65
40
  setVisible = props.setVisible,
@@ -79,6 +54,14 @@ var MessageContent = function MessageContent(props) {
79
54
  var history = useHistory();
80
55
  var _useThemeSwitcher = useThemeSwitcher(),
81
56
  themeVars = _useThemeSwitcher.themeVars;
57
+ var intl = useIntl();
58
+ var _useConfigLocale = useConfigLocale(),
59
+ _useConfigLocale$loca = _useConfigLocale.locale,
60
+ locale = _useConfigLocale$loca === void 0 ? "zh_CN" : _useConfigLocale$loca;
61
+ var localeRef = useRef(locale);
62
+ localeRef.current = locale;
63
+ var listRequestRef = useRef(0);
64
+ var unreadRequestRef = useRef(0);
82
65
  // tabs头部配置项
83
66
  var _useState = useState([]),
84
67
  _useState2 = _slicedToArray(_useState, 2),
@@ -103,59 +86,81 @@ var MessageContent = function MessageContent(props) {
103
86
  _getMessageListApi = requestOption.getMessageListApi,
104
87
  _getMessageUnreadCountApi = requestOption.getMessageUnreadCountApi;
105
88
  useEffect(function () {
106
- _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
107
- var resRequestApi, res, _data$, data, params;
108
- return _regeneratorRuntime().wrap(function _callee$(_context) {
109
- while (1) switch (_context.prev = _context.next) {
89
+ var cancelled = false;
90
+ _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
91
+ var resRequestApi, res, _data$, data, selected, params;
92
+ return _regenerator().w(function (_context) {
93
+ while (1) switch (_context.n) {
110
94
  case 0:
111
- resRequestApi = _getMessageTypeApi || getMessageTypeApi;
112
- _context.next = 3;
95
+ resRequestApi = _getMessageTypeApi || function (gateway) {
96
+ return getMessageTypeApi(gateway, locale);
97
+ };
98
+ _context.n = 1;
113
99
  return resRequestApi(gatewayPrefix);
114
- case 3:
115
- res = _context.sent;
100
+ case 1:
101
+ res = _context.v;
102
+ if (!cancelled) {
103
+ _context.n = 2;
104
+ break;
105
+ }
106
+ return _context.a(2);
107
+ case 2:
116
108
  if (res && res.status == "success") {
117
109
  data = res.data;
118
110
  setTabOption(data);
111
+ // The backend localizes name. Refresh on language changes without
112
+ // discarding the currently selected category or page conditions.
113
+ selected = data.find(function (item) {
114
+ return item.code === conditionsRef.current.type;
115
+ });
119
116
  params = {
120
- type: (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.code
117
+ type: selected ? selected.code : (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.code
121
118
  };
122
119
  getMessageList(params);
123
120
  }
124
121
  getMessageUnreadCount();
125
- case 6:
126
- case "end":
127
- return _context.stop();
122
+ case 3:
123
+ return _context.a(2);
128
124
  }
129
125
  }, _callee);
130
126
  }))();
131
- }, []);
132
- var _useLocale = _useLocale2(langConfig),
133
- localeObj = _useLocale.langObj,
134
- _useLocale$locale = _useLocale.locale,
135
- locale = _useLocale$locale === void 0 ? "zh_CN" : _useLocale$locale;
127
+ return function () {
128
+ cancelled = true;
129
+ listRequestRef.current++;
130
+ unreadRequestRef.current++;
131
+ };
132
+ }, [locale]);
136
133
  // 查询消息列表(接口)
137
134
  var getMessageList = /*#__PURE__*/function () {
138
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
139
- var resRequestApi, res, _res$data, _total, _res$data$records, records;
140
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
141
- while (1) switch (_context2.prev = _context2.next) {
135
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(params) {
136
+ var requestId, resRequestApi, res, _res$data, _total, _res$data$records, records;
137
+ return _regenerator().w(function (_context2) {
138
+ while (1) switch (_context2.n) {
142
139
  case 0:
140
+ requestId = ++listRequestRef.current;
143
141
  setLoading(true);
144
142
  conditionsRef.current = _objectSpread(_objectSpread({}, conditionsRef.current), params);
145
- resRequestApi = _getMessageListApi || getMessageListApi;
146
- _context2.next = 5;
143
+ resRequestApi = _getMessageListApi || function (params, gateway) {
144
+ return getMessageListApi(params, gateway, locale);
145
+ };
146
+ _context2.n = 1;
147
147
  return resRequestApi(conditionsRef.current, gatewayPrefix);
148
- case 5:
149
- res = _context2.sent;
148
+ case 1:
149
+ res = _context2.v;
150
+ if (!(requestId !== listRequestRef.current || localeRef.current !== locale)) {
151
+ _context2.n = 2;
152
+ break;
153
+ }
154
+ return _context2.a(2);
155
+ case 2:
150
156
  if (res && res.status == "success") {
151
157
  _res$data = res.data, _total = _res$data.total, _res$data$records = _res$data.records, records = _res$data$records === void 0 ? [] : _res$data$records;
152
158
  setDataSource(records);
153
159
  setTotal(_total);
154
160
  }
155
161
  setLoading(false);
156
- case 8:
157
- case "end":
158
- return _context2.stop();
162
+ case 3:
163
+ return _context2.a(2);
159
164
  }
160
165
  }, _callee2);
161
166
  }));
@@ -165,24 +170,32 @@ var MessageContent = function MessageContent(props) {
165
170
  }();
166
171
  // 查询所有类型的未读消息数(接口)
167
172
  var getMessageUnreadCount = /*#__PURE__*/function () {
168
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
169
- var resRequestApi, res, _res$data$byType, byType, _unreadTypeArr;
170
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
171
- while (1) switch (_context3.prev = _context3.next) {
173
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
174
+ var requestId, resRequestApi, res, _res$data$byType, byType, _unreadTypeArr;
175
+ return _regenerator().w(function (_context3) {
176
+ while (1) switch (_context3.n) {
172
177
  case 0:
173
- resRequestApi = _getMessageUnreadCountApi || getMessageUnreadCountApi;
174
- _context3.next = 3;
178
+ requestId = ++unreadRequestRef.current;
179
+ resRequestApi = _getMessageUnreadCountApi || function (gateway) {
180
+ return getMessageUnreadCountApi(gateway, locale);
181
+ };
182
+ _context3.n = 1;
175
183
  return resRequestApi(gatewayPrefix);
176
- case 3:
177
- res = _context3.sent;
184
+ case 1:
185
+ res = _context3.v;
186
+ if (!(requestId !== unreadRequestRef.current || localeRef.current !== locale)) {
187
+ _context3.n = 2;
188
+ break;
189
+ }
190
+ return _context3.a(2);
191
+ case 2:
178
192
  if (res && res.status == "success") {
179
193
  _res$data$byType = res.data.byType, byType = _res$data$byType === void 0 ? {} : _res$data$byType;
180
194
  _unreadTypeArr = Object.keys(byType || {});
181
195
  setUnreadTypeArr(_unreadTypeArr);
182
196
  }
183
- case 5:
184
- case "end":
185
- return _context3.stop();
197
+ case 3:
198
+ return _context3.a(2);
186
199
  }
187
200
  }, _callee3);
188
201
  }));
@@ -236,7 +249,7 @@ var MessageContent = function MessageContent(props) {
236
249
  total: total
237
250
  };
238
251
  };
239
- var emptyDescription = formatMessage(localeObj["no_new_messages"]);
252
+ var emptyDescription = intl.get("fcdcd88b-3db8-4216-a93a-ab79d854408d").d("暂无新消息");
240
253
  return /*#__PURE__*/React.createElement("div", {
241
254
  className: "cw-message-content"
242
255
  }, tabOption.length ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Tabs, {
@@ -244,8 +257,8 @@ var MessageContent = function MessageContent(props) {
244
257
  className: "cw-message-content-tabs",
245
258
  animated: false
246
259
  }, tabOption.map(function (item) {
247
- var tabName = getLocalizedTabName(item, locale);
248
- var moreTitle = formatMessage(localeObj["more"]);
260
+ var tabName = item.name;
261
+ var moreTitle = intl.get("a30db643-5238-42bc-bc5e-98a9d0c7df51").d("更多");
249
262
  return /*#__PURE__*/React.createElement(TabPane, {
250
263
  tab: unreadTypeArr.includes(item.code) ? /*#__PURE__*/React.createElement(_Badge, {
251
264
  color: themeVars["red-5"]
@@ -284,9 +297,9 @@ var MessageContent = function MessageContent(props) {
284
297
  })));
285
298
  })), total == 0 || hideOnSinglePage && total <= pageInfo.pageSize ? null : /*#__PURE__*/React.createElement("div", {
286
299
  className: "cw-message-pagination-wrapper"
287
- }, /*#__PURE__*/React.createElement("span", null, formatMessage(localeObj["totalItems"], {
300
+ }, /*#__PURE__*/React.createElement("span", null, intl.get("205d9305-0c9e-4384-a5e2-4e1bbdc4a76f", {
288
301
  total: total
289
- })), /*#__PURE__*/React.createElement(_Pagination, _extends({
302
+ }).d("共{total}条")), /*#__PURE__*/React.createElement(_Pagination, _extends({
290
303
  simple: true
291
304
  }, getPaginationOption())))) : /*#__PURE__*/React.createElement(_Empty, {
292
305
  description: emptyDescription
@@ -6,12 +6,12 @@ import "@chaoswise/ui/lib/Modal/index.less";
6
6
  import _Modal from "@chaoswise/ui/lib/Modal";
7
7
  import "@chaoswise/ui/lib/CustomNotification/index.less";
8
8
  import _CustomNotification from "@chaoswise/ui/lib/CustomNotification";
9
- import _useLocale2 from "@chaoswise/ui/lib/useLocale";
10
9
  import _useConfigContext2 from "@chaoswise/ui/lib/useConfigContext";
11
10
  var _excluded = ["count"],
12
11
  _excluded2 = ["onClickStrongMessageItem"];
13
12
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
14
- 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
13
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
14
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
15
15
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
16
16
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -27,6 +27,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
27
27
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
28
28
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
29
29
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
30
+ import useIntl from '../useIntl';
31
+ import useConfigLocale from '../ConfigProvider/useLocale';
30
32
  import React, { useState, useEffect, useMemo, useRef } from "react";
31
33
  import messageIcon from "./message.svg";
32
34
  import CommonIcon from "./CommonIcon";
@@ -36,8 +38,6 @@ import classnames from "classnames";
36
38
  import PropTypes from "prop-types";
37
39
  import io from "socket.io-client";
38
40
  import audioMp3 from "./audioMp3.wav";
39
- import langConfig from "./locale";
40
- import { formatMessage } from "../utils";
41
41
  import "./index.less";
42
42
  function Message(props) {
43
43
  var _props$hideOnSinglePa = props.hideOnSinglePage,
@@ -75,8 +75,14 @@ function Message(props) {
75
75
  var _useConfigContext = _useConfigContext2(),
76
76
  getPrefixCls = _useConfigContext.getPrefixCls;
77
77
  var prefixCls = getPrefixCls();
78
- var _useLocale = _useLocale2(langConfig),
79
- localeObj = _useLocale.langObj;
78
+ var intl = useIntl();
79
+ var intlRef = useRef(intl);
80
+ intlRef.current = intl;
81
+ var _useConfigLocale = useConfigLocale(),
82
+ locale = _useConfigLocale.locale;
83
+ // Socket listeners outlive renders; default requests must use the latest language.
84
+ var localeRef = useRef(locale);
85
+ localeRef.current = locale;
80
86
  var messageImg = imgOption.messageImg,
81
87
  _imgOption$badgeOptio = imgOption.badgeOption,
82
88
  badgeOption = _imgOption$badgeOptio === void 0 ? {} : _imgOption$badgeOptio;
@@ -115,9 +121,9 @@ function Message(props) {
115
121
  current: 1,
116
122
  pageSize: 30
117
123
  }),
118
- _useState10 = _slicedToArray(_useState9, 2),
119
- pageInfo = _useState10[0],
120
- setPageInfo = _useState10[1];
124
+ _useState0 = _slicedToArray(_useState9, 2),
125
+ pageInfo = _useState0[0],
126
+ setPageInfo = _useState0[1];
121
127
  // 初始化条件
122
128
  var conditionsRef = useRef({
123
129
  current: 1,
@@ -188,20 +194,22 @@ function Message(props) {
188
194
  audio.play()["catch"](function (err) {
189
195
  var _err$message;
190
196
  if ((err === null || err === void 0 ? void 0 : err.name) === "NotAllowedError" && err !== null && err !== void 0 && (_err$message = err.message) !== null && _err$message !== void 0 && _err$message.includes('play() failed')) {
197
+ var _intl = intlRef.current;
191
198
  if (!modal.current) {
192
199
  modal.current = _Modal.warning({
193
- title: formatMessage(localeObj["playAutomatically"]),
200
+ title: _intl.get("de6eaecc-9d39-41f1-82d3-80694c558028").d("消息提醒需要有交互行为才可以自动播放"),
194
201
  prefixCls: "".concat(prefixCls, "-modal"),
195
202
  okButtonProps: {
196
203
  prefixCls: "".concat(prefixCls, "-btn")
197
204
  },
198
- okText: formatMessage(localeObj["ok"]),
205
+ okText: _intl.get("4253417c-d699-4eed-8c75-34d2a8b18a68").d("确定"),
199
206
  mask: true,
200
207
  maskClosable: true
201
208
  });
202
209
  } else {
203
- modal.current.update(function (prevConfig) {
204
- return _objectSpread({}, prevConfig);
210
+ modal.current.update({
211
+ title: _intl.get("de6eaecc-9d39-41f1-82d3-80694c558028").d("消息提醒需要有交互行为才可以自动播放"),
212
+ okText: _intl.get("4253417c-d699-4eed-8c75-34d2a8b18a68").d("确定")
205
213
  });
206
214
  }
207
215
  }
@@ -209,20 +217,22 @@ function Message(props) {
209
217
  }
210
218
  };
211
219
  var openNotification = /*#__PURE__*/function () {
212
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(time, id) {
220
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(time, id) {
213
221
  var params, resRequestApi, res, data, _ref2, userMessageId, title, summary;
214
- return _regeneratorRuntime().wrap(function _callee$(_context) {
215
- while (1) switch (_context.prev = _context.next) {
222
+ return _regenerator().w(function (_context) {
223
+ while (1) switch (_context.n) {
216
224
  case 0:
217
225
  params = {
218
226
  userMessageId: id,
219
227
  clientType: "BROWSER"
220
228
  };
221
- resRequestApi = _getMessageDetailApi || getMessageDetailApi;
222
- _context.next = 4;
229
+ resRequestApi = _getMessageDetailApi || function (params, gateway) {
230
+ return getMessageDetailApi(params, gateway, localeRef.current);
231
+ };
232
+ _context.n = 1;
223
233
  return resRequestApi(params, gatewayPrefix);
224
- case 4:
225
- res = _context.sent;
234
+ case 1:
235
+ res = _context.v;
226
236
  if (res && res.status == "success") {
227
237
  data = res.data;
228
238
  _ref2 = data || {}, userMessageId = _ref2.userMessageId, title = _ref2.title, summary = _ref2.summary; // 消息语音提示
@@ -245,9 +255,8 @@ function Message(props) {
245
255
  key: id
246
256
  }, restStrongMessageOption));
247
257
  }
248
- case 6:
249
- case "end":
250
- return _context.stop();
258
+ case 2:
259
+ return _context.a(2);
251
260
  }
252
261
  }, _callee);
253
262
  }));
@@ -256,16 +265,17 @@ function Message(props) {
256
265
  };
257
266
  }();
258
267
  var readInnerMessage = /*#__PURE__*/function () {
259
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
268
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(params) {
260
269
  var resRequestApi;
261
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
262
- while (1) switch (_context2.prev = _context2.next) {
270
+ return _regenerator().w(function (_context2) {
271
+ while (1) switch (_context2.n) {
263
272
  case 0:
264
- resRequestApi = _readInnerMessageApi || readInnerMessageApi;
273
+ resRequestApi = _readInnerMessageApi || function (params, gateway) {
274
+ return readInnerMessageApi(params, gateway, localeRef.current);
275
+ };
265
276
  resRequestApi(params, gatewayPrefix);
266
- case 2:
267
- case "end":
268
- return _context2.stop();
277
+ case 1:
278
+ return _context2.a(2);
269
279
  }
270
280
  }, _callee2);
271
281
  }));
@@ -302,17 +312,19 @@ function Message(props) {
302
312
  }
303
313
  };
304
314
  var connectSocket = /*#__PURE__*/function () {
305
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
315
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
306
316
  var resRequestApi, res, finalOrigin, socket;
307
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
308
- while (1) switch (_context3.prev = _context3.next) {
317
+ return _regenerator().w(function (_context3) {
318
+ while (1) switch (_context3.n) {
309
319
  case 0:
310
320
  // 获取sessionId
311
- resRequestApi = _getSessionId || getSessionId;
312
- _context3.next = 3;
321
+ resRequestApi = _getSessionId || function (gateway) {
322
+ return getSessionId(gateway, localeRef.current);
323
+ };
324
+ _context3.n = 1;
313
325
  return resRequestApi(gatewayPrefix);
314
- case 3:
315
- res = _context3.sent;
326
+ case 1:
327
+ res = _context3.v;
316
328
  if (res && res.status == "success") {
317
329
  finalOrigin = socketOrigin || "ws://".concat(window.location.host); // 连接到后端socket服务器
318
330
  socket = io(finalOrigin, {
@@ -334,9 +346,8 @@ function Message(props) {
334
346
  };
335
347
  });
336
348
  }
337
- case 5:
338
- case "end":
339
- return _context3.stop();
349
+ case 2:
350
+ return _context3.a(2);
340
351
  }
341
352
  }, _callee3);
342
353
  }));
@@ -345,23 +356,24 @@ function Message(props) {
345
356
  };
346
357
  }();
347
358
  var getMessageQuerySettings = /*#__PURE__*/function () {
348
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
359
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
349
360
  var resRequestApi, res, data;
350
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
351
- while (1) switch (_context4.prev = _context4.next) {
361
+ return _regenerator().w(function (_context4) {
362
+ while (1) switch (_context4.n) {
352
363
  case 0:
353
- resRequestApi = _getMessageQuerySettingsApi || getMessageQuerySettingsApi;
354
- _context4.next = 3;
364
+ resRequestApi = _getMessageQuerySettingsApi || function (gateway) {
365
+ return getMessageQuerySettingsApi(gateway, localeRef.current);
366
+ };
367
+ _context4.n = 1;
355
368
  return resRequestApi(gatewayPrefix);
356
- case 3:
357
- res = _context4.sent;
369
+ case 1:
370
+ res = _context4.v;
358
371
  if (res && res.status === "success") {
359
372
  data = res.data;
360
373
  messageOptionRef.current = data || {};
361
374
  }
362
- case 5:
363
- case "end":
364
- return _context4.stop();
375
+ case 2:
376
+ return _context4.a(2);
365
377
  }
366
378
  }, _callee4);
367
379
  }));