11import React from 'react' ;
22import dayjs from 'dayjs' ;
3- import { useHistory } from 'umi' ;
3+ import { Link } from 'umi' ;
44import { Space , Avatar , Tag } from 'antd' ;
55import { ListToolBarProps } from '@ant-design/pro-table' ;
66import ProList , { ProListMetas } from '@ant-design/pro-list' ;
@@ -10,15 +10,14 @@ import { TABS_MAP, TabType } from '@/constants';
1010import * as styles from './index.less' ;
1111
1212const TopicList : React . FC < Props > = ( { dataSource, loading, toolbar } ) => {
13- const history = useHistory ( ) ;
14-
1513 const metas : ProListMetas = {
1614 avatar : {
1715 dataIndex : 'author.avatar_url' ,
1816 render : ( _ , entity : TopicModel ) => {
1917 const { tab : _tab , author, reply_count, visit_count, top } = entity ;
2018
2119 const category = TABS_MAP [ _tab as TabType ] ;
20+ const { loginname, avatar_url } = author ;
2221
2322 const renderReplyVisit = ( ) =>
2423 typeof visit_count === 'number' && (
@@ -41,7 +40,9 @@ const TopicList: React.FC<Props> = ({ dataSource, loading, toolbar }) => {
4140
4241 return (
4342 < Space >
44- < Avatar size = "small" src = { author . avatar_url } />
43+ < Link to = { `/user/${ loginname } ` } >
44+ < Avatar size = "small" src = { avatar_url } />
45+ </ Link >
4546 { renderReplyVisit ( ) }
4647 { top ? (
4748 < Tag color = "#5BD8A6" > 置顶</ Tag >
@@ -55,6 +56,10 @@ const TopicList: React.FC<Props> = ({ dataSource, loading, toolbar }) => {
5556 title : {
5657 dataIndex : 'title' ,
5758 valueType : 'text' ,
59+ render : ( _ , entity : TopicModel ) => {
60+ const { id, title } = entity ;
61+ return < Link to = { `/topic/${ id } ` } > { title } </ Link > ;
62+ } ,
5863 } ,
5964 actions : {
6065 render : ( _ , entity : TopicModel ) => {
@@ -73,13 +78,6 @@ const TopicList: React.FC<Props> = ({ dataSource, loading, toolbar }) => {
7378 metas = { metas }
7479 className = { styles . list }
7580 toolbar = { toolbar }
76- onRow = { ( record ) => {
77- return {
78- onClick : ( ) => {
79- history . push ( `/topic/${ record . id } ` ) ;
80- } ,
81- } ;
82- } }
8381 />
8482 ) ;
8583} ;
0 commit comments