功能:完成表格排序功能

This commit is contained in:
Liu 宇阳
2024-11-11 14:26:04 +08:00
parent 20e69bb057
commit d78805f80c
5 changed files with 12 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ const ArticlePage = () => {
dataIndex: 'view',
key: 'view',
align: 'center',
sorter: (a: Article, b: Article) => a.view! - b.view!
},
{
title: '评论数量',
@@ -103,6 +104,7 @@ const ArticlePage = () => {
key: 'comment',
align: 'center',
render: (data: string) => <span>{data}</span>,
sorter: (a: Article, b: Article) => a.comment! - b.comment!
},
{
title: '发布时间',
@@ -111,6 +113,8 @@ const ArticlePage = () => {
align: 'center',
width: 200,
render: (text: string) => dayjs(+text).format('YYYY-MM-DD HH:mm:ss'),
defaultSortOrder: 'descend',
sorter: (a: Article, b: Article) => +a.createTime! - +b.createTime!
},
{
title: '操作',

View File

@@ -90,6 +90,8 @@ const CommentPage = () => {
dataIndex: 'createTime',
key: 'createTime',
render: (date: string) => dayjs(+date).format('YYYY-MM-DD HH:mm:ss'),
defaultSortOrder: 'descend',
sorter: (a: Comment, b: Comment) => +a.createTime! - +b.createTime!
},
{
title: '操作',

View File

@@ -59,6 +59,8 @@ const FootprintPage = () => {
align: 'center',
width: 200,
render: (time: string) => dayjs(+time).format('YYYY-MM-DD HH:mm:ss'),
defaultSortOrder: 'descend',
sorter: (a: Footprint, b: Footprint) => +a.createTime! - +b.createTime!
},
{
title: '操作',

View File

@@ -58,7 +58,7 @@ const WallPage = () => {
title: '名称',
dataIndex: 'name',
key: 'name',
fixed: 'left',
fixed: 'left'
},
{
title: '内容',
@@ -81,6 +81,8 @@ const WallPage = () => {
dataIndex: 'createTime',
key: 'createTime',
render: (date: string) => dayjs(+date).format('YYYY-MM-DD HH:mm:ss'),
defaultSortOrder: 'descend',
sorter: (a: Wall, b: Wall) => +a.createTime! - +b.createTime!
},
{
title: '操作',

View File

@@ -22,7 +22,7 @@ export interface Article {
tagIds: string,
tagList: Tag[]
view?: number
count?: number,
comment?: number,
config: Config,
createTime?: string,
}