55 Tooltip ,
66 Empty ,
77 Popover ,
8- Menu ,
9- Popconfirm ,
108} from "antd" ;
119import { ClockCircleOutlined , StarFilled } from "@ant-design/icons" ;
1210import type { ItemType } from "antd/es/menu/interface" ;
@@ -47,6 +45,7 @@ interface CardViewProps<T> {
4745 onClick ?: ( item : T ) => void ;
4846 } [ ]
4947 | ( ( item : T ) => ItemType [ ] ) ;
48+ loading ?: boolean ;
5049 onView ?: ( item : T ) => void ;
5150 onFavorite ?: ( item : T ) => void ;
5251 isFavorite ?: ( item : T ) => boolean ;
@@ -160,8 +159,15 @@ const TagsRenderer = ({ tags }: { tags?: any[] }) => {
160159} ;
161160
162161function CardView < T extends BaseCardDataType > ( props : CardViewProps < T > ) {
163- const { data, pagination, operations, onView, onFavorite, isFavorite } =
164- props ;
162+ const {
163+ data,
164+ pagination,
165+ operations,
166+ loading,
167+ onView,
168+ onFavorite,
169+ isFavorite,
170+ } = props ;
165171
166172 if ( data . length === 0 ) {
167173 return (
@@ -174,47 +180,6 @@ function CardView<T extends BaseCardDataType>(props: CardViewProps<T>) {
174180 const ops = ( item ) =>
175181 typeof operations === "function" ? operations ( item ) : operations ;
176182
177- const menu = ( item ) => {
178- const ops =
179- typeof operations === "function" ? operations ( item ) : operations ;
180- < Menu >
181- { ops . map ( ( op ) => {
182- if ( op ?. danger ) {
183- return (
184- < Menu . Item key = { op ?. key } disabled icon = { op ?. icon } >
185- < Popconfirm
186- title = "确定删除吗?"
187- description = "此操作不可撤销"
188- onConfirm = { op . onClick ? ( ) => op . onClick ( item ) : undefined }
189- okText = "确定"
190- cancelText = "取消"
191- // 阻止事件冒泡,避免 Dropdown 关闭
192- onClick = { ( e ) => e . stopPropagation ( ) }
193- >
194- < div
195- style = { {
196- display : "block" ,
197- width : "100%" ,
198- color : "inherit" ,
199- } }
200- onClick = { ( e ) => e . stopPropagation ( ) }
201- >
202- { op . icon }
203- { op . label }
204- </ div >
205- </ Popconfirm >
206- </ Menu . Item >
207- ) ;
208- } else {
209- return (
210- < Menu . Item key = { op ?. key } onClick = { op ?. onClick } icon = { op ?. icon } >
211- { op ?. label }
212- </ Menu . Item >
213- ) ;
214- }
215- } ) }
216- </ Menu > ;
217- } ;
218183 return (
219184 < div className = "flex-overflow-hidden" >
220185 < div className = "overflow-auto grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4" >
0 commit comments