Skip to content

Commit

Permalink
refactor: fix antd deprecated property
Browse files Browse the repository at this point in the history
  • Loading branch information
d3george authored and d3george committed Oct 15, 2024
1 parent e5ced4f commit 3991bcd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/layouts/_common/bread-crumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Breadcrumb } from 'antd';
import { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
import { Breadcrumb, type BreadcrumbProps, type GetProp } from 'antd';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useMatches, Link } from 'react-router-dom';
Expand All @@ -10,13 +9,15 @@ import { menuFilter } from '@/router/utils';

import { AppRouteObject } from '#/router';

type MenuItem = GetProp<BreadcrumbProps, 'items'>[number];

/**
* 动态面包屑解决方案:https://github.com/MinjieChang/myblog/issues/29
*/
export default function BreadCrumb() {
const { t } = useTranslation();
const matches = useMatches();
const [breadCrumbs, setBreadCrumbs] = useState<ItemType[]>([]);
const [breadCrumbs, setBreadCrumbs] = useState<MenuItem[]>([]);

const flattenedRoutes = useFlattenedRoutes();
const permissionRoutes = usePermissionRoutes();
Expand All @@ -33,7 +34,7 @@ export default function BreadCrumb() {
items = items!
.find((item) => item.meta?.key === key)
?.children?.filter((item) => !item.meta?.hideMenu);
const result: ItemType = {
const result: MenuItem = {
key,
title: t(label),
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/management/user/profile/projects-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function ProjectsTab() {
<ProTag color="warning">{item.deadline.diff(dayjs(), 'day')} days left</ProTag>
</div>
<div className="flex w-full ">
<Avatar.Group maxCount={4}>
<Avatar.Group max={{ count: 4 }}>
{item.members.map((memberAvatar, index) => (
<Avatar src={memberAvatar} key={index} />
))}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/management/user/profile/teams-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function TeamsTab() {
</header>
<main className="my-4 opacity-70">{item.desc}</main>
<footer className="flex w-full items-center">
<Avatar.Group maxCount={4}>
<Avatar.Group max={{ count: 4 }}>
{item.members.map((memberAvatar, index) => (
<Avatar src={memberAvatar} key={index} />
))}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/sys/others/kanban/kanban-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ function KanbanTask({ index, task }: Props) {

{assignee?.length && (
<Avatar.Group
maxCount={3}
maxStyle={{
color: themeToken.colorPrimary,
backgroundColor: themeToken.colorPrimaryBg,
max={{
count: 3,
style: {
color: themeToken.colorPrimary,
backgroundColor: themeToken.colorPrimaryBg,
},
}}
>
{assignee.map((url) => (
Expand Down
6 changes: 4 additions & 2 deletions src/router/hooks/use-route-to-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { useSettings } from '@/store/settingStore';

import { ThemeLayout } from '#/enum';
import { AppRouteObject } from '#/router';
import type { ItemType } from 'antd/es/menu/interface';
import type { GetProp, MenuProps } from 'antd';

type MenuItem = GetProp<MenuProps, 'items'>[number];

/**
* routes -> menus
Expand Down Expand Up @@ -50,7 +52,7 @@ export function useRouteToMenuFn() {
if (children) {
menuItem.children = routeToMenuFn(children);
}
return menuItem as ItemType;
return menuItem as MenuItem;
});
},
[t, themeLayout],
Expand Down

0 comments on commit 3991bcd

Please sign in to comment.