@bit-sun/business-component 4.2.0-alpha.6.9 → 4.2.5-per-alpha.2
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.
- package/.umirc.ts +14 -10
- package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
- package/dist/components/Business/BsLayouts/index.d.ts +1 -1
- package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +19 -8
- package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +9 -17
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
- package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
- package/dist/components/Business/CommonAlert/index.d.ts +1 -2
- package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
- package/dist/components/Business/DetailPageWrapper/index.d.ts +11 -12
- package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
- package/dist/components/Business/ItemPropertySelector/index.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
- package/dist/components/Business/PropertyModal/index.d.ts +1 -2
- package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Business/StateFlow/index.d.ts +1 -2
- package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +6 -6
- package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
- package/dist/components/Business/columnSettingTable/index.d.ts +3 -3
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +3 -3
- package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
- package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
- package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
- package/dist/components/Common/Section/index.d.ts +1 -1
- package/dist/components/Functional/AddSelect/index.d.ts +1 -2
- package/dist/components/Functional/AuthButton/index.d.ts +1 -2
- package/dist/components/Functional/DataImport/index.d.ts +4 -4
- package/dist/components/Functional/DataValidation/index.d.ts +5 -5
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
- package/dist/components/Functional/QueryMutipleInput/index.d.ts +1 -2
- package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
- package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
- package/dist/components/Functional/SearchSelect/utils.d.ts +2 -3
- package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
- package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +2203 -1852
- package/dist/index.js +2196 -1847
- package/dist/plugin/TableColumnSetting/index.d.ts +5 -5
- package/dist/utils/TableUtils.d.ts +18 -19
- package/dist/utils/luckysheetLoader.d.ts +21 -0
- package/dist/utils/utils.d.ts +0 -41
- package/package.json +1 -1
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +94 -25
- package/src/components/Business/BsLayouts/index.tsx +235 -129
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +144 -4
- package/src/components/Business/BsSulaQueryTable/index.md +120 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +241 -24
- package/src/components/Business/BsSulaQueryTable/setting.tsx +232 -17
- package/src/components/Business/DetailPageWrapper/index.tsx +30 -27
- package/src/components/Business/HomePageWrapper/index.tsx +10 -8
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +38 -234
- package/src/components/Business/columnSettingTable/index.tsx +6 -7
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +22 -23
- package/src/components/Functional/AddSelect/index.tsx +0 -92
- package/src/components/Functional/DataImport/index.tsx +76 -3
- package/src/components/Functional/DataValidation/index.tsx +81 -3
- package/src/components/Functional/SearchSelect/index.tsx +2 -5
- package/src/components/Solution/RuleComponent/index.js +0 -1
- package/src/index.ts +0 -2
- package/src/utils/luckysheetLoader.ts +164 -0
- package/src/utils/utils.ts +1 -41
- package/dist/components/Business/SystemLog/index.d.ts +0 -78
- package/src/components/Business/SystemLog/index.md +0 -37
- package/src/components/Business/SystemLog/index.tsx +0 -87
|
@@ -36,17 +36,28 @@ const SortableItem = SortableElement((props) => <tr {...props} />);
|
|
|
36
36
|
const SortableBody = SortableContainer((props) => <tbody {...props} />);
|
|
37
37
|
|
|
38
38
|
class SortableTable extends React.Component {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
constructor(props) {
|
|
40
|
+
super(props);
|
|
41
|
+
this.state = {
|
|
42
|
+
dataSource: [],
|
|
43
|
+
columns: [],
|
|
44
|
+
sortDataSource: [],
|
|
45
|
+
visible: false, // 修正: setVisible -> visible
|
|
46
|
+
searchDataSource: '',
|
|
47
|
+
onSearchSort: '',
|
|
48
|
+
isDefaultValue: false,
|
|
49
|
+
defaultValue: [],
|
|
50
|
+
bsTableCode: '', //设置table 列的标识
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// 实例变量
|
|
54
|
+
this.isUnmounted = false;
|
|
55
|
+
this.requestController = null;
|
|
56
|
+
this.debounceTimer = null;
|
|
57
|
+
|
|
58
|
+
// Modal组件ref,用于直接访问DOM进行清理
|
|
59
|
+
this.modalRef = React.createRef();
|
|
60
|
+
}
|
|
50
61
|
|
|
51
62
|
patchUserColumnConfig = (config: any, tableCode: any) => {
|
|
52
63
|
const { appRequestConfig } = this.props;
|
|
@@ -77,6 +88,9 @@ class SortableTable extends React.Component {
|
|
|
77
88
|
message.error('保存表头列自定义失败,请稍后尝试');
|
|
78
89
|
reject('');
|
|
79
90
|
}
|
|
91
|
+
}).catch(error => {
|
|
92
|
+
console.error('[SortableTable] 请求失败:', error);
|
|
93
|
+
reject(error);
|
|
80
94
|
});
|
|
81
95
|
});
|
|
82
96
|
};
|
|
@@ -162,7 +176,6 @@ class SortableTable extends React.Component {
|
|
|
162
176
|
|
|
163
177
|
componentWillReceiveProps(nextProps: any) {
|
|
164
178
|
if (this.isColumnsChange(this.props?.datasource, nextProps?.datasource)) {
|
|
165
|
-
//this.setInitValue(nextProps?.datasource || []);
|
|
166
179
|
this.validateLocalStorageConfig(nextProps?.datasource, nextProps?.bsTableCode);
|
|
167
180
|
}
|
|
168
181
|
}
|
|
@@ -270,8 +283,145 @@ class SortableTable extends React.Component {
|
|
|
270
283
|
})),
|
|
271
284
|
bsTableCode,
|
|
272
285
|
});
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
componentWillUnmount() {
|
|
290
|
+
console.log('[SortableTable] 组件即将卸载,开始清理资源');
|
|
291
|
+
|
|
292
|
+
// 设置卸载标志,防止异步操作
|
|
293
|
+
this.isUnmounted = true;
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
// 1. 取消请求
|
|
297
|
+
if (this.requestController) {
|
|
298
|
+
try {
|
|
299
|
+
console.log('[SortableTable] 取消进行中的请求');
|
|
300
|
+
this.requestController.abort();
|
|
301
|
+
this.requestController = null;
|
|
302
|
+
} catch (abortError) {
|
|
303
|
+
console.warn('[SortableTable] 取消请求时出错:', abortError);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// 2. 清理定时器
|
|
308
|
+
if (this.debounceTimer) {
|
|
309
|
+
clearTimeout(this.debounceTimer);
|
|
310
|
+
this.debounceTimer = null;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 3. 清理Modal相关引用
|
|
314
|
+
if (this.state.visible) {
|
|
315
|
+
this.setState({ visible: false });
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 4. 清理事件处理器引用 - 重点修复外部触发按钮的内存泄漏
|
|
319
|
+
// 将所有事件处理器方法设为null,断开React事件委托的引用
|
|
320
|
+
this.showModal = null;
|
|
321
|
+
this.handleShowModal = null;
|
|
322
|
+
this.handleOk = null;
|
|
323
|
+
this.handleCancel = null;
|
|
324
|
+
this.handleReset = null;
|
|
325
|
+
this.handleResetSetting = null;
|
|
326
|
+
this.onChange = null;
|
|
327
|
+
this.onSearch = null;
|
|
328
|
+
this.onSearchSort = null;
|
|
329
|
+
this.handleTableHeadHidden = null;
|
|
330
|
+
this.patchUserColumnConfig = null;
|
|
331
|
+
this.setInitValue = null;
|
|
332
|
+
|
|
333
|
+
// 5. 强制清理react-sortable-hoc组件的Fiber引用
|
|
334
|
+
if (this.DraggableContainer) {
|
|
335
|
+
// 清理SortableContainer的内部引用
|
|
336
|
+
try {
|
|
337
|
+
if (this.DraggableContainer._reactInternalFiber) {
|
|
338
|
+
this.DraggableContainer._reactInternalFiber = null;
|
|
339
|
+
}
|
|
340
|
+
if (this.DraggableContainer._reactInternalInstance) {
|
|
341
|
+
this.DraggableContainer._reactInternalInstance = null;
|
|
342
|
+
}
|
|
343
|
+
} catch (e) {
|
|
344
|
+
// 忽略清理失败
|
|
345
|
+
}
|
|
346
|
+
this.DraggableContainer = null;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (this.DraggableBodyRow) {
|
|
350
|
+
// 清理SortableElement的内部引用
|
|
351
|
+
try {
|
|
352
|
+
if (this.DraggableBodyRow._reactInternalFiber) {
|
|
353
|
+
this.DraggableBodyRow._reactInternalFiber = null;
|
|
354
|
+
}
|
|
355
|
+
if (this.DraggableBodyRow._reactInternalInstance) {
|
|
356
|
+
this.DraggableBodyRow._reactInternalInstance = null;
|
|
357
|
+
}
|
|
358
|
+
} catch (e) {
|
|
359
|
+
// 忽略清理失败
|
|
360
|
+
}
|
|
361
|
+
this.DraggableBodyRow = null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// 清理columns引用
|
|
365
|
+
if (this.columns) {
|
|
366
|
+
this.columns.forEach(col => {
|
|
367
|
+
if (col && typeof col === 'object') {
|
|
368
|
+
Object.keys(col).forEach(key => {
|
|
369
|
+
if (typeof col[key] === 'function') {
|
|
370
|
+
col[key] = null;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
this.columns = null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// 6. 清理Modal ref和DOM引用
|
|
379
|
+
if (this.modalRef && this.modalRef.current) {
|
|
380
|
+
try {
|
|
381
|
+
const modalElement = this.modalRef.current;
|
|
382
|
+
// 清理Modal DOM节点的React引用
|
|
383
|
+
const reactKeys = Object.keys(modalElement).filter(key =>
|
|
384
|
+
key.startsWith('__reactInternalInstance') ||
|
|
385
|
+
key.startsWith('__reactEventHandlers') ||
|
|
386
|
+
key.startsWith('_reactInternalFiber')
|
|
387
|
+
);
|
|
388
|
+
reactKeys.forEach(key => {
|
|
389
|
+
try {
|
|
390
|
+
delete modalElement[key];
|
|
391
|
+
} catch (e) {
|
|
392
|
+
// 忽略删除失败
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// 清理Fiber节点引用
|
|
397
|
+
if (modalElement._reactInternalFiber) {
|
|
398
|
+
modalElement._reactInternalFiber = null;
|
|
399
|
+
}
|
|
400
|
+
if (modalElement._reactInternalInstance) {
|
|
401
|
+
modalElement._reactInternalInstance = null;
|
|
402
|
+
}
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.warn('[SortableTable] Modal ref清理失败:', error);
|
|
405
|
+
}
|
|
406
|
+
this.modalRef.current = null;
|
|
407
|
+
}
|
|
408
|
+
this.modalRef = null;
|
|
409
|
+
|
|
410
|
+
// 7. 清理状态引用
|
|
411
|
+
this.state = null;
|
|
412
|
+
|
|
413
|
+
// 8. 防止组件卸载后的setState调用
|
|
414
|
+
this.setState = () => {
|
|
415
|
+
console.warn('[SortableTable] 组件已卸载,忽略setState调用');
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
console.log('[SortableTable] 组件清理完成,__reactEventHandlers引用已断开');
|
|
419
|
+
} catch (error) {
|
|
420
|
+
console.warn('[SortableTable] 组件清理失败:', error);
|
|
421
|
+
}
|
|
273
422
|
}
|
|
274
423
|
|
|
424
|
+
|
|
275
425
|
columns = [
|
|
276
426
|
{
|
|
277
427
|
title: '列名称',
|
|
@@ -499,6 +649,7 @@ class SortableTable extends React.Component {
|
|
|
499
649
|
];
|
|
500
650
|
|
|
501
651
|
showModal = () => {
|
|
652
|
+
if (this.isUnmounted) return;
|
|
502
653
|
this.setState({
|
|
503
654
|
visible: true,
|
|
504
655
|
onSearchSort: false
|
|
@@ -506,7 +657,15 @@ class SortableTable extends React.Component {
|
|
|
506
657
|
this.setInitValue();
|
|
507
658
|
};
|
|
508
659
|
|
|
660
|
+
handleShowModal = () => {
|
|
661
|
+
if (this.isUnmounted) return;
|
|
662
|
+
if (this.showModal) {
|
|
663
|
+
this.showModal();
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
509
667
|
handleOk = (e?: React.MouseEvent<HTMLElement>) => {
|
|
668
|
+
if (this.isUnmounted) return;
|
|
510
669
|
const { sortDataSource, isDefaultValue, defaultValue } = this.state;
|
|
511
670
|
if (!sortDataSource.length) {
|
|
512
671
|
message.warning('至少选择一列!');
|
|
@@ -520,8 +679,11 @@ class SortableTable extends React.Component {
|
|
|
520
679
|
};
|
|
521
680
|
|
|
522
681
|
handleCancel = (e: React.MouseEvent<HTMLElement>) => {
|
|
682
|
+
if (this.isUnmounted) return;
|
|
523
683
|
this.setState({
|
|
524
684
|
visible: false,
|
|
685
|
+
searchDataSource: '',
|
|
686
|
+
onSearchSort: '',
|
|
525
687
|
});
|
|
526
688
|
};
|
|
527
689
|
|
|
@@ -592,6 +754,7 @@ class SortableTable extends React.Component {
|
|
|
592
754
|
|
|
593
755
|
|
|
594
756
|
onChange = (e: CheckboxChangeEvent, title) => {
|
|
757
|
+
if (this.isUnmounted) return;
|
|
595
758
|
const { sortDataSource, dataSource } = this.state;
|
|
596
759
|
|
|
597
760
|
if (!e.target.checked) {
|
|
@@ -700,21 +863,28 @@ class SortableTable extends React.Component {
|
|
|
700
863
|
this.setState({
|
|
701
864
|
visible: false,
|
|
702
865
|
});
|
|
866
|
+
resolve({ status: '0' });
|
|
703
867
|
} else {
|
|
704
868
|
message.error('重置表头列自定义失败,请稍后尝试');
|
|
705
869
|
reject('');
|
|
706
870
|
}
|
|
871
|
+
}).catch(error => {
|
|
872
|
+
console.error('[SortableTable] 重置请求失败:', error);
|
|
873
|
+
message.error('重置表头列自定义失败,请稍后尝试');
|
|
874
|
+
reject(error);
|
|
707
875
|
});
|
|
708
876
|
})
|
|
709
877
|
};
|
|
710
878
|
|
|
711
879
|
onSearch = (e: any) => {
|
|
880
|
+
if (this.isUnmounted) return;
|
|
712
881
|
this.setState({
|
|
713
882
|
searchDataSource: e.target.value,
|
|
714
883
|
});
|
|
715
884
|
};
|
|
716
885
|
|
|
717
886
|
onSearchSort = (e: any) => {
|
|
887
|
+
if (this.isUnmounted) return;
|
|
718
888
|
this.setState({
|
|
719
889
|
onSearchSort: e.target.value,
|
|
720
890
|
});
|
|
@@ -737,15 +907,60 @@ class SortableTable extends React.Component {
|
|
|
737
907
|
);
|
|
738
908
|
|
|
739
909
|
return (
|
|
740
|
-
<div className={'sort_table_wrapper'}>
|
|
910
|
+
<div data="bssulaquerysettingdiv" className={'sort_table_wrapper'}>
|
|
741
911
|
{visible && (
|
|
742
912
|
<Modal
|
|
913
|
+
ref={this.modalRef}
|
|
743
914
|
title="展示列设置"
|
|
744
915
|
wrapClassName={'sort_table_wrapper'}
|
|
745
916
|
width={810}
|
|
746
917
|
visible={visible}
|
|
747
918
|
onOk={this.handleOk}
|
|
748
919
|
onCancel={this.handleCancel}
|
|
920
|
+
destroyOnClose={true}
|
|
921
|
+
afterClose={() => {
|
|
922
|
+
if (this.isUnmounted) return;
|
|
923
|
+
|
|
924
|
+
// 清理Modal相关的状态和引用
|
|
925
|
+
this.setState({
|
|
926
|
+
searchDataSource: '',
|
|
927
|
+
onSearchSort: '',
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
// 强制清理React Fiber节点和DOM引用
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
try {
|
|
933
|
+
// 清理所有带有sort_table类名的DOM节点的React引用
|
|
934
|
+
const sortTableElements = document.querySelectorAll('.sort_table, .sort_table_column_wrapper, .sort_table_column, .sort_table_content_wrapper, .sort_table_column_count');
|
|
935
|
+
sortTableElements.forEach(element => {
|
|
936
|
+
// 清理React内部实例引用
|
|
937
|
+
const reactKeys = Object.keys(element).filter(key => key.startsWith('__reactInternalInstance') || key.startsWith('__reactEventHandlers'));
|
|
938
|
+
reactKeys.forEach(key => {
|
|
939
|
+
try {
|
|
940
|
+
delete element[key];
|
|
941
|
+
} catch (e) {
|
|
942
|
+
// 忽略删除失败
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
// 清理React Fiber引用
|
|
947
|
+
if (element._reactInternalFiber) {
|
|
948
|
+
element._reactInternalFiber = null;
|
|
949
|
+
}
|
|
950
|
+
if (element._reactInternalInstance) {
|
|
951
|
+
element._reactInternalInstance = null;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
// 强制垃圾回收提示
|
|
956
|
+
if (window.gc) {
|
|
957
|
+
window.gc();
|
|
958
|
+
}
|
|
959
|
+
} catch (error) {
|
|
960
|
+
console.warn('[SortableTable] Modal afterClose清理失败:', error);
|
|
961
|
+
}
|
|
962
|
+
}, 100);
|
|
963
|
+
}}
|
|
749
964
|
footer={[
|
|
750
965
|
<div>
|
|
751
966
|
<Button
|
|
@@ -955,13 +1170,13 @@ class SortableTable extends React.Component {
|
|
|
955
1170
|
</Modal>
|
|
956
1171
|
)}
|
|
957
1172
|
{
|
|
958
|
-
!onlyModal
|
|
959
|
-
? <div onClick={this.
|
|
960
|
-
:
|
|
1173
|
+
!onlyModal && !this.isUnmounted
|
|
1174
|
+
? <div onClick={this.handleShowModal} style={{fontSize:14}}>列设置</div>
|
|
1175
|
+
: null
|
|
961
1176
|
}
|
|
962
1177
|
</div>
|
|
963
1178
|
);
|
|
964
1179
|
}
|
|
965
1180
|
}
|
|
966
1181
|
|
|
967
|
-
export default SortableTable;
|
|
1182
|
+
export default SortableTable;
|
|
@@ -92,14 +92,16 @@ const DetailWrapper = React.memo(
|
|
|
92
92
|
|
|
93
93
|
const basePath = window.top == window ? '' : `/${itemPath}`;
|
|
94
94
|
|
|
95
|
-
const menuRoutes =
|
|
96
|
-
window.top == window
|
|
95
|
+
const menuRoutes = useMemo(() => {
|
|
96
|
+
return window.top == window
|
|
97
97
|
? routes.find((item) => item.path === '/')?.routes || []
|
|
98
98
|
: JSON.parse(localStorage.getItem(getLimitMenuDataKey()) || '[]');
|
|
99
|
+
}, [routes, itemPath]);
|
|
99
100
|
|
|
100
|
-
const breadcrumbNameMap =
|
|
101
|
-
memoizeOneFormatter(menuRoutes, '')
|
|
102
|
-
);
|
|
101
|
+
const breadcrumbNameMap = useMemo(() => {
|
|
102
|
+
return getMainCrumbNameMap(memoizeOneFormatter(menuRoutes, ''));
|
|
103
|
+
}, [menuRoutes]); // 只有menuRoutes变化时才重新创建
|
|
104
|
+
|
|
103
105
|
const matchParamsPath = (pathname: string, breadcrumbNameMap: object) => {
|
|
104
106
|
const pathKey: any = Object.keys(breadcrumbNameMap).find((key) =>
|
|
105
107
|
pathToRegexp ? pathToRegexp(key).test(pathname) : false,
|
|
@@ -107,7 +109,7 @@ const DetailWrapper = React.memo(
|
|
|
107
109
|
return pathKey ? breadcrumbNameMap[pathKey] : undefined;
|
|
108
110
|
};
|
|
109
111
|
|
|
110
|
-
const
|
|
112
|
+
const { pageTitle, breadcrumbArrs } = useMemo(() => {
|
|
111
113
|
const { hideRouteArray = [] } = localStorage.getItem(getCommonInfoKey()) && JSON.parse(localStorage.getItem(getCommonInfoKey())) || {};
|
|
112
114
|
const currRouterData = matchParamsPath(
|
|
113
115
|
`${basePath}${pathname}`,
|
|
@@ -115,7 +117,7 @@ const DetailWrapper = React.memo(
|
|
|
115
117
|
) || getDetailMatchRoute(`${basePath}${pathname}`,breadcrumbNameMap,hideRouteArray, { pathToRegexp });
|
|
116
118
|
|
|
117
119
|
if (!currRouterData) {
|
|
118
|
-
return '';
|
|
120
|
+
return { pageTitle: '', breadcrumbArrs: [] };
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
let breadcrumbArrs = currRouterData.nameMap || [];
|
|
@@ -134,9 +136,7 @@ const DetailWrapper = React.memo(
|
|
|
134
136
|
breadcrumbNameMap,
|
|
135
137
|
);
|
|
136
138
|
|
|
137
|
-
if(
|
|
138
|
-
|
|
139
|
-
if(breadcrumbArrs.length >= 2) {
|
|
139
|
+
if(parentRoute && breadcrumbArrs.length >= 2) {
|
|
140
140
|
breadcrumbArrs.splice(-1, 0, {
|
|
141
141
|
title: parentRoute.name,
|
|
142
142
|
path: result[1]
|
|
@@ -144,21 +144,24 @@ const DetailWrapper = React.memo(
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
setBreadCrumbArr([...breadcrumbArrs]);
|
|
148
|
-
|
|
149
147
|
const pageName = formatMessage({
|
|
150
148
|
id: currRouterData.locale || currRouterData.name,
|
|
151
149
|
defaultMessage: currRouterData.name,
|
|
152
150
|
});
|
|
153
151
|
|
|
154
|
-
|
|
152
|
+
const pageTitle = title
|
|
155
153
|
? title
|
|
156
154
|
: window.top === window
|
|
157
155
|
? pageName
|
|
158
156
|
: `${currRouterData.name}`;
|
|
159
|
-
};
|
|
160
157
|
|
|
161
|
-
|
|
158
|
+
return { pageTitle, breadcrumbArrs: [...breadcrumbArrs] };
|
|
159
|
+
}, [pathname, title, breadcrumbNameMap, basePath, pathToRegexp]);
|
|
160
|
+
|
|
161
|
+
// 使用useEffect来更新breadcrumbArr状态,避免在渲染过程中直接调用setState
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
setBreadCrumbArr(breadcrumbArrs);
|
|
164
|
+
}, [breadcrumbArrs]);
|
|
162
165
|
|
|
163
166
|
useEffect(() => {}, []);
|
|
164
167
|
|
|
@@ -195,11 +198,11 @@ const DetailWrapper = React.memo(
|
|
|
195
198
|
}
|
|
196
199
|
};
|
|
197
200
|
|
|
198
|
-
const
|
|
201
|
+
const renderedActionList = useMemo(() => {
|
|
199
202
|
const authButton = localStorage.getItem(getMenuAuthDataKey())
|
|
200
203
|
? JSON.parse(localStorage.getItem(getMenuAuthDataKey()) as string)
|
|
201
204
|
: [];
|
|
202
|
-
let visibleActions =
|
|
205
|
+
let visibleActions = actionList.filter(
|
|
203
206
|
(action) =>
|
|
204
207
|
((action.visible && action.visible !== 'false') || judgeIsEmpty(action.visible)) &&
|
|
205
208
|
(!shouldUseAuth() || (judgeIsEmpty(action.code) || authButton.filter(item => item === action.code))),
|
|
@@ -228,7 +231,7 @@ const DetailWrapper = React.memo(
|
|
|
228
231
|
};
|
|
229
232
|
|
|
230
233
|
// 可在actionList第一项设置visibleActionCount,控制按钮几个开始显示更多,默认为3个
|
|
231
|
-
if (visibleActions.length <= (
|
|
234
|
+
if (visibleActions.length <= (actionList?.[0]?.visibleActionCount || 3)) {
|
|
232
235
|
return visibleActions.map((item) => {
|
|
233
236
|
return renderButton(item);
|
|
234
237
|
});
|
|
@@ -258,7 +261,7 @@ const DetailWrapper = React.memo(
|
|
|
258
261
|
</Dropdown>
|
|
259
262
|
</div>
|
|
260
263
|
);
|
|
261
|
-
};
|
|
264
|
+
}, [actionList]);
|
|
262
265
|
|
|
263
266
|
return (
|
|
264
267
|
<div ref={wrapperContainerRef} className='bs_detail_page_head_wrapper'>
|
|
@@ -280,11 +283,11 @@ const DetailWrapper = React.memo(
|
|
|
280
283
|
<div className={'detail_page_title_box'}>
|
|
281
284
|
{/* <div className={'detail_page_title'}>{pageTitle}</div> */}
|
|
282
285
|
<Breadcrumb>
|
|
283
|
-
{
|
|
286
|
+
{breadcrumbArrs.map((item, index) => {
|
|
284
287
|
return <Breadcrumb.Item
|
|
285
288
|
key={item}
|
|
286
289
|
>
|
|
287
|
-
<span className={`${index ===
|
|
290
|
+
<span className={`${index === breadcrumbArrs.length - 1 ? 'bread_name_last' : ''} bread_name`} >
|
|
288
291
|
{typeof item == 'object' ? <span className='bread_name_pre' onClick={()=> {
|
|
289
292
|
history.push({
|
|
290
293
|
pathname: item.path
|
|
@@ -299,7 +302,7 @@ const DetailWrapper = React.memo(
|
|
|
299
302
|
className={'detail_page_btns'}
|
|
300
303
|
style={{ marginRight: '20px', display: 'flex', gap: '8px' }}
|
|
301
304
|
>
|
|
302
|
-
{
|
|
305
|
+
{renderedActionList}
|
|
303
306
|
{
|
|
304
307
|
!donotNeedShowScreenIcon ? ( <a>
|
|
305
308
|
{isFullScreen ? (
|
|
@@ -340,11 +343,11 @@ const DetailWrapper = React.memo(
|
|
|
340
343
|
);
|
|
341
344
|
},
|
|
342
345
|
(prevProps, nextProps) => {
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
) {
|
|
346
|
-
|
|
347
|
-
}
|
|
346
|
+
// if (
|
|
347
|
+
// (JSON.stringify(prevProps.actionList) != JSON.stringify(nextProps.actionList)) || prevProps.pathname !== nextProps.pathname
|
|
348
|
+
// ) {
|
|
349
|
+
// return false;
|
|
350
|
+
// }
|
|
348
351
|
return true;
|
|
349
352
|
},
|
|
350
353
|
);
|
|
@@ -38,14 +38,16 @@ const HeaderWrapper = React.memo(
|
|
|
38
38
|
}: { pathname: string, routes: any[], itemPath: string, alertProps: any }) => {
|
|
39
39
|
const [breadcrumbArr, setBreadCrumbArr]: any = useState([]);
|
|
40
40
|
const basePath = window.top == window ? '' : `/${itemPath}`;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
const menuRoutes = useMemo(() => {
|
|
43
|
+
return window.top == window
|
|
43
44
|
? routes.find((item) => item.path === '/')?.routes || []
|
|
44
45
|
: JSON.parse(localStorage.getItem(getLimitMenuDataKey()) || '[]');
|
|
46
|
+
}, [routes, itemPath]);
|
|
45
47
|
|
|
46
|
-
const breadcrumbNameMap =
|
|
47
|
-
memoizeOneFormatter(menuRoutes, '')
|
|
48
|
-
);
|
|
48
|
+
const breadcrumbNameMap = useMemo(() => {
|
|
49
|
+
return getMainCrumbNameMap(memoizeOneFormatter(menuRoutes, ''));
|
|
50
|
+
}, [menuRoutes]); // 只有menuRoutes变化时才重新创建
|
|
49
51
|
|
|
50
52
|
const matchParamsPath = (pathname: string, breadcrumbNameMap: object) => {
|
|
51
53
|
const pathKey: any = Object.keys(breadcrumbNameMap).find((key) =>
|
|
@@ -122,9 +124,9 @@ const HeaderWrapper = React.memo(
|
|
|
122
124
|
);
|
|
123
125
|
},
|
|
124
126
|
(prevProps, nextProps) => {
|
|
125
|
-
if (prevProps.
|
|
126
|
-
|
|
127
|
-
}
|
|
127
|
+
// if (prevProps.pathname !== nextProps.pathname) {
|
|
128
|
+
// return false;
|
|
129
|
+
// }
|
|
128
130
|
return true;
|
|
129
131
|
},
|
|
130
132
|
);
|