Skip to content

Commit c699800

Browse files
committed
chore: 移除不再使用的 coverToNewToken 函数及相关依赖,更新文档以反映 antd 版本要求
1 parent 87e0838 commit c699800

21 files changed

+174
-402
lines changed

demos/layout/[email protected]

Lines changed: 0 additions & 67 deletions
This file was deleted.

docs/components/form/FieldSet/index.en-US.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,6 @@ ProFormMoney's input box for entering amounts supports the display of currency s
641641

642642
### ProFormSegmented
643643

644-
> Ant Design version needs to be >= antd\@4.20.0."
645-
646644
Same as [Segmented](https://ant.design/components/segmented-cn/). Supports both `request` and `valueEnum` methods to generate options.
647645

648646
> Requesting remote data is more complicated, see [here](https://procomponents.ant.design/components/schema#request-%E5%92%8C-params) for details.

docs/components/form/FieldSet/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,6 @@ ProFormMoney 用于输入金额的输入框,支持根据全局国际化显示
649649

650650
### ProFormSegmented
651651

652-
> antd 版本需要 >= antd\@4.20.0
653-
654652
[Segmented](https://ant.design/components/segmented-cn/) 相同。支持了 request 和 valueEnum 两种方式来生成 options。
655653

656654
> 请求远程数据比较复杂,详细可以看[这里](https://procomponents.ant.design/components/schema#request-%E5%92%8C-params)

src/card/components/TabPane/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { TabPaneProps, TabsProps } from 'antd';
2-
import { ConfigProvider, version } from 'antd';
2+
import { ConfigProvider } from 'antd';
33
import toArray from 'rc-util/lib/Children/toArray';
44
import { noteOnce } from 'rc-util/lib/warning';
55
import React, { useContext } from 'react';
@@ -51,13 +51,8 @@ export function useLegacyItems(
5151
*/
5252
const TabPane: React.FC<ProCardTabPaneProps> = (props) => {
5353
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
54-
// 如果是antd v5 则返回为空
55-
if (version.startsWith('5')) {
56-
return <></>;
57-
} else {
58-
// 兼容性提示,直接返回 null
59-
return null;
60-
}
54+
// 已废弃的组件,直接返回空
55+
return <></>;
6156
};
6257

6358
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {

src/layout/ProLayout.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import useSWR, { useSWRConfig } from 'swr';
1919
import type { GenerateStyle, ProTokenType } from '../provider';
2020
import { ProConfigProvider, ProProvider, isNeedOpenHash } from '../provider';
2121
import {
22-
coverToNewToken,
2322
isBrowser,
2423
useBreakpoint,
2524
useDocumentTitle,
@@ -797,42 +796,42 @@ const BaseProLayout: React.FC<ProLayoutProps> = (props) => {
797796
token.layout?.sider?.menuHeight || token?.controlHeightLG,
798797
},
799798
components: {
800-
Menu: coverToNewToken({
799+
Menu: {
801800
colorItemBg:
802801
token.layout?.sider?.colorMenuBackground || 'transparent',
803802
colorSubItemBg:
804803
token.layout?.sider?.colorMenuBackground || 'transparent',
805-
radiusItem: token.borderRadius,
804+
itemBorderRadius: token.borderRadius,
806805

807-
colorItemBgSelected:
806+
itemSelectedBg:
808807
token.layout?.sider?.colorBgMenuItemSelected ||
809808
token?.colorBgTextHover,
810-
colorItemBgHover:
809+
itemHoverBg:
811810
token.layout?.sider?.colorBgMenuItemHover ||
812811
token?.colorBgTextHover,
813-
colorItemBgActive:
812+
itemActiveBg:
814813
token.layout?.sider?.colorBgMenuItemActive ||
815814
token?.colorBgTextActive,
816-
colorItemBgSelectedHorizontal:
815+
horizontalItemSelectedBg:
817816
token.layout?.sider?.colorBgMenuItemSelected ||
818817
token?.colorBgTextHover,
819-
colorActiveBarWidth: 0,
820-
colorActiveBarHeight: 0,
821-
colorActiveBarBorderSize: 0,
822-
colorItemText:
818+
activeBarWidth: 0,
819+
activeBarHeight: 0,
820+
activeBarBorderWidth: 0,
821+
itemColor:
823822
token.layout?.sider?.colorTextMenu ||
824823
token?.colorTextSecondary,
825-
colorItemTextHover:
824+
itemHoverColor:
826825
token.layout?.sider?.colorTextMenuItemHover ||
827826
'rgba(0, 0, 0, 0.85)', // 悬浮态
828-
colorItemTextSelected:
827+
itemSelectedColor:
829828
token.layout?.sider?.colorTextMenuSelected ||
830829
'rgba(0, 0, 0, 1)',
831830
popupBg: token?.colorBgElevated,
832831
subMenuItemBg: token?.colorBgElevated,
833832
darkSubMenuItemBg: 'transparent',
834833
darkPopupBg: token?.colorBgElevated,
835-
}),
834+
},
836835
},
837836
}}
838837
>

src/layout/components/Help/ProHelpPanel.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Card, ConfigProvider, Menu } from 'antd';
33
import useMergedState from 'rc-util/lib/hooks/useMergedState';
44
import React, { useContext, useMemo, useState } from 'react';
55
import { ProProvider, isNeedOpenHash } from '../../../provider';
6-
import { coverToNewToken } from '../../../utils';
6+
77
import type { ProHelpDataSource } from './HelpProvide';
88
import { ProHelpProvide } from './HelpProvide';
99
import { ProHelpContentPanel } from './ProHelpContentPanel';
@@ -234,30 +234,30 @@ export const ProHelpPanel: React.FC<ProHelpPanelProps> = ({
234234
controlHeightLG: 26,
235235
},
236236
components: {
237-
Menu: coverToNewToken({
238-
radiusItem: token.borderRadius,
239-
colorActiveBarWidth: 0,
240-
colorActiveBarBorderSize: 0,
241-
colorItemBgSelected:
237+
Menu: {
238+
itemBorderRadius: token.borderRadius,
239+
activeBarWidth: 0,
240+
activeBarBorderWidth: 0,
241+
itemSelectedBg:
242242
token.layout?.sider?.colorBgMenuItemSelected ||
243243
'rgba(0, 0, 0, 0.04)',
244-
colorItemBgActive:
244+
itemActiveBg:
245245
token.layout?.sider?.colorBgMenuItemHover ||
246246
'rgba(0, 0, 0, 0.04)',
247-
colorItemText:
247+
itemColor:
248248
token.layout?.sider?.colorTextMenu ||
249249
'rgba(0, 0, 0, 0.65)',
250-
colorItemTextHover:
250+
itemHoverColor:
251251
token.layout?.sider?.colorTextMenuActive ||
252252
'rgba(0, 0, 0, 0.85)',
253-
colorItemTextSelected:
253+
itemSelectedColor:
254254
token.layout?.sider?.colorTextMenuSelected ||
255255
'rgba(0, 0, 0, 1)',
256-
colorItemBg: 'transparent',
257-
colorSubItemBg: 'transparent',
256+
itemBg: 'transparent',
257+
subMenuItemBg: 'transparent',
258258
popupBg: token?.colorBgElevated,
259259
darkPopupBg: token?.colorBgElevated,
260-
}),
260+
},
261261
},
262262
}}
263263
>

src/layout/components/SiderMenu/SiderMenu.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AvatarProps, SiderProps } from 'antd';
2-
import { Avatar, Layout, Menu, Space, version } from 'antd';
2+
import { Avatar, Layout, Menu, Space } from 'antd';
33
import classNames from 'classnames';
44
import type { CSSProperties, FC, ReactNode } from 'react';
55
import React, { useContext, useMemo } from 'react';
@@ -17,12 +17,6 @@ import { useStylish } from './style/stylish';
1717

1818
const _SafetyWarningProvider: FC<{ children: ReactNode }> = React.memo(
1919
(props) => {
20-
if (process.env.NODE_ENV !== 'production') {
21-
console.warn(
22-
`[pro-layout] SiderMenu required antd@^5.11.2 for access the menu context, please upgrade your antd version (current ${version}).`,
23-
);
24-
}
25-
2620
return <>{props.children}</>;
2721
},
2822
);

src/layout/components/TopNavHeader/index.tsx

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ConfigProvider } from 'antd';
22
import classNames from 'classnames';
33
import React, { useContext, useMemo, useRef } from 'react';
44
import { isNeedOpenHash, ProProvider } from '../../../provider';
5-
import { coverToNewToken } from '../../../utils';
5+
66
import { AppsLogoComponents } from '../AppsLogoComponents';
77
import type { GlobalHeaderProps } from '../GlobalHeader';
88
import { ActionsContent } from '../GlobalHeader/ActionsContent';
@@ -62,47 +62,40 @@ const TopNavHeader: React.FC<TopNavHeaderProps> = (
6262
bodyBg: 'transparent',
6363
},
6464
Menu: {
65-
...coverToNewToken({
66-
colorItemBg:
67-
token.layout?.header?.colorBgHeader || 'transparent',
68-
colorSubItemBg:
69-
token.layout?.header?.colorBgHeader || 'transparent',
70-
radiusItem: token.borderRadius,
71-
colorItemBgSelected:
72-
token.layout?.header?.colorBgMenuItemSelected ||
73-
token?.colorBgTextHover,
74-
itemHoverBg:
75-
token.layout?.header?.colorBgMenuItemHover ||
76-
token?.colorBgTextHover,
77-
colorItemBgSelectedHorizontal:
78-
token.layout?.header?.colorBgMenuItemSelected ||
79-
token?.colorBgTextHover,
80-
colorActiveBarWidth: 0,
81-
colorActiveBarHeight: 0,
82-
colorActiveBarBorderSize: 0,
83-
colorItemText:
84-
token.layout?.header?.colorTextMenu ||
85-
token?.colorTextSecondary,
86-
colorItemTextHoverHorizontal:
87-
token.layout?.header?.colorTextMenuActive || token?.colorText,
88-
colorItemTextSelectedHorizontal:
89-
token.layout?.header?.colorTextMenuSelected ||
90-
token?.colorTextBase,
91-
horizontalItemBorderRadius: 4,
92-
colorItemTextHover:
93-
token.layout?.header?.colorTextMenuActive ||
94-
'rgba(0, 0, 0, 0.85)',
95-
horizontalItemHoverBg:
96-
token.layout?.header?.colorBgMenuItemHover ||
97-
'rgba(0, 0, 0, 0.04)',
98-
colorItemTextSelected:
99-
token.layout?.header?.colorTextMenuSelected ||
100-
'rgba(0, 0, 0, 1)',
101-
popupBg: token?.colorBgElevated,
102-
subMenuItemBg: token?.colorBgElevated,
103-
darkSubMenuItemBg: 'transparent',
104-
darkPopupBg: token?.colorBgElevated,
105-
}),
65+
itemBg: token.layout?.header?.colorBgHeader || 'transparent',
66+
subMenuItemBg:
67+
token.layout?.header?.colorBgHeader || 'transparent',
68+
itemBorderRadius: token.borderRadius,
69+
itemSelectedBg:
70+
token.layout?.header?.colorBgMenuItemSelected ||
71+
token?.colorBgTextHover,
72+
horizontalItemSelectedBg:
73+
token.layout?.header?.colorBgMenuItemSelected ||
74+
token?.colorBgTextHover,
75+
activeBarWidth: 0,
76+
activeBarHeight: 0,
77+
activeBarBorderWidth: 0,
78+
itemColor:
79+
token.layout?.header?.colorTextMenu ||
80+
token?.colorTextSecondary,
81+
horizontalItemHoverColor:
82+
token.layout?.header?.colorTextMenuActive || token?.colorText,
83+
horizontalItemSelectedColor:
84+
token.layout?.header?.colorTextMenuSelected ||
85+
token?.colorTextBase,
86+
horizontalItemBorderRadius: 4,
87+
itemHoverColor:
88+
token.layout?.header?.colorTextMenuActive ||
89+
'rgba(0, 0, 0, 0.85)',
90+
horizontalItemHoverBg:
91+
token.layout?.header?.colorBgMenuItemHover ||
92+
'rgba(0, 0, 0, 0.04)',
93+
itemSelectedColor:
94+
token.layout?.header?.colorTextMenuSelected ||
95+
'rgba(0, 0, 0, 1)',
96+
popupBg: token?.colorBgElevated,
97+
darkSubMenuItemBg: 'transparent',
98+
darkPopupBg: token?.colorBgElevated,
10699
},
107100
},
108101
token: {

src/provider/useStyle/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const operationUnit = (token: ProAliasToken): CSSObject => ({
8787
});
8888

8989
/**
90-
* 封装了一下 antd 的 useStyle,支持了一下antd@4
90+
* 封装了一下 antd 的 useStyle
9191
* @param componentName {string} 组件的名字
9292
* @param styleFn {GenerateStyle} 生成样式的函数
9393
* @returns UseStyleResult

src/utils/compareVersions/coverToNewToken.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)