11import React , { useEffect } from 'react' ;
2- import dayjs from 'dayjs' ;
32
43import { useHistory , useAccess } from 'umi' ;
5- import { Avatar , Tag , Space , Divider , Button } from 'antd' ;
4+ import { Divider , Button } from 'antd' ;
65import { useRequest , useReactive } from 'ahooks' ;
7- import { ProListMetas } from '@ant-design/pro-list' ;
8- import ProList from '@ant-design/pro-list' ;
96import { ReloadOutlined , EditOutlined } from '@ant-design/icons' ;
107
118import { TABS_MAP } from '@/constants' ;
129import type { TabType } from '@/constants' ;
1310
1411import * as API from '@/service/topic' ;
1512import * as styles from './index.less' ;
13+ import TopicItemList from '@/page/topic/component/TopicItemList' ;
1614
1715interface Props { }
1816
@@ -94,52 +92,6 @@ const TopicList: React.FC<Props> = (props) => {
9492 } ;
9593 } , [ loading ] ) ;
9694
97- const metas : ProListMetas = {
98- avatar : {
99- dataIndex : 'author.avatar_url' ,
100- render : ( _ , entity ) => {
101- const { tab : _tab , author, reply_count, visit_count } = entity ;
102-
103- const category = TABS_MAP [ _tab as keyof typeof TABS_MAP ] || {
104- color : '#777' ,
105- name : '未知' ,
106- } ;
107-
108- return (
109- < Space >
110- < Avatar size = "small" src = { author . avatar_url } />
111- < div
112- style = { {
113- width : '96px' ,
114- padding : '0 8px' ,
115- } }
116- >
117- < span
118- style = { {
119- color : '#9e78c0' ,
120- } }
121- >
122- { reply_count }
123- </ span >
124- /< span > { visit_count } </ span >
125- </ div >
126- < Tag color = { category . color } > { category . name } </ Tag >
127- </ Space >
128- ) ;
129- } ,
130- } ,
131- title : {
132- dataIndex : 'title' ,
133- valueType : 'text' ,
134- } ,
135- actions : {
136- render : ( _ , entity ) => {
137- const { last_reply_at } = entity ;
138- return dayjs ( last_reply_at ) . fromNow ( ) ;
139- } ,
140- } ,
141- } ;
142-
14395 const renderFooter = ( ) => {
14496 return (
14597 < div className = { styles . footer } >
@@ -183,13 +135,9 @@ const TopicList: React.FC<Props> = (props) => {
183135
184136 return (
185137 < div >
186- < ProList
187- rowKey = "id"
188- showActions = "always"
189- dataSource = { data . filter ( ( item : any ) => item ?. author ?. loginname ) }
138+ < TopicItemList
190139 loading = { loading }
191- metas = { metas }
192- className = { styles . list }
140+ dataSource = { data . filter ( ( item : any ) => item ?. author ?. loginname ) }
193141 toolbar = { {
194142 menu : {
195143 type : 'tab' ,
@@ -204,14 +152,6 @@ const TopicList: React.FC<Props> = (props) => {
204152 } ,
205153 actions,
206154 } }
207- onRow = { ( record ) => {
208- return {
209- onClick : ( ) => {
210- console . log ( 'onClick' , record ) ;
211- history . push ( `/topic/${ record . id } ` ) ;
212- } ,
213- } ;
214- } }
215155 />
216156 < Divider type = "horizontal" />
217157 { renderFooter ( ) }
0 commit comments