@chaoswise/ui 2.6.6 → 2.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,11 +11,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
11
11
  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); }
12
12
  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); }); }; }
13
13
  import React from "react";
14
- // import moment from "moment";
15
-
14
+ import moment from "moment";
16
15
  import { readInnerMessageApi } from "../../service";
17
16
  import langConfig from "../../locale";
18
- import { formatMessage, setMomentByTimeZone, getFormatByLocalStorage } from "../../../utils";
17
+ import { formatMessage } from "../../../utils";
19
18
  import "./index.less";
20
19
  var TabList = function TabList(props) {
21
20
  var _props$messages = props.messages,
@@ -30,7 +29,8 @@ var TabList = function TabList(props) {
30
29
  setVisible = props.setVisible,
31
30
  requestOption = props.requestOption,
32
31
  code = props.code,
33
- onTabListAllRead = props.onTabListAllRead;
32
+ onTabListAllRead = props.onTabListAllRead,
33
+ renderMessageDateFormat = props.renderMessageDateFormat;
34
34
  var _useLocale = _useLocale2(langConfig),
35
35
  localeObj = _useLocale.langObj;
36
36
  var _readInnerMessageApi = requestOption.readInnerMessageApi;
@@ -108,7 +108,7 @@ var TabList = function TabList(props) {
108
108
  className: "cw-message-content-tabs-list-desc"
109
109
  }, (_message$summary = message.summary) !== null && _message$summary !== void 0 ? _message$summary : ""), /*#__PURE__*/React.createElement("div", {
110
110
  className: "cw-message-content-tabs-list-date"
111
- }, message.time ? setMomentByTimeZone(Number(message.time)).format(getFormatByLocalStorage("YYYY/MM/DD HH:mm:ss")) : ""));
111
+ }, message.time ? renderMessageDateFormat ? renderMessageDateFormat(Number(message.time)) : moment(Number(message.time)).format("YYYY/MM/DD HH:mm:ss") : ""));
112
112
  });
113
113
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, {
114
114
  className: "cw-message-content-all-read",
@@ -56,7 +56,8 @@ var MessageContent = function MessageContent(props) {
56
56
  isClose = props.isClose,
57
57
  requestOption = props.requestOption,
58
58
  onTabListAllRead = props.onTabListAllRead,
59
- conditionsRef = props.conditionsRef;
59
+ conditionsRef = props.conditionsRef,
60
+ renderMessageDateFormat = props.renderMessageDateFormat;
60
61
  var history = useHistory();
61
62
  var _useThemeSwitcher = useThemeSwitcher(),
62
63
  themeVars = _useThemeSwitcher.themeVars;
@@ -246,7 +247,8 @@ var MessageContent = function MessageContent(props) {
246
247
  setVisible: setVisible,
247
248
  requestOption: requestOption,
248
249
  code: item.code,
249
- onTabListAllRead: onTabListAllRead
250
+ onTabListAllRead: onTabListAllRead,
251
+ renderMessageDateFormat: renderMessageDateFormat
250
252
  }) : /*#__PURE__*/React.createElement(_Empty, {
251
253
  description: emptyDescription
252
254
  }), /*#__PURE__*/React.createElement("div", {
@@ -60,7 +60,9 @@ function Message(props) {
60
60
  _props$strongMessageO = props.strongMessageOption,
61
61
  strongMessageOption = _props$strongMessageO === void 0 ? {} : _props$strongMessageO,
62
62
  _props$onSocketChange = props.onSocketChange,
63
- onSocketChange = _props$onSocketChange === void 0 ? function () {} : _props$onSocketChange;
63
+ onSocketChange = _props$onSocketChange === void 0 ? function () {} : _props$onSocketChange,
64
+ _props$renderMessageD = props.renderMessageDateFormat,
65
+ renderMessageDateFormat = _props$renderMessageD === void 0 ? function () {} : _props$renderMessageD;
64
66
  var _useConfigContext = _useConfigContext2(),
65
67
  getPrefixCls = _useConfigContext.getPrefixCls;
66
68
  var prefixCls = getPrefixCls();
@@ -366,7 +368,8 @@ function Message(props) {
366
368
  requestOption: requestOption,
367
369
  onTabListAllRead: onTabListAllRead,
368
370
  closable: closable,
369
- conditionsRef: conditionsRef
371
+ conditionsRef: conditionsRef,
372
+ renderMessageDateFormat: renderMessageDateFormat
370
373
  })));
371
374
  }
372
375
  Message.defaultProps = {
@@ -431,6 +434,10 @@ Message.propTypes = {
431
434
  /**
432
435
  * 强提醒配置strongMessageOption = {onClickStrongMessageItem = ()=>{},点击强提醒项后的回调}
433
436
  */
434
- strongMessageOption: PropTypes.object
437
+ strongMessageOption: PropTypes.object,
438
+ /**
439
+ * 渲染消息时间格式,function(时间戳)=>{},
440
+ */
441
+ renderMessageDateFormat: PropTypes.func
435
442
  };
436
443
  export default Message;
@@ -232,11 +232,6 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
232
232
  useEffect(function () {
233
233
  // 设置数据源
234
234
  setData(dataSource);
235
- if (type === "list") {
236
- if (targetKeys) {
237
- setListCheckedStyle(targetKeys, dataSource);
238
- }
239
- }
240
235
  }, [dataSource]);
241
236
  useEffect(function () {
242
237
  //传入的当前选中的key
@@ -262,6 +257,21 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
262
257
  return !i.disabled;
263
258
  }));
264
259
  setCheckValue(finalCheckValue);
260
+ var newData = [];
261
+ var listCheckedKeys_ = [];
262
+ dataSource.forEach(function (item, index) {
263
+ if (isMath(item.title, saveSearchValueLeft)) {
264
+ newData.push(dataSource[index]);
265
+ }
266
+ });
267
+ listCheckedKeys_ = newData.filter(function (item) {
268
+ return finalCheckValue.find(function (i) {
269
+ return i.key == item.key;
270
+ });
271
+ }).map(function (item) {
272
+ return item.key;
273
+ });
274
+ setListCheckedStyle(listCheckedKeys_, newData);
265
275
  }
266
276
  //回显table
267
277
  if (type === "table") {
@@ -277,7 +287,7 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
277
287
  }
278
288
  }
279
289
  }
280
- }, [targetKeys, dataSource]);
290
+ }, [targetKeys, dataSource, saveSearchValueLeft]);
281
291
  //触发前端自定义搜索
282
292
  useEffect(function () {
283
293
  if (searchValueLeft !== undefined) {
@@ -91,19 +91,22 @@ export var formatMessage = function formatMessage(message) {
91
91
 
92
92
  /**
93
93
  * 根据特定时区将时间戳转换为固定时间偏移量的时间对象
94
- * @param {*} time 时间参数 作为moment的值
95
- * @param {*} countryCityCode 自定义时区 需要转化的时区值
96
- * @returns {moment.Moment} 返回的moment对象
94
+ * @param {*} time - 时间参数,可以是时间戳、日期字符串或 moment 对象
95
+ * @param {*} defaultCountryCityCode - 默认时区代码,默认为本地时区(通过 moment.tz.guess() 自动检测)
96
+ * @param {*} countryCityCode - 自定义时区代码,用于覆盖默认时区
97
+ * @returns {moment.Moment} 返回转换为指定时区的 moment 对象
97
98
  */
98
- export var setMomentByTimeZone = function setMomentByTimeZone(time, countryCityCode) {
99
- // 从localStorage获取时区信息
99
+ export var setDateByTimeZone = function setDateByTimeZone(time) {
100
+ var defaultCountryCityCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : moment.tz.guess();
101
+ var countryCityCode = arguments.length > 2 ? arguments[2] : undefined;
102
+ // 从 localStorage 获取时区信息
100
103
  var timeZoneData = JSON.parse(localStorage.getItem('cw_timeZone'));
101
-
102
- // 如果 localStorage 中找不到时区信息,则使用 moment.tz.guess() 自动推测本地时区
103
- var timezone = timeZoneData ? timeZoneData.countryCityCode : moment.tz.guess();
104
+ // 如果 localStorage 中没有找到时区信息,则使用默认时区(自动推测的本地时区)
105
+ var timezone = timeZoneData ? timeZoneData.countryCityCode : defaultCountryCityCode;
106
+ // 如果有传入的自定义时区代码,则使用自定义时区,否则使用从 localStorage 获取或推测的时区
104
107
  var _timezone = countryCityCode ? countryCityCode : timezone;
105
- // (如时间戳或moment对象)
106
- return moment.tz(time, _timezone); // 直接使用时区创建moment对象
108
+ // 返回转换为指定时区的 moment 对象
109
+ return moment.tz(time, _timezone);
107
110
  };
108
111
 
109
112
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaoswise/ui",
3
- "version": "2.6.6",
3
+ "version": "2.6.7",
4
4
  "description": "公共UI库",
5
5
  "keywords": [
6
6
  "ui",
@@ -149,5 +149,5 @@
149
149
  "access": "public"
150
150
  },
151
151
  "license": "MIT",
152
- "gitHead": "d8ab9b19eea2bb894165d1797057153592cb85f7"
152
+ "gitHead": "fe06e4858602753c10139ad38f812f6c5aeb8146"
153
153
  }