From a806c0135ce248f0eb67d7fc73600dc5f890113f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 10 May 2022 22:48:05 +0800 Subject: [PATCH] fix: fix typescript error --- package.json | 1 + src/components/NoticeIcon/NoticeList.tsx | 40 +++++++++---------- .../RightContent/AvatarDropdown.tsx | 7 ++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index f37a8c24..52c7c32e 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "devDependencies": { "@ant-design/pro-cli": "^2.1.0", "@playwright/test": "^1.17.0", + "@types/classnames": "^2.3.1", "@types/express": "^4.17.0", "@types/history": "^4.7.0", "@types/jest": "^26.0.0", diff --git a/src/components/NoticeIcon/NoticeList.tsx b/src/components/NoticeIcon/NoticeList.tsx index 5face399..7afae9fb 100644 --- a/src/components/NoticeIcon/NoticeList.tsx +++ b/src/components/NoticeIcon/NoticeList.tsx @@ -61,30 +61,30 @@ const NoticeList: React.FC = ({ ) : null; return ( - { onClick?.(item); }} > - - {item.title} -
{item.extra}
- - } - description={ -
-
{item.description}
-
{item.datetime}
-
- } - /> -
+ + + {item.title} +
{item.extra}
+ + } + description={ +
+
{item.description}
+
{item.datetime}
+
+ } + /> +
+ ); }} /> diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index af29ae11..1edc225a 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -7,6 +7,7 @@ import HeaderDropdown from '../HeaderDropdown'; import styles from './index.less'; import { outLogin } from '@/services/ant-design-pro/api'; import type { MenuInfo } from 'rc-menu/lib/interface'; +import type { ItemType } from 'antd/lib/menu/hooks/useItems'; export type GlobalHeaderRightProps = { menu?: boolean; @@ -68,7 +69,7 @@ const AvatarDropdown: React.FC = ({ menu }) => { return loading; } - const menuItems = [ + const menuItems: ItemType[] = [ ...(menu ? [ { @@ -82,7 +83,7 @@ const AvatarDropdown: React.FC = ({ menu }) => { label: '个人设置', }, { - type: 'divider', + type: 'divider' as const, }, ] : []), @@ -96,7 +97,7 @@ const AvatarDropdown: React.FC = ({ menu }) => { const menuHeaderDropdown = ( ); - + return (