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,56 +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, top } = entity ;
102-
103- const category = TABS_MAP [ _tab as TabType ] || {
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- { top ? (
127- < Tag color = "#5BD8A6" > 置顶</ Tag >
128- ) : (
129- < Tag color = { category . color } > { category . name } </ Tag >
130- ) }
131- </ Space >
132- ) ;
133- } ,
134- } ,
135- title : {
136- dataIndex : 'title' ,
137- valueType : 'text' ,
138- } ,
139- actions : {
140- render : ( _ , entity ) => {
141- const { last_reply_at } = entity ;
142- return dayjs ( last_reply_at ) . fromNow ( ) ;
143- } ,
144- } ,
145- } ;
146-
14795 const renderFooter = ( ) => {
14896 return (
14997 < div className = { styles . footer } >
@@ -187,13 +135,9 @@ const TopicList: React.FC<Props> = (props) => {
187135
188136 return (
189137 < div >
190- < ProList
191- rowKey = "id"
192- showActions = "always"
193- dataSource = { data . filter ( ( item : any ) => item ?. author ?. loginname ) }
138+ < TopicItemList
194139 loading = { loading }
195- metas = { metas }
196- className = { styles . list }
140+ dataSource = { data . filter ( ( item : any ) => item ?. author ?. loginname ) }
197141 toolbar = { {
198142 menu : {
199143 type : 'tab' ,
@@ -208,14 +152,6 @@ const TopicList: React.FC<Props> = (props) => {
208152 } ,
209153 actions,
210154 } }
211- onRow = { ( record ) => {
212- return {
213- onClick : ( ) => {
214- console . log ( 'onClick' , record ) ;
215- history . push ( `/topic/${ record . id } ` ) ;
216- } ,
217- } ;
218- } }
219155 />
220156 < Divider type = "horizontal" />
221157 { renderFooter ( ) }
0 commit comments