@chaoswise/ui 2.6.6 → 2.6.8
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
|
-
|
|
15
|
-
|
|
14
|
+
import moment from "moment";
|
|
16
15
|
import { readInnerMessageApi } from "../../service";
|
|
17
16
|
import langConfig from "../../locale";
|
|
18
|
-
import { formatMessage
|
|
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 ?
|
|
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", {
|
package/lib/CWMessage/index.js
CHANGED
|
@@ -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;
|
package/lib/CWTable/CWTable.js
CHANGED
|
@@ -95,37 +95,29 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
95
95
|
isRealTimeDrag = _ref$isRealTimeDrag === void 0 ? true : _ref$isRealTimeDrag,
|
|
96
96
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
97
97
|
var prefix = rest.getPrefixCls();
|
|
98
|
-
|
|
98
|
+
//filterDropDown和表格联用控制表格的列是否显示
|
|
99
|
+
var _useState = useState([]),
|
|
99
100
|
_useState2 = _slicedToArray(_useState, 2),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
showCols = _useState2[0],
|
|
102
|
+
setShowCols = _useState2[1];
|
|
103
|
+
//异步加载设置loading
|
|
104
|
+
var _useState3 = useState(''),
|
|
103
105
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//filterDropDown和表格联用控制表格的列是否显示
|
|
106
|
+
loading = _useState4[0],
|
|
107
|
+
setLoading = _useState4[1];
|
|
107
108
|
var _useState5 = useState([]),
|
|
108
109
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
tableColumn = _useState6[0],
|
|
111
|
+
setTableColumn = _useState6[1];
|
|
112
|
+
// 编辑行,编辑中的那一行的id
|
|
112
113
|
var _useState7 = useState(''),
|
|
113
114
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
editingKey = _useState8[0],
|
|
116
|
+
setEditingKey = _useState8[1];
|
|
116
117
|
var _useState9 = useState([]),
|
|
117
118
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// 编辑行,编辑中的那一行的id
|
|
121
|
-
var _useState11 = useState(''),
|
|
122
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
123
|
-
editingKey = _useState12[0],
|
|
124
|
-
setEditingKey = _useState12[1];
|
|
125
|
-
var _useState13 = useState([]),
|
|
126
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
127
|
-
finalDataSource = _useState14[0],
|
|
128
|
-
setFinalDataSource = _useState14[1];
|
|
119
|
+
finalDataSource = _useState10[0],
|
|
120
|
+
setFinalDataSource = _useState10[1];
|
|
129
121
|
|
|
130
122
|
// 重写onChange
|
|
131
123
|
var sorterInfo = useRef({}); // header中也会修改sorterInfo中的属性
|
|
@@ -188,13 +180,13 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
188
180
|
};
|
|
189
181
|
|
|
190
182
|
// 设置前端分页
|
|
191
|
-
var
|
|
183
|
+
var _useState11 = useState({
|
|
192
184
|
current: 1,
|
|
193
185
|
pageSize: 30
|
|
194
186
|
}),
|
|
195
|
-
|
|
196
|
-
pageInfo =
|
|
197
|
-
setPageInfo =
|
|
187
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
188
|
+
pageInfo = _useState12[0],
|
|
189
|
+
setPageInfo = _useState12[1];
|
|
198
190
|
// 设置搜索字段
|
|
199
191
|
var searchInfo = useRef({}); // 搜索信息
|
|
200
192
|
var watcher = useRef(null); // null
|
|
@@ -238,7 +230,7 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
238
230
|
_columnFilter$isShowS = columnFilter.isShowSelectAll,
|
|
239
231
|
isShowSelectAll = _columnFilter$isShowS === void 0 ? false : _columnFilter$isShowS;
|
|
240
232
|
var resetSortDataSource = function resetSortDataSource() {
|
|
241
|
-
var _dataSource =
|
|
233
|
+
var _dataSource = dataSource;
|
|
242
234
|
if (frontPagination) {
|
|
243
235
|
var _current = pagination.current,
|
|
244
236
|
_pageSize = pagination.pageSize,
|
|
@@ -267,10 +259,10 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
267
259
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
268
260
|
var entry = _step.value;
|
|
269
261
|
var _className = entry.target.className;
|
|
270
|
-
var
|
|
262
|
+
var _height = entry.contentRect.height;
|
|
271
263
|
var offsetHeight = entry.target.offsetHeight;
|
|
272
264
|
if (_className.includes('cw-common-table')) {
|
|
273
|
-
outerHeight =
|
|
265
|
+
outerHeight = _height;
|
|
274
266
|
}
|
|
275
267
|
if (_className.includes('cw-table-extra-header-area')) {
|
|
276
268
|
extraHeaderHeight = offsetHeight; // padding不计算高度
|
|
@@ -281,21 +273,39 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
281
273
|
if (_className.includes('cw-table-pagination-box')) {
|
|
282
274
|
paginationHeight = offsetHeight;
|
|
283
275
|
}
|
|
284
|
-
if (_className.includes('-table-header')) {
|
|
285
|
-
tableHeaderHeight = height;
|
|
286
|
-
}
|
|
287
276
|
}
|
|
288
|
-
|
|
289
|
-
// 计算表格高度
|
|
290
277
|
} catch (err) {
|
|
291
278
|
_iterator.e(err);
|
|
292
279
|
} finally {
|
|
293
280
|
_iterator.f();
|
|
294
281
|
}
|
|
282
|
+
if (showHeader) {
|
|
283
|
+
var tableHeaderDom = tableRef.current.querySelector(".".concat(prefix, "-table-thead"));
|
|
284
|
+
if (tableHeaderDom) {
|
|
285
|
+
var _tableHeaderDom$getBo = tableHeaderDom.getBoundingClientRect(),
|
|
286
|
+
height = _tableHeaderDom$getBo.height;
|
|
287
|
+
tableHeaderHeight = height;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// 计算表格高度
|
|
295
291
|
var tableWrapperHeight = outerHeight - searchBarHeight - extraHeaderHeight - paginationHeight;
|
|
296
292
|
var scrollY = tableWrapperHeight - tableHeaderHeight - 2;
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
tableRef.current.style.height = "".concat(tableWrapperHeight, "px");
|
|
294
|
+
var maxHeight = "".concat(scrollY, "px");
|
|
295
|
+
if (finalDataSource.length !== 0) {
|
|
296
|
+
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.height = maxHeight;
|
|
297
|
+
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.maxHeight = maxHeight;
|
|
298
|
+
var allFixedBodyInnerDom = tableRef.current.querySelectorAll(".".concat(prefix, "-table-body-inner"));
|
|
299
|
+
if (allFixedBodyInnerDom) {
|
|
300
|
+
allFixedBodyInnerDom.forEach(function (fixedBody) {
|
|
301
|
+
fixedBody.style.maxHeight = maxHeight;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.height = 'unset';
|
|
306
|
+
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.maxHeight = "unset";
|
|
307
|
+
tableRef.current.querySelector(".".concat(prefix, "-table-placeholder")).style.height = maxHeight;
|
|
308
|
+
}
|
|
299
309
|
});
|
|
300
310
|
watcher.current.observe(outContainerRef.current);
|
|
301
311
|
watcher.current.observe(extraHeaderContainerRef.current);
|
|
@@ -319,23 +329,7 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
319
329
|
(_watcher$current4 = watcher.current) === null || _watcher$current4 === void 0 || _watcher$current4.unobserve(paginationContainerRef.current);
|
|
320
330
|
}
|
|
321
331
|
};
|
|
322
|
-
}, [autoHeight]);
|
|
323
|
-
useEffect(function () {
|
|
324
|
-
if (!autoHeight) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
var tableHeaderDom;
|
|
328
|
-
if (showHeader) {
|
|
329
|
-
tableHeaderDom = tableRef.current.querySelector(".".concat(prefix, "-table-header"));
|
|
330
|
-
watcher.current.observe(tableHeaderDom);
|
|
331
|
-
}
|
|
332
|
-
return function () {
|
|
333
|
-
if (tableHeaderDom) {
|
|
334
|
-
var _watcher$current5;
|
|
335
|
-
(_watcher$current5 = watcher.current) === null || _watcher$current5 === void 0 || _watcher$current5.unobserve(tableHeaderDom);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
}, [showHeader, autoHeight]);
|
|
332
|
+
}, [autoHeight, finalDataSource, showHeader]);
|
|
339
333
|
var editMode = '';
|
|
340
334
|
columns.find(function (v) {
|
|
341
335
|
var _v$form;
|
|
@@ -414,39 +408,25 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
414
408
|
useEffect(function () {
|
|
415
409
|
resizeColsRef.current = tableColumn;
|
|
416
410
|
}, [tableColumn]);
|
|
417
|
-
|
|
411
|
+
var _pagination = useMemo(function () {
|
|
412
|
+
return pagination ? pagination : {};
|
|
413
|
+
}, [pagination]);
|
|
418
414
|
// 设置分页页码
|
|
419
415
|
useEffect(function () {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return newPageInfo;
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
}, [pagination]);
|
|
416
|
+
setPageInfo(function (prePageInfo) {
|
|
417
|
+
var newPageInfo = _objectSpread({}, prePageInfo);
|
|
418
|
+
if (_pagination.defaultCurrent) {
|
|
419
|
+
newPageInfo.current = _pagination.defaultCurrent;
|
|
420
|
+
}
|
|
421
|
+
if (_pagination.defaultPageSize) {
|
|
422
|
+
newPageInfo.pageSize = _pagination.defaultPageSize;
|
|
423
|
+
}
|
|
424
|
+
return newPageInfo;
|
|
425
|
+
});
|
|
426
|
+
}, [_pagination.defaultCurrent, _pagination.defaultPageSize]);
|
|
435
427
|
var _showCols = useMemo(function () {
|
|
436
428
|
return columnFilter.hasOwnProperty('showColumns') ? showColumns : showCols;
|
|
437
429
|
}, [showColumns, showCols]);
|
|
438
|
-
useEffect(function () {
|
|
439
|
-
if (!autoHeight) {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
var maxHeight = "".concat(scrollY, "px");
|
|
443
|
-
if (finalDataSource.length !== 0) {
|
|
444
|
-
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.height = maxHeight;
|
|
445
|
-
} else {
|
|
446
|
-
tableRef.current.querySelector(".".concat(prefix, "-table-body")).style.height = 'unset';
|
|
447
|
-
tableRef.current.querySelector(".".concat(prefix, "-table-placeholder")).style.height = maxHeight;
|
|
448
|
-
}
|
|
449
|
-
}, [scrollY, finalDataSource]);
|
|
450
430
|
|
|
451
431
|
// 表格滚动到底触发函数
|
|
452
432
|
useEffect(function () {
|
|
@@ -514,9 +494,9 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
514
494
|
return _showCols.includes(col.dataIndex);
|
|
515
495
|
});
|
|
516
496
|
};
|
|
517
|
-
var bodyScroll = autoHeight ? merge({
|
|
518
|
-
y:
|
|
519
|
-
}
|
|
497
|
+
var bodyScroll = autoHeight ? merge(scroll, {
|
|
498
|
+
y: 1
|
|
499
|
+
}) : scroll;
|
|
520
500
|
|
|
521
501
|
// 表格数据有children时点击展开的函数
|
|
522
502
|
var onExpand = function onExpand(expanded, record) {
|
|
@@ -657,14 +637,6 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
657
637
|
onShowSizeChange: onShowSizeChange,
|
|
658
638
|
size: size == 'small' ? 'small' : ''
|
|
659
639
|
});
|
|
660
|
-
// if (frontPagination) {
|
|
661
|
-
// return {
|
|
662
|
-
// ...common,
|
|
663
|
-
// current: pageInfo.current,
|
|
664
|
-
// pageSize: pageInfo.pageSize,
|
|
665
|
-
// total: dataSource.length,
|
|
666
|
-
// }
|
|
667
|
-
// }
|
|
668
640
|
return _objectSpread(_objectSpread({}, common), {}, {
|
|
669
641
|
current: current || pageInfo.current,
|
|
670
642
|
pageSize: pageSize || pageInfo.pageSize,
|
|
@@ -791,8 +763,7 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
791
763
|
})), /*#__PURE__*/React.createElement("div", {
|
|
792
764
|
className: "cw-table-wrapper-main",
|
|
793
765
|
style: {
|
|
794
|
-
|
|
795
|
-
height: autoHeight ? tableWrapperHeight : 'auto'
|
|
766
|
+
height: "auto"
|
|
796
767
|
},
|
|
797
768
|
ref: tableRef
|
|
798
769
|
}, /*#__PURE__*/React.createElement(EditableContext.Provider, {
|
|
@@ -828,14 +799,9 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
828
799
|
expandedRowRender: expandedRowRender,
|
|
829
800
|
loading: Boolean(loading)
|
|
830
801
|
}, rest)))))), /*#__PURE__*/React.createElement("div", {
|
|
831
|
-
className: classnames({
|
|
832
|
-
'cw-table-pagination-box':
|
|
833
|
-
|
|
834
|
-
})
|
|
835
|
-
// style={{
|
|
836
|
-
// padding: Object.keys(searchBar).length > 0 && '0 32px'
|
|
837
|
-
// }}
|
|
838
|
-
,
|
|
802
|
+
className: classnames("cw-table-pagination-box", {
|
|
803
|
+
'cw-table-pagination-box-none': !finalDataSource.length || !pagination
|
|
804
|
+
}),
|
|
839
805
|
ref: paginationContainerRef
|
|
840
806
|
}, /*#__PURE__*/React.createElement(_Pagination, getPaginationOption())));
|
|
841
807
|
};
|
|
@@ -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) {
|
package/lib/utils/index.js
CHANGED
|
@@ -91,19 +91,22 @@ export var formatMessage = function formatMessage(message) {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* 根据特定时区将时间戳转换为固定时间偏移量的时间对象
|
|
94
|
-
* @param {*} time
|
|
95
|
-
* @param {*}
|
|
96
|
-
* @
|
|
94
|
+
* @param {*} time - 时间参数,可以是时间戳、日期字符串或 moment 对象
|
|
95
|
+
* @param {*} defaultCountryCityCode - 默认时区代码,默认为本地时区(通过 moment.tz.guess() 自动检测)
|
|
96
|
+
* @param {*} countryCityCode - 自定义时区代码,用于覆盖默认时区
|
|
97
|
+
* @returns {moment.Moment} 返回转换为指定时区的 moment 对象
|
|
97
98
|
*/
|
|
98
|
-
export var
|
|
99
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
+
// 如果 localStorage 中没有找到时区信息,则使用默认时区(自动推测的本地时区)
|
|
105
|
+
var timezone = timeZoneData ? timeZoneData.countryCityCode : defaultCountryCityCode;
|
|
106
|
+
// 如果有传入的自定义时区代码,则使用自定义时区,否则使用从 localStorage 获取或推测的时区
|
|
104
107
|
var _timezone = countryCityCode ? countryCityCode : timezone;
|
|
105
|
-
//
|
|
106
|
-
return moment.tz(time, _timezone);
|
|
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.
|
|
3
|
+
"version": "2.6.8",
|
|
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": "
|
|
152
|
+
"gitHead": "9862a1d4a1f6556dd1fb953637e9bec805b4ea9a"
|
|
153
153
|
}
|