@zat-design/sisyphus-react 4.5.5 → 4.5.6-beta.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/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/FormsProvider/index.d.ts +18 -0
- package/es/ProAction/components/CheckModalContent/index.d.ts +8 -0
- package/es/ProAction/index.d.ts +7 -0
- package/es/ProAction/propsType.d.ts +45 -0
- package/es/ProConfigProvider/index.d.ts +9 -0
- package/es/ProConfigProvider/propsType.d.ts +82 -0
- package/es/ProDownload/index.d.ts +6 -0
- package/es/ProDownload/propsType.d.ts +71 -0
- package/es/ProDownload/utils.d.ts +60 -0
- package/es/ProDrawerForm/components/ProDrawer/index.d.ts +7 -0
- package/es/ProDrawerForm/components/ProModal/index.d.ts +7 -0
- package/es/ProDrawerForm/components/index.d.ts +2 -0
- package/es/ProDrawerForm/hooks/useConfirmClose.d.ts +24 -0
- package/es/ProDrawerForm/index.d.ts +6 -0
- package/es/ProDrawerForm/propsType.d.ts +111 -0
- package/es/ProDrawerForm/utils/index.d.ts +25 -0
- package/es/ProEditLabel/components/RenderProForm.d.ts +4 -0
- package/es/ProEditLabel/index.d.ts +4 -0
- package/es/ProEditLabel/propsType.d.ts +163 -0
- package/es/ProEditLabel/utils/index.d.ts +7 -0
- package/es/ProEditTable/components/ActionButton/index.d.ts +2 -0
- package/es/ProEditTable/components/RcTable/BaseTable.d.ts +5 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +7 -0
- package/es/ProEditTable/components/RcTable/index.d.ts +4 -0
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +4 -0
- package/es/ProEditTable/components/RenderField/index.d.ts +3 -0
- package/es/ProEditTable/components/RenderField/propsType.d.ts +30 -0
- package/es/ProEditTable/components/RenderField/tools.d.ts +22 -0
- package/es/ProEditTable/components/RenderToolbar/index.d.ts +2 -0
- package/es/ProEditTable/components/Summary/index.d.ts +12 -0
- package/es/ProEditTable/components/Validator/index.d.ts +18 -0
- package/es/ProEditTable/components/index.d.ts +5 -0
- package/es/ProEditTable/index.d.ts +4 -0
- package/es/ProEditTable/propsType.d.ts +437 -0
- package/es/ProEditTable/utils/config.d.ts +25 -0
- package/es/ProEditTable/utils/diffOriginal.d.ts +22 -0
- package/es/ProEditTable/utils/getDefaultProps.d.ts +1 -0
- package/es/ProEditTable/utils/index.d.ts +23 -0
- package/es/ProEditTable/utils/tools.d.ts +133 -0
- package/es/ProEditTable/utils/transform.d.ts +13 -0
- package/es/ProEditTable/utils/useEditTableError.d.ts +7 -0
- package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +16 -0
- package/es/ProEditTable/utils/validateAll.d.ts +89 -0
- package/es/ProEnum/components/Group.d.ts +10 -0
- package/es/ProEnum/components/Tag.d.ts +7 -0
- package/es/ProEnum/hooks/useEnum.d.ts +29 -0
- package/es/ProEnum/hooks/useEnumRequest.d.ts +4 -0
- package/es/ProEnum/hooks/useFrequentEnumRequest.d.ts +14 -0
- package/es/ProEnum/index.d.ts +10 -0
- package/es/ProEnum/index.js +1 -1
- package/es/ProEnum/propsType.d.ts +320 -0
- package/es/ProEnum/utils/eventCenter.d.ts +1 -0
- package/es/ProEnum/utils/frequentEnum.d.ts +39 -0
- package/es/ProEnum/utils/getEnum.d.ts +47 -0
- package/es/ProEnum/utils/getEnumLabel.d.ts +2 -0
- package/es/ProEnum/utils/index.d.ts +98 -0
- package/es/ProForm/components/Container.d.ts +9 -0
- package/es/ProForm/components/FormFooter/index.d.ts +5 -0
- package/es/ProForm/components/FormFooter/propsType.d.ts +21 -0
- package/es/ProForm/components/base/Checkbox/index.d.ts +14 -0
- package/es/ProForm/components/base/DatePicker/index.d.ts +11 -0
- package/es/ProForm/components/base/Input/index.d.ts +3 -0
- package/es/ProForm/components/base/Input/propsType.d.ts +21 -0
- package/es/ProForm/components/base/InputNumber/index.d.ts +11 -0
- package/es/ProForm/components/base/Radio/index.d.ts +15 -0
- package/es/ProForm/components/base/RangePicker/index.d.ts +19 -0
- package/es/ProForm/components/base/RangePicker/useDateRange.d.ts +15 -0
- package/es/ProForm/components/base/Select/index.d.ts +11 -0
- package/es/ProForm/components/base/Switch/index.d.ts +10 -0
- package/es/ProForm/components/base/SwitchCheckbox/index.d.ts +10 -0
- package/es/ProForm/components/base/TextArea/index.d.ts +11 -0
- package/es/ProForm/components/base/TimePicker/index.d.ts +13 -0
- package/es/ProForm/components/combination/Container/index.d.ts +4 -0
- package/es/ProForm/components/combination/Container/propsType.d.ts +13 -0
- package/es/ProForm/components/combination/FormList/components/ActionButton.d.ts +24 -0
- package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +23 -0
- package/es/ProForm/components/combination/FormList/components/Empty.d.ts +13 -0
- package/es/ProForm/components/combination/FormList/components/LineFields.d.ts +20 -0
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.d.ts +12 -0
- package/es/ProForm/components/combination/FormList/index.d.ts +4 -0
- package/es/ProForm/components/combination/FormList/propsType.d.ts +69 -0
- package/es/ProForm/components/combination/FormList/utils.d.ts +18 -0
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.d.ts +9 -0
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +28 -0
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.d.ts +10 -0
- package/es/ProForm/components/combination/Group/hooks/index.d.ts +34 -0
- package/es/ProForm/components/combination/Group/index.d.ts +9 -0
- package/es/ProForm/components/combination/Group/propsType.d.ts +99 -0
- package/es/ProForm/components/combination/Group/utils/index.d.ts +153 -0
- package/es/ProForm/components/combination/ProCascader/index.d.ts +3 -0
- package/es/ProForm/components/combination/ProCascader/propsType.d.ts +48 -0
- package/es/ProForm/components/combination/ProCascader/utils/index.d.ts +14 -0
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.d.ts +33 -0
- package/es/ProForm/components/combination/ProModalSelect/index.d.ts +4 -0
- package/es/ProForm/components/combination/ProModalSelect/propsType.d.ts +106 -0
- package/es/ProForm/components/combination/ProModalSelect/utils/index.d.ts +15 -0
- package/es/ProForm/components/combination/ProNumberRange/index.d.ts +3 -0
- package/es/ProForm/components/combination/ProNumberRange/propsType.d.ts +85 -0
- package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +4 -0
- package/es/ProForm/components/combination/ProRangeLimit/propsType.d.ts +23 -0
- package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.d.ts +8 -0
- package/es/ProForm/components/combination/ProTimeLimit/index.d.ts +33 -0
- package/es/ProForm/components/index.d.ts +29 -0
- package/es/ProForm/components/render/ChangedWrapper.d.ts +17 -0
- package/es/ProForm/components/render/ConfirmWrapper.d.ts +10 -0
- package/es/ProForm/components/render/CustomComponentViewWrapper.d.ts +30 -0
- package/es/ProForm/components/render/Render.d.ts +4 -0
- package/es/ProForm/components/render/RenderFields.d.ts +26 -0
- package/es/ProForm/components/render/propsType.d.ts +279 -0
- package/es/ProForm/hooks/useControlled.d.ts +1 -0
- package/es/ProForm/hooks/useDeepCompareMemo.d.ts +2 -0
- package/es/ProForm/hooks/useFieldProps.d.ts +4 -0
- package/es/ProForm/hooks/useForm.d.ts +8 -0
- package/es/ProForm/hooks/useRules.d.ts +16 -0
- package/es/ProForm/hooks/useShouldUpdate.d.ts +31 -0
- package/es/ProForm/hooks/useWatch.d.ts +22 -0
- package/es/ProForm/index.d.ts +6 -0
- package/es/ProForm/propsType.d.ts +143 -0
- package/es/ProForm/utils/buildFormItemProps.d.ts +25 -0
- package/es/ProForm/utils/diffOriginal.d.ts +10 -0
- package/es/ProForm/utils/getDefaultProps.d.ts +1 -0
- package/es/ProForm/utils/index.d.ts +109 -0
- package/es/ProForm/utils/processDependencies.d.ts +29 -0
- package/es/ProForm/utils/reactiveValues.d.ts +33 -0
- package/es/ProForm/utils/rulesCreator.d.ts +7 -0
- package/es/ProForm/utils/transformNames.d.ts +10 -0
- package/es/ProForm/utils/transformValue.d.ts +6 -0
- package/es/ProForm/utils/valueType.d.ts +70 -0
- package/es/ProIcon/config/index.d.ts +19 -0
- package/es/ProIcon/index.d.ts +4 -0
- package/es/ProIcon/propsTypes.d.ts +175 -0
- package/es/ProIcon/utils/index.d.ts +6 -0
- package/es/ProLayout/components/Layout/Header/index.d.ts +4 -0
- package/es/ProLayout/components/Layout/Menu/FoldMenu/index.d.ts +3 -0
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +3 -0
- package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.d.ts +15 -0
- package/es/ProLayout/components/Layout/Menu/SideMenu/index.d.ts +3 -0
- package/es/ProLayout/components/Layout/Menu/index.d.ts +4 -0
- package/es/ProLayout/components/Layout/Notice/index.d.ts +4 -0
- package/es/ProLayout/components/Layout/index.d.ts +3 -0
- package/es/ProLayout/components/ProCollapse/PropTypes.d.ts +98 -0
- package/es/ProLayout/components/ProCollapse/index.d.ts +3 -0
- package/es/ProLayout/components/ProFooter/PropTypes.d.ts +27 -0
- package/es/ProLayout/components/ProFooter/index.d.ts +3 -0
- package/es/ProLayout/components/ProHeader/PropTypes.d.ts +206 -0
- package/es/ProLayout/components/ProHeader/components/Copy/index.d.ts +4 -0
- package/es/ProLayout/components/ProHeader/components/Describe/index.d.ts +26 -0
- package/es/ProLayout/components/ProHeader/components/Describe/index.js +106 -0
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.d.ts +9 -0
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.d.ts +4 -0
- package/es/ProLayout/components/ProHeader/components/index.d.ts +2 -0
- package/es/ProLayout/components/ProHeader/index.d.ts +4 -0
- package/es/ProLayout/components/ProHeader/index.js +54 -118
- package/es/ProLayout/components/ProHeader/utils/index.d.ts +20 -0
- package/es/ProLayout/components/ProHeader/utils/index.js +23 -1
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +7 -0
- package/es/ProLayout/components/TabsManager/components/TabItem.d.ts +26 -0
- package/es/ProLayout/components/TabsManager/components/TabsContext.d.ts +5 -0
- package/es/ProLayout/components/TabsManager/components/TabsHeader.d.ts +10 -0
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.d.ts +6 -0
- package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.d.ts +25 -0
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.d.ts +18 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.d.ts +31 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.d.ts +5 -0
- package/es/ProLayout/components/TabsManager/index.d.ts +6 -0
- package/es/ProLayout/components/TabsManager/index.js +87 -3
- package/es/ProLayout/components/TabsManager/propTypes.d.ts +89 -0
- package/es/ProLayout/components/TabsManager/style/index.less +6 -3
- package/es/ProLayout/components/TabsManager/utils/index.d.ts +47 -0
- package/es/ProLayout/components/index.d.ts +3 -0
- package/es/ProLayout/index.d.ts +19 -0
- package/es/ProLayout/index.js +28 -10
- package/es/ProLayout/propTypes.d.ts +550 -0
- package/es/ProLayout/style/index.less +32 -0
- package/es/ProLayout/utils/index.d.ts +43 -0
- package/es/ProSelect/components/AdaptiveTooltip.d.ts +4 -0
- package/es/ProSelect/index.d.ts +5 -0
- package/es/ProSelect/propsType.d.ts +162 -0
- package/es/ProSelect/utils/index.d.ts +86 -0
- package/es/ProStep/components/Anchor/index.d.ts +4 -0
- package/es/ProStep/components/Item/index.d.ts +4 -0
- package/es/ProStep/components/LazyLoad/index.d.ts +19 -0
- package/es/ProStep/components/Listener/index.d.ts +4 -0
- package/es/ProStep/components/Step/index.d.ts +5 -0
- package/es/ProStep/index.d.ts +11 -0
- package/es/ProStep/propsType.d.ts +224 -0
- package/es/ProStep/utils/index.d.ts +22 -0
- package/es/ProStepTab/index.d.ts +22 -0
- package/es/ProStepTab/propsType.d.ts +114 -0
- package/es/ProTable/components/EditableCell/EditIcon.d.ts +6 -0
- package/es/ProTable/components/EditableCell/index.d.ts +4 -0
- package/es/ProTable/components/EditableCell/propsType.d.ts +24 -0
- package/es/ProTable/components/FormatColumn/index.d.ts +22 -0
- package/es/ProTable/components/FormatColumn/propsType.d.ts +29 -0
- package/es/ProTable/components/RcTable/components/BaseTable/index.d.ts +2 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +18 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.d.ts +8 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.d.ts +61 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/index.d.ts +2 -0
- package/es/ProTable/components/RcTable/index.d.ts +4 -0
- package/es/ProTable/components/RenderColumn/index.d.ts +22 -0
- package/es/ProTable/components/RenderEmptyText/index.d.ts +3 -0
- package/es/ProTable/components/RenderFooter/index.d.ts +2 -0
- package/es/ProTable/components/RenderSummary/index.d.ts +3 -0
- package/es/ProTable/components/RenderTableHeader/index.d.ts +2 -0
- package/es/ProTable/components/RenderTabs/index.d.ts +3 -0
- package/es/ProTable/components/TableResizable/index.d.ts +13 -0
- package/es/ProTable/components/TooltipTitle/index.d.ts +11 -0
- package/es/ProTable/components/index.d.ts +31 -0
- package/es/ProTable/hooks/useAntdTable.d.ts +7 -0
- package/es/ProTable/index.d.ts +17 -0
- package/es/ProTable/propsType.d.ts +805 -0
- package/es/ProTable/utils/columnStorage.d.ts +35 -0
- package/es/ProTable/utils/index.d.ts +52 -0
- package/es/ProTabs/components/Card/index.d.ts +3 -0
- package/es/ProTabs/components/index.d.ts +1 -0
- package/es/ProTabs/index.d.ts +4 -0
- package/es/ProTabs/propType.d.ts +94 -0
- package/es/ProThemeTools/component/ProTools/index.d.ts +3 -0
- package/es/ProThemeTools/component/index.d.ts +1 -0
- package/es/ProThemeTools/context/ThemeContext.d.ts +43 -0
- package/es/ProThemeTools/index.d.ts +9 -0
- package/es/ProThemeTools/propsType.d.ts +170 -0
- package/es/ProThemeTools/utils/index.d.ts +51 -0
- package/es/ProTooltip/index.d.ts +3 -0
- package/es/ProTooltip/propsType.d.ts +57 -0
- package/es/ProTree/components/AdaptiveTooltip.d.ts +4 -0
- package/es/ProTree/components/CloseIcon.d.ts +2 -0
- package/es/ProTree/components/List.d.ts +17 -0
- package/es/ProTree/components/ProTree.d.ts +3 -0
- package/es/ProTree/components/ProTreeSelect/index.d.ts +5 -0
- package/es/ProTree/components/ProTreeSelect/propsType.d.ts +445 -0
- package/es/ProTree/components/SearchTitle.d.ts +10 -0
- package/es/ProTree/components/Tree.d.ts +27 -0
- package/es/ProTree/components/index.d.ts +4 -0
- package/es/ProTree/index.d.ts +3 -0
- package/es/ProTree/propsType.d.ts +818 -0
- package/es/ProTree/utils.d.ts +62 -0
- package/es/ProTreeModal/components/Cascader.d.ts +14 -0
- package/es/ProTreeModal/components/CloseIcon.d.ts +2 -0
- package/es/ProTreeModal/components/List.d.ts +21 -0
- package/es/ProTreeModal/components/SearchTitle.d.ts +6 -0
- package/es/ProTreeModal/components/SortableItem.d.ts +12 -0
- package/es/ProTreeModal/components/Tree.d.ts +25 -0
- package/es/ProTreeModal/components/Trigger.d.ts +21 -0
- package/es/ProTreeModal/components/index.d.ts +6 -0
- package/es/ProTreeModal/index.d.ts +4 -0
- package/es/ProTreeModal/propsType.d.ts +298 -0
- package/es/ProTreeModal/utils.d.ts +39 -0
- package/es/ProUpload/components/ButtonRender.d.ts +20 -0
- package/es/ProUpload/components/DragRender.d.ts +21 -0
- package/es/ProUpload/components/DraggableUploadListItem.d.ts +2 -0
- package/es/ProUpload/components/Example.d.ts +10 -0
- package/es/ProUpload/components/FileItem.d.ts +33 -0
- package/es/ProUpload/components/ImageRender.d.ts +19 -0
- package/es/ProUpload/index.d.ts +4 -0
- package/es/ProUpload/propsType.d.ts +264 -0
- package/es/ProUpload/uitls.d.ts +3 -0
- package/es/ProUtils/utils/index.d.ts +6 -0
- package/es/ProViewer/index.d.ts +4 -0
- package/es/ProViewer/propsType.d.ts +37 -0
- package/es/ProWaterMark/index.d.ts +4 -0
- package/es/ProWaterMark/propsType.d.ts +6 -0
- package/es/hooks/useDraggableRow.d.ts +34 -0
- package/es/index.d.ts +57 -0
- package/es/index.js +0 -2
- package/es/locale/en_US.d.ts +176 -0
- package/es/locale/index.d.ts +15 -0
- package/es/locale/zh_CN.d.ts +176 -0
- package/es/tokens.d.ts +83 -0
- package/es/utils/index.d.ts +24 -0
- package/package.json +12 -2
|
@@ -7,26 +7,18 @@ import React, { memo, useEffect, useState, useRef } from 'react';
|
|
|
7
7
|
import { tools } from '@zat-design/utils';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
|
-
import { useToggle
|
|
10
|
+
import { useToggle } from 'ahooks';
|
|
11
11
|
import { ReactSVG } from 'react-svg';
|
|
12
12
|
import foldSvg from "../../../assets/arrow.svg";
|
|
13
13
|
import { Copy, ProBackBtn } from "./components";
|
|
14
|
+
import { DescribeItems, DescribeValue } from "./components/Describe";
|
|
14
15
|
import getEnumLabel from "../../../ProEnum/utils/getEnumLabel";
|
|
15
16
|
import locale from "../../../locale";
|
|
16
|
-
import {
|
|
17
|
+
import { toKeyPart, getDescribeColumnKey, getTagKey, getSubDescribeKey } from "./utils";
|
|
17
18
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
19
|
const {
|
|
19
20
|
formatAmount
|
|
20
21
|
} = tools;
|
|
21
|
-
const toKeyPart = value => {
|
|
22
|
-
if (value == null || value === '') return undefined;
|
|
23
|
-
if (typeof value === 'string' || typeof value === 'number') return String(value);
|
|
24
|
-
return undefined;
|
|
25
|
-
};
|
|
26
|
-
const getDescribeColumnKey = (item, index) => toKeyPart(item.label) ?? toKeyPart(item.value) ?? `describe-${index}`;
|
|
27
|
-
const getDescribeValueKey = (item, parentKey, index) => toKeyPart(item.link) ?? toKeyPart(item.value) ?? `${parentKey}-value-${index}`;
|
|
28
|
-
const getTagKey = (tagItem, parentKey, index) => toKeyPart(tagItem) ?? `${parentKey}-tag-${index}`;
|
|
29
|
-
const getSubDescribeKey = (item, index) => toKeyPart(item.label) ?? toKeyPart(item.code) ?? `sub-describe-${index}`;
|
|
30
22
|
const ProHeader = props => {
|
|
31
23
|
const {
|
|
32
24
|
breadcrumbColumns,
|
|
@@ -37,7 +29,6 @@ const ProHeader = props => {
|
|
|
37
29
|
className,
|
|
38
30
|
bodyOverFlowHidden = false,
|
|
39
31
|
fixedTop,
|
|
40
|
-
showBack = true,
|
|
41
32
|
showShadow = false,
|
|
42
33
|
zIndex = 98,
|
|
43
34
|
title,
|
|
@@ -47,19 +38,32 @@ const ProHeader = props => {
|
|
|
47
38
|
isConfirmBack = false,
|
|
48
39
|
isConfirmBackModalProps = {}
|
|
49
40
|
} = props;
|
|
50
|
-
|
|
41
|
+
|
|
42
|
+
// 返回按钮是否显示。
|
|
43
|
+
// 显式意图优先于 autoBack 启发式:
|
|
44
|
+
// 1) 用户显式传了 showBack → 完全尊重该值;
|
|
45
|
+
// 2) 传了 onBack(返回不依赖浏览器历史,如 tab 内返回 / 自定义跳转)→ 显示;
|
|
46
|
+
// 3) 都没传(纯默认,返回兜底走 window.history.back)→ 由 autoBack 按历史长度智能判断:
|
|
47
|
+
// 新开页面(history.length <= autoBack)无处可返回,则隐藏。
|
|
48
|
+
const computeBackState = () => {
|
|
49
|
+
if (props.showBack !== undefined) return props.showBack;
|
|
50
|
+
if (onBack) return true;
|
|
51
|
+
return window.history.length > autoBack;
|
|
52
|
+
};
|
|
53
|
+
const [backState, setBackState] = useState(computeBackState);
|
|
51
54
|
const [fold, {
|
|
52
55
|
toggle
|
|
53
56
|
}] = useToggle(collapsed);
|
|
54
57
|
const ref = useRef(null);
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
|
|
59
|
+
// 最终用于渲染的标题(title + showBack 时会被转成面包屑,此处置空)
|
|
60
|
+
let finalTitle = title;
|
|
57
61
|
|
|
58
62
|
// 面包屑配置数据源
|
|
59
|
-
const
|
|
63
|
+
const finalBreadcrumbColumns = breadcrumbColumns || [];
|
|
60
64
|
|
|
61
65
|
// 次级配置数据源
|
|
62
|
-
const
|
|
66
|
+
const finalSubDescribeColumns = subDescribeColumns || [];
|
|
63
67
|
useEffect(() => {
|
|
64
68
|
if (bodyOverFlowHidden) {
|
|
65
69
|
const bodyElement = document.querySelector('body');
|
|
@@ -70,13 +74,11 @@ const ProHeader = props => {
|
|
|
70
74
|
bodyElement.style.overflow = '';
|
|
71
75
|
};
|
|
72
76
|
}, [bodyOverFlowHidden]);
|
|
77
|
+
|
|
78
|
+
// showBack / onBack / autoBack 变化时同步 backState(避免 props 更新后按钮显隐不同步)
|
|
73
79
|
useEffect(() => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (isNewPage <= autoBack) {
|
|
77
|
-
setBackState(false);
|
|
78
|
-
}
|
|
79
|
-
}, []);
|
|
80
|
+
setBackState(computeBackState());
|
|
81
|
+
}, [props.showBack, onBack, autoBack]);
|
|
80
82
|
|
|
81
83
|
/**
|
|
82
84
|
* 主级描述数据渲染
|
|
@@ -108,82 +110,6 @@ const ProHeader = props => {
|
|
|
108
110
|
return null;
|
|
109
111
|
}
|
|
110
112
|
const onlyTag = tag && !label && !value;
|
|
111
|
-
const tagRender = params => {
|
|
112
|
-
if (Array.isArray(params?.tag) && params?.tag.length) {
|
|
113
|
-
return /*#__PURE__*/_jsx(Space, {
|
|
114
|
-
size: 4,
|
|
115
|
-
children: params.tag.map((tagItem, tagIndex) => {
|
|
116
|
-
return /*#__PURE__*/_jsx("div", {
|
|
117
|
-
className: "pro-header-tag",
|
|
118
|
-
children: tagItem
|
|
119
|
-
}, getTagKey(tagItem, describeItemKey, tagIndex));
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return params?.tag ? /*#__PURE__*/_jsx("div", {
|
|
124
|
-
className: "pro-header-tag",
|
|
125
|
-
children: params?.tag
|
|
126
|
-
}) : null;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/** 单行渲染 */
|
|
130
|
-
const valueRender = params => {
|
|
131
|
-
return /*#__PURE__*/_jsxs(Space, {
|
|
132
|
-
size: 4,
|
|
133
|
-
align: params?.tag ? 'baseline' : 'center',
|
|
134
|
-
children: [params?.link ? /*#__PURE__*/_jsx("a", {
|
|
135
|
-
onClick: () => {
|
|
136
|
-
const newWindow = window.open(params.link);
|
|
137
|
-
newWindow.opener = null;
|
|
138
|
-
},
|
|
139
|
-
children: params?.value
|
|
140
|
-
}) : params?.value, params?.copyable && _isString(params?.value) ? /*#__PURE__*/_jsx(Copy, {
|
|
141
|
-
text: params.value
|
|
142
|
-
}) : null, tagRender({
|
|
143
|
-
tag: params?.tag
|
|
144
|
-
})]
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/** 多行渲染 */
|
|
149
|
-
const itemsRender = () => {
|
|
150
|
-
// items配置是否超长,超长配置... + tip 提示
|
|
151
|
-
const itemsHidden = checkDescribeItemsHidden(ref?.current);
|
|
152
|
-
const result = /*#__PURE__*/_jsxs("div", {
|
|
153
|
-
ref: ref,
|
|
154
|
-
className: classnames({
|
|
155
|
-
'pro-header-describe-items': true,
|
|
156
|
-
'pro-header-describe-items-more': items.length >= 2
|
|
157
|
-
}),
|
|
158
|
-
children: [items?.length > 3 ? `共${items?.length}个,` : null, items.map((item, itemIndex) => {
|
|
159
|
-
return /*#__PURE__*/_jsxs("span", {
|
|
160
|
-
children: [valueRender(item), items?.length !== itemIndex + 1 ? ' 、' : null]
|
|
161
|
-
}, getDescribeValueKey(item, describeItemKey, itemIndex));
|
|
162
|
-
}), itemsHidden ? /*#__PURE__*/_jsx("span", {
|
|
163
|
-
className: "pro-header-describe-items-omit",
|
|
164
|
-
children: "..."
|
|
165
|
-
}) : null]
|
|
166
|
-
});
|
|
167
|
-
if (itemsHidden) {
|
|
168
|
-
const tipResult = /*#__PURE__*/_jsx(_Fragment, {
|
|
169
|
-
children: items.map((item, itemIndex) => {
|
|
170
|
-
return /*#__PURE__*/_jsx("p", {
|
|
171
|
-
className: "pro-header-describe-items-tip-value",
|
|
172
|
-
children: valueRender(item)
|
|
173
|
-
}, getDescribeValueKey(item, describeItemKey, itemIndex));
|
|
174
|
-
})
|
|
175
|
-
});
|
|
176
|
-
return /*#__PURE__*/_jsx(Tooltip, {
|
|
177
|
-
placement: "bottomLeft",
|
|
178
|
-
classNames: {
|
|
179
|
-
root: 'pro-header-describe-items-tip'
|
|
180
|
-
},
|
|
181
|
-
title: tipResult,
|
|
182
|
-
children: result
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
return result;
|
|
186
|
-
};
|
|
187
113
|
const tagCls = classnames({
|
|
188
114
|
'pro-header-only-tag': onlyTag,
|
|
189
115
|
'pro-header-describe-items-calc': _isString(width) ? width.includes('calc') : false
|
|
@@ -200,12 +126,17 @@ const ProHeader = props => {
|
|
|
200
126
|
children: label
|
|
201
127
|
}) : null, /*#__PURE__*/_jsx("span", {
|
|
202
128
|
className: "pro-header-describe-value",
|
|
203
|
-
children: items?.length ?
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
129
|
+
children: items?.length ? /*#__PURE__*/_jsx(DescribeItems, {
|
|
130
|
+
items: items,
|
|
131
|
+
parentKey: describeItemKey,
|
|
132
|
+
containerRef: ref
|
|
133
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
134
|
+
children: /*#__PURE__*/_jsx(DescribeValue, {
|
|
135
|
+
value: value,
|
|
136
|
+
copyable: copyable,
|
|
137
|
+
tag: tag,
|
|
138
|
+
link: link,
|
|
139
|
+
parentKey: describeItemKey
|
|
209
140
|
})
|
|
210
141
|
})
|
|
211
142
|
})]
|
|
@@ -302,10 +233,10 @@ const ProHeader = props => {
|
|
|
302
233
|
* 总结信息面板渲染
|
|
303
234
|
*/
|
|
304
235
|
const breadcrumbRender = () => {
|
|
305
|
-
if (Array.isArray(
|
|
236
|
+
if (Array.isArray(finalBreadcrumbColumns) && !finalBreadcrumbColumns.length) {
|
|
306
237
|
return [];
|
|
307
238
|
}
|
|
308
|
-
const list =
|
|
239
|
+
const list = finalBreadcrumbColumns?.filter(item => {
|
|
309
240
|
return item.type === 'breadcrumb';
|
|
310
241
|
});
|
|
311
242
|
return list.map((item, index) => {
|
|
@@ -355,10 +286,10 @@ const ProHeader = props => {
|
|
|
355
286
|
* 头部左侧导航栏后业务信息
|
|
356
287
|
*/
|
|
357
288
|
const infoRender = () => {
|
|
358
|
-
if (!Array.isArray(
|
|
289
|
+
if (!Array.isArray(finalBreadcrumbColumns)) {
|
|
359
290
|
return '';
|
|
360
291
|
}
|
|
361
|
-
const list =
|
|
292
|
+
const list = finalBreadcrumbColumns?.filter(item => {
|
|
362
293
|
return item.type !== 'breadcrumb';
|
|
363
294
|
});
|
|
364
295
|
if (!list.length) {
|
|
@@ -436,24 +367,29 @@ const ProHeader = props => {
|
|
|
436
367
|
})
|
|
437
368
|
});
|
|
438
369
|
};
|
|
370
|
+
|
|
371
|
+
// 说明:以下两个 class 的判断沿用原有等价逻辑(去掉了原表达式里对 describeColumns 的重复判断)。
|
|
372
|
+
// has = 有次级描述 或 有主级描述;no = 无主级描述。二者非严格互斥(原实现即如此,未改动其行为)。
|
|
373
|
+
const noDescribe = _isEmpty(describeColumns);
|
|
374
|
+
const hasDescribe = !_isEmpty(finalSubDescribeColumns) || !noDescribe;
|
|
439
375
|
const cls = classnames({
|
|
440
376
|
'pro-header': true,
|
|
441
377
|
'pro-header-fixed': fixedTop,
|
|
442
378
|
'pro-header-shadow': showShadow,
|
|
443
379
|
// 内部窗口滚动自带阴影场景
|
|
444
380
|
'pro-header-no-back': !backState,
|
|
445
|
-
'pro-header-has-describe':
|
|
446
|
-
'pro-header-no-describe':
|
|
381
|
+
'pro-header-has-describe': hasDescribe,
|
|
382
|
+
'pro-header-no-describe': noDescribe,
|
|
447
383
|
[`${className}`]: className
|
|
448
384
|
});
|
|
449
|
-
if (title && !_isEmpty(
|
|
385
|
+
if (title && !_isEmpty(finalBreadcrumbColumns)) {
|
|
450
386
|
console.error('warning: The title and the breadcrumbList cannot be used together');
|
|
451
387
|
}
|
|
452
388
|
|
|
453
389
|
// title默认不显示返回按钮,只有showBack设置为true时才显示
|
|
454
390
|
if (title && props.showBack) {
|
|
455
|
-
|
|
456
|
-
|
|
391
|
+
finalTitle = null;
|
|
392
|
+
finalBreadcrumbColumns.push({
|
|
457
393
|
type: 'breadcrumb',
|
|
458
394
|
value: title
|
|
459
395
|
});
|
|
@@ -492,9 +428,9 @@ const ProHeader = props => {
|
|
|
492
428
|
top: fixedTop,
|
|
493
429
|
zIndex
|
|
494
430
|
},
|
|
495
|
-
children:
|
|
431
|
+
children: finalTitle ? /*#__PURE__*/_jsx("div", {
|
|
496
432
|
className: "pro-header-title",
|
|
497
|
-
children:
|
|
433
|
+
children: finalTitle
|
|
498
434
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
499
435
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
500
436
|
className: "pro-header-top",
|
|
@@ -516,14 +452,14 @@ const ProHeader = props => {
|
|
|
516
452
|
className: "pro-header-right",
|
|
517
453
|
children: actionsRender()
|
|
518
454
|
})]
|
|
519
|
-
}), describeRender(describeColumns), !_isEmpty(
|
|
455
|
+
}), describeRender(describeColumns), !_isEmpty(finalSubDescribeColumns) ? /*#__PURE__*/_jsxs("div", {
|
|
520
456
|
className: classnames({
|
|
521
457
|
'pro-header-nav': true,
|
|
522
458
|
'pro-header-nav-open': fold,
|
|
523
459
|
'pro-header-nav-hidden': !fold
|
|
524
460
|
}),
|
|
525
461
|
children: [/*#__PURE__*/_jsx("ul", {
|
|
526
|
-
children:
|
|
462
|
+
children: finalSubDescribeColumns.map((item, index) => {
|
|
527
463
|
return /*#__PURE__*/_jsx("li", {
|
|
528
464
|
children: subDescribeRender(item)
|
|
529
465
|
}, getSubDescribeKey(item, index));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { DescribeColumnType, SubDescribeColumnType } from '../PropTypes';
|
|
3
|
+
/**
|
|
4
|
+
* 检查描述dom是否部分隐藏
|
|
5
|
+
* @param ele dom节点
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkDescribeItemsHidden: (ele?: any) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 将值转为可用于 React key 的字符串片段
|
|
10
|
+
* 仅 string / number 有效,其余(含 ReactNode、对象、数组、boolean)返回 undefined
|
|
11
|
+
*/
|
|
12
|
+
export declare const toKeyPart: (value: unknown) => string | undefined;
|
|
13
|
+
/** 主级描述项 key:label → value → describe-${index} */
|
|
14
|
+
export declare const getDescribeColumnKey: (item: DescribeColumnType, index: number) => string;
|
|
15
|
+
/** 描述值 key:link → value → ${parentKey}-value-${index} */
|
|
16
|
+
export declare const getDescribeValueKey: (item: Pick<DescribeColumnType, "tag" | "link" | "value" | "copyable">, parentKey: string, index: number) => string;
|
|
17
|
+
/** 标签 key:tagItem → ${parentKey}-tag-${index} */
|
|
18
|
+
export declare const getTagKey: (tagItem: string | React.ReactNode, parentKey: string, index: number) => string;
|
|
19
|
+
/** 次级描述项 key:label → code → sub-describe-${index} */
|
|
20
|
+
export declare const getSubDescribeKey: (item: SubDescribeColumnType, index: number) => string;
|
|
@@ -11,4 +11,26 @@ export const checkDescribeItemsHidden = ele => {
|
|
|
11
11
|
const itemsScrollWidth = element.scrollWidth;
|
|
12
12
|
const itemsClientWidth = element.clientWidth;
|
|
13
13
|
return itemsScrollWidth > itemsClientWidth;
|
|
14
|
-
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 将值转为可用于 React key 的字符串片段
|
|
18
|
+
* 仅 string / number 有效,其余(含 ReactNode、对象、数组、boolean)返回 undefined
|
|
19
|
+
*/
|
|
20
|
+
export const toKeyPart = value => {
|
|
21
|
+
if (value == null || value === '') return undefined;
|
|
22
|
+
if (typeof value === 'string' || typeof value === 'number') return String(value);
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** 主级描述项 key:label → value → describe-${index} */
|
|
27
|
+
export const getDescribeColumnKey = (item, index) => toKeyPart(item.label) ?? toKeyPart(item.value) ?? `describe-${index}`;
|
|
28
|
+
|
|
29
|
+
/** 描述值 key:link → value → ${parentKey}-value-${index} */
|
|
30
|
+
export const getDescribeValueKey = (item, parentKey, index) => toKeyPart(item.link) ?? toKeyPart(item.value) ?? `${parentKey}-value-${index}`;
|
|
31
|
+
|
|
32
|
+
/** 标签 key:tagItem → ${parentKey}-tag-${index} */
|
|
33
|
+
export const getTagKey = (tagItem, parentKey, index) => toKeyPart(tagItem) ?? `${parentKey}-tag-${index}`;
|
|
34
|
+
|
|
35
|
+
/** 次级描述项 key:label → code → sub-describe-${index} */
|
|
36
|
+
export const getSubDescribeKey = (item, index) => toKeyPart(item.label) ?? toKeyPart(item.code) ?? `sub-describe-${index}`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TabContextMenuProps } from '../propTypes';
|
|
2
|
+
/**
|
|
3
|
+
* 右键菜单组件 - 兼容Antd 4.x和5.x
|
|
4
|
+
*/
|
|
5
|
+
declare function TabContextMenu({ tabId, children, closable, onClose, onCloseOthers, onCloseRight, onCloseAll, menuItems: customMenuItems, tabMenuClick, tab, tabs, }: TabContextMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default TabContextMenu;
|
|
7
|
+
export { TabContextMenu };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabItem } from '../../../propTypes';
|
|
3
|
+
interface TabItemComponentProps {
|
|
4
|
+
tab: TabItem;
|
|
5
|
+
active: boolean;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onCloseOthers: () => void;
|
|
9
|
+
onCloseRight: () => void;
|
|
10
|
+
onCloseAll: () => void;
|
|
11
|
+
/** 所有标签页列表 */
|
|
12
|
+
tabsList?: TabItem[];
|
|
13
|
+
/** 自定义菜单项 */
|
|
14
|
+
menuItems?: import('antd').MenuProps['items'];
|
|
15
|
+
/** 自定义菜单项点击回调 */
|
|
16
|
+
tabMenuClick?: (params: {
|
|
17
|
+
key: string;
|
|
18
|
+
tab: TabItem;
|
|
19
|
+
tabs: TabItem[];
|
|
20
|
+
}) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 单个标签页组件
|
|
24
|
+
*/
|
|
25
|
+
declare const TabItemComponent: React.FC<TabItemComponentProps>;
|
|
26
|
+
export { TabItemComponent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TabsProps } from 'antd';
|
|
2
|
+
export interface TabsHeaderProps {
|
|
3
|
+
activeKey: string | undefined;
|
|
4
|
+
tabsItems: TabsProps['items'];
|
|
5
|
+
onTabChange: (activeKey: string) => void;
|
|
6
|
+
onTabEdit: (targetKey: string, action: 'add' | 'remove') => void;
|
|
7
|
+
draggable?: boolean;
|
|
8
|
+
onReorder?: (activeId: string, overId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function TabsHeader({ activeKey, tabsItems, onTabChange, onTabEdit, draggable, onReorder, }: TabsHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IframeConfig } from '../../../propTypes';
|
|
2
|
+
export interface UseIframeRouteOptions {
|
|
3
|
+
/** iframe 嵌入配置 */
|
|
4
|
+
config: IframeConfig | undefined;
|
|
5
|
+
/** 命中路由后调用的 addTab(由外部 tabsInstance.addTab 注入) */
|
|
6
|
+
addTab: (params: {
|
|
7
|
+
code: string;
|
|
8
|
+
name: string;
|
|
9
|
+
extra?: Record<string, any>;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface UseIframeRouteReturn {
|
|
13
|
+
/** 当前是否处于 iframe 嵌入环境(通过 URL query `?isIframe` 判定,大小写不敏感) */
|
|
14
|
+
isIframe: boolean;
|
|
15
|
+
/** 是否启用纯净渲染(隐藏 Header/Menu/TabsBar);非 iframe 或未配置 iframe 时始终为 false */
|
|
16
|
+
pure: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* iframe 嵌入模式 hook
|
|
20
|
+
* - 通过 URL query `?isIframe`(大小写不敏感)判定是否处于 iframe 嵌入场景
|
|
21
|
+
* - 命中时按 routes 静态路径匹配 window.location.pathname,调用 addTab
|
|
22
|
+
* - query string 自动作为 extra 透传给业务组件
|
|
23
|
+
* - 暴露 pure 标志供外部 layout 决定渲染范围
|
|
24
|
+
*/
|
|
25
|
+
export declare const useIframeRoute: (options: UseIframeRouteOptions) => UseIframeRouteReturn;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProLayoutTabsInstance } from '../../../propTypes';
|
|
2
|
+
/**
|
|
3
|
+
* @description 获取 ProLayout 标签页实例的 Hook(类似 Form.useForm)
|
|
4
|
+
* @returns [ProLayoutTabsInstance] 标签页实例
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* // 在 ProLayout children 中使用
|
|
8
|
+
* const [layoutTabs] = useProLayoutTabs();
|
|
9
|
+
*
|
|
10
|
+
* // 使用实例方法
|
|
11
|
+
* layoutTabs.addTab({
|
|
12
|
+
* code: 'PolicyInput',
|
|
13
|
+
* name: '投保单录入',
|
|
14
|
+
* extra: { customData: '自定义数据' }
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useProLayoutTabs(): [ProLayoutTabsInstance];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TabsState } from '../../../propTypes';
|
|
2
|
+
import { TabsCacheManager } from '../propTypes';
|
|
3
|
+
/**
|
|
4
|
+
* 简化的标签页缓存管理器
|
|
5
|
+
*/
|
|
6
|
+
declare class SimpleTabsCache implements TabsCacheManager {
|
|
7
|
+
private cacheKey;
|
|
8
|
+
private storage;
|
|
9
|
+
constructor(keyPrefix: string, strategy: 'localStorage' | 'sessionStorage');
|
|
10
|
+
/** 保存标签页状态 */
|
|
11
|
+
save(state: TabsState): void;
|
|
12
|
+
/** 恢复标签页状态 */
|
|
13
|
+
restore(): TabsState | null;
|
|
14
|
+
/** 清空缓存 */
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
interface UseTabsCacheOptions {
|
|
18
|
+
cacheKey: string;
|
|
19
|
+
storage: 'localStorage' | 'sessionStorage';
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 标签页缓存管理Hook
|
|
24
|
+
*/
|
|
25
|
+
export declare const useTabsCache: (options: UseTabsCacheOptions) => {
|
|
26
|
+
saveToCache: (state: TabsState) => void;
|
|
27
|
+
restoreFromCache: () => TabsState | null;
|
|
28
|
+
clearCache: () => void;
|
|
29
|
+
cacheManager: SimpleTabsCache;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -85,6 +85,68 @@ const TabsManager = /*#__PURE__*/forwardRef(({
|
|
|
85
85
|
}
|
|
86
86
|
}, [state.activeKey]);
|
|
87
87
|
|
|
88
|
+
// tab 内子视图栈:按 tabId 隔离。栈底→栈顶顺序,入口页不在其中。
|
|
89
|
+
// 只活在内存、不进缓存(详情/工作流是运行态 ReactNode,无法 JSON 序列化)。
|
|
90
|
+
const [viewStacks, setViewStacks] = useState({});
|
|
91
|
+
|
|
92
|
+
// 用 ref 持有 activeKey,供稳定的 pushView/back 读取当前激活 tab,避免因 activeKey 变化重建实例
|
|
93
|
+
const activeKeyRef = useRef(state.activeKey);
|
|
94
|
+
activeKeyRef.current = state.activeKey;
|
|
95
|
+
|
|
96
|
+
// 同步持有最新 viewStacks,使 getViewStack 成为稳定引用且读取不受渲染时序影响
|
|
97
|
+
const viewStacksRef = useRef(viewStacks);
|
|
98
|
+
viewStacksRef.current = viewStacks;
|
|
99
|
+
|
|
100
|
+
// 在当前激活 tab 内压入一层子视图(入口页/下层随之隐藏但不卸载)
|
|
101
|
+
const pushView = useCallback(node => {
|
|
102
|
+
const tabId = activeKeyRef.current;
|
|
103
|
+
if (!tabId) return;
|
|
104
|
+
setViewStacks(prev => ({
|
|
105
|
+
...prev,
|
|
106
|
+
[tabId]: [...(prev[tabId] || []), node]
|
|
107
|
+
}));
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
// 返回:销毁当前激活 tab 的栈顶子视图(栈空时 no-op)
|
|
111
|
+
const back = useCallback(() => {
|
|
112
|
+
const tabId = activeKeyRef.current;
|
|
113
|
+
if (!tabId) return;
|
|
114
|
+
setViewStacks(prev => {
|
|
115
|
+
const stack = prev[tabId];
|
|
116
|
+
if (!stack || stack.length === 0) return prev;
|
|
117
|
+
const nextStack = stack.slice(0, -1);
|
|
118
|
+
const next = {
|
|
119
|
+
...prev
|
|
120
|
+
};
|
|
121
|
+
if (nextStack.length === 0) {
|
|
122
|
+
delete next[tabId];
|
|
123
|
+
} else {
|
|
124
|
+
next[tabId] = nextStack;
|
|
125
|
+
}
|
|
126
|
+
return next;
|
|
127
|
+
});
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
// 获取当前激活 tab 的子视图栈(从 ref 读最新值,稳定引用)
|
|
131
|
+
const getViewStack = useCallback(() => viewStacksRef.current[activeKeyRef.current] || [], []);
|
|
132
|
+
|
|
133
|
+
// 子视图栈与 tabsList 对账:任何关闭路径(removeTab / closeOthers / closeRight /
|
|
134
|
+
// closeAll)导致某 tab 消失后,清除其残留子视图栈,避免关闭后 node 仍驻留内存。
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
setViewStacks(prev => {
|
|
137
|
+
const keys = Object.keys(prev);
|
|
138
|
+
if (keys.length === 0) return prev;
|
|
139
|
+
const aliveIds = new Set(state.tabsList.map(tab => tab.id));
|
|
140
|
+
const staleKeys = keys.filter(id => !aliveIds.has(id));
|
|
141
|
+
if (staleKeys.length === 0) return prev;
|
|
142
|
+
const next = {
|
|
143
|
+
...prev
|
|
144
|
+
};
|
|
145
|
+
staleKeys.forEach(id => delete next[id]);
|
|
146
|
+
return next;
|
|
147
|
+
});
|
|
148
|
+
}, [state.tabsList]);
|
|
149
|
+
|
|
88
150
|
// 通知父级(ProLayout)当前是否有 Tab
|
|
89
151
|
useEffect(() => {
|
|
90
152
|
onTabsChange?.(state.tabsList.length > 0);
|
|
@@ -169,8 +231,11 @@ const TabsManager = /*#__PURE__*/forwardRef(({
|
|
|
169
231
|
tabsList: state.tabsList,
|
|
170
232
|
activeTabInfo: state.tabsList.find(tab => tab.id === state.activeKey),
|
|
171
233
|
activeComponent: state.activeComponent
|
|
172
|
-
})
|
|
173
|
-
|
|
234
|
+
}),
|
|
235
|
+
pushView,
|
|
236
|
+
back,
|
|
237
|
+
getViewStack
|
|
238
|
+
}), [addTab, removeTab, updateTab, state.tabsList, state.activeKey, state.activeComponent, dataSource, pushView, back, getViewStack]);
|
|
174
239
|
const handleTabChange = useCallback(activeKey => {
|
|
175
240
|
switchTab(activeKey);
|
|
176
241
|
}, [switchTab]);
|
|
@@ -227,11 +292,30 @@ const TabsManager = /*#__PURE__*/forwardRef(({
|
|
|
227
292
|
});
|
|
228
293
|
}
|
|
229
294
|
}
|
|
295
|
+
|
|
296
|
+
// 该 tab 的子视图栈:栈底→栈顶。只有「当前激活 tab 的栈顶层」可见,
|
|
297
|
+
// 入口页与下层子视图 display:none 但保持挂载 → 返回秒回、状态不丢。
|
|
298
|
+
const stack = viewStacks[tab.id] || [];
|
|
299
|
+
// 入口页可见条件:该 tab 激活 且 无子视图
|
|
300
|
+
const entryVisible = isActive && stack.length === 0;
|
|
230
301
|
return /*#__PURE__*/_jsx("div", {
|
|
231
|
-
className: `tab-pane ${
|
|
302
|
+
className: `tab-pane ${entryVisible ? '' : 'hidden'}`,
|
|
232
303
|
"data-testid": `tab-pane-${tab.id}`,
|
|
233
304
|
children: content
|
|
234
305
|
}, tab.id);
|
|
306
|
+
}), state.tabsList.map(tab => {
|
|
307
|
+
const isActive = tab.id === state.activeKey;
|
|
308
|
+
const stack = viewStacks[tab.id] || [];
|
|
309
|
+
if (stack.length === 0) return null;
|
|
310
|
+
const topIndex = stack.length - 1;
|
|
311
|
+
return stack.map((node, index) => {
|
|
312
|
+
const layerVisible = isActive && index === topIndex;
|
|
313
|
+
return /*#__PURE__*/_jsx("div", {
|
|
314
|
+
className: `tab-pane ${layerVisible ? '' : 'hidden'}`,
|
|
315
|
+
"data-testid": `tab-subview-${tab.id}-${index}`,
|
|
316
|
+
children: node
|
|
317
|
+
}, `${tab.id}-subview-${index}`);
|
|
318
|
+
});
|
|
235
319
|
}), state.tabsList.length === 0 && /*#__PURE__*/_jsx("div", {
|
|
236
320
|
className: "tab-pane",
|
|
237
321
|
"data-testid": "default-content",
|