校园论坛
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumCategory from '@/domain/iForumCategory';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumCategory>[] = [
|
||||
{
|
||||
title: t('forum.category.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.category.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.category.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.category.slug'),
|
||||
dataIndex: 'slug',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.category.slug.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.category.parent_id'),
|
||||
dataIndex: 'parent_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.category.description'),
|
||||
dataIndex: 'description',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.category.icon'),
|
||||
dataIndex: 'icon',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.category.sort'),
|
||||
dataIndex: 'sort',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.category.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.category.status.0') },
|
||||
{ value: 1, label: t('forum.category.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('forum.category.status.1')}</Tag>
|
||||
: <Tag color="error">{t('forum.category.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.category.status.0'), value: 0 },
|
||||
{ text: t('forum.category.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.category.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('forum.category.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumCategory> = {
|
||||
api: '/forum/category',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.category',
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 600,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.category.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.category.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumCategory> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,144 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumComment from '@/domain/iForumComment';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumComment>[] = [
|
||||
{
|
||||
title: t('forum.comment.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.post_id'),
|
||||
dataIndex: 'post_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.parent_id'),
|
||||
dataIndex: 'parent_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.reply_to'),
|
||||
dataIndex: 'reply_to',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.content'),
|
||||
dataIndex: 'content',
|
||||
valueType: 'text',
|
||||
hideInTable: true,
|
||||
hideInSearch: true,
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.comment.content.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.like_count'),
|
||||
dataIndex: 'like_count',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.comment.status.0') },
|
||||
{ value: 1, label: t('forum.comment.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('forum.comment.status.1')}</Tag>
|
||||
: <Tag color="error">{t('forum.comment.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.comment.status.0'), value: 0 },
|
||||
{ text: t('forum.comment.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('forum.comment.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumComment> = {
|
||||
api: '/forum/comment',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.comment',
|
||||
scroll: { x: 1200 },
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 700,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.comment.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.comment.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumComment> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,84 @@
|
||||
import { Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumPostFavorite from '@/domain/iForumPostFavorite';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumPostFavorite>[] = [
|
||||
{
|
||||
title: t('forum.post-favorite.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.post-favorite.post_id'),
|
||||
dataIndex: 'post_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post-favorite.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.post-favorite.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumPostFavorite> = {
|
||||
api: '/forum/post-favorite',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.post-favorite',
|
||||
createShow: false,
|
||||
editShow: false,
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 500,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.post-favorite.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.post-favorite.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumPostFavorite> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,84 @@
|
||||
import { Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumPostLike from '@/domain/iForumPostLike';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumPostLike>[] = [
|
||||
{
|
||||
title: t('forum.post-like.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.post-like.post_id'),
|
||||
dataIndex: 'post_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post-like.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.post-like.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumPostLike> = {
|
||||
api: '/forum/post-like',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.post-like',
|
||||
createShow: false,
|
||||
editShow: false,
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 500,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.post-like.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.post-like.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumPostLike> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,203 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumPost from '@/domain/iForumPost';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumPost>[] = [
|
||||
{
|
||||
title: t('forum.post.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.post.title'),
|
||||
dataIndex: 'title',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.post.title.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.post.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.post.category_id'),
|
||||
dataIndex: 'category_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('forum.post.content'),
|
||||
dataIndex: 'content',
|
||||
valueType: 'text',
|
||||
hideInTable: true,
|
||||
hideInSearch: true,
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.post.content.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.post.view_count'),
|
||||
dataIndex: 'view_count',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.comment_count'),
|
||||
dataIndex: 'comment_count',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.like_count'),
|
||||
dataIndex: 'like_count',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.favorite_count'),
|
||||
dataIndex: 'favorite_count',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.is_hot'),
|
||||
dataIndex: 'is_hot',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.post.is_hot.0') },
|
||||
{ value: 1, label: t('forum.post.is_hot.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="red">{t('forum.post.is_hot.1')}</Tag>
|
||||
: <Tag>{t('forum.post.is_hot.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.post.is_hot.0'), value: 0 },
|
||||
{ text: t('forum.post.is_hot.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.is_top'),
|
||||
dataIndex: 'is_top',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.post.is_top.0') },
|
||||
{ value: 1, label: t('forum.post.is_top.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="blue">{t('forum.post.is_top.1')}</Tag>
|
||||
: <Tag>{t('forum.post.is_top.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.post.is_top.0'), value: 0 },
|
||||
{ text: t('forum.post.is_top.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.post.status.0') },
|
||||
{ value: 1, label: t('forum.post.status.1') },
|
||||
{ value: 2, label: t('forum.post.status.2') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'default', 1: 'success', 2: 'warning' };
|
||||
const labelMap: Record<number, string> = { 0: t('forum.post.status.0'), 1: t('forum.post.status.1'), 2: t('forum.post.status.2') };
|
||||
return <Tag color={colorMap[value] || 'default'}>{labelMap[value] || '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.post.status.0'), value: 0 },
|
||||
{ text: t('forum.post.status.1'), value: 1 },
|
||||
{ text: t('forum.post.status.2'), value: 2 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.post.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('forum.post.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumPost> = {
|
||||
api: '/forum/post',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.post',
|
||||
scroll: { x: 1600 },
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 800,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.post.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.post.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumPost> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,133 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IForumSensitiveWord from '@/domain/iForumSensitiveWord';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IForumSensitiveWord>[] = [
|
||||
{
|
||||
title: t('forum.sensitive-word.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.word'),
|
||||
dataIndex: 'word',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('forum.sensitive-word.word.required') }],
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.replacement'),
|
||||
dataIndex: 'replacement',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.type'),
|
||||
dataIndex: 'type',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 1, label: t('forum.sensitive-word.type.1') },
|
||||
{ value: 2, label: t('forum.sensitive-word.type.2') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 2
|
||||
? <Tag color="red">{t('forum.sensitive-word.type.2')}</Tag>
|
||||
: <Tag color="blue">{t('forum.sensitive-word.type.1')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.sensitive-word.type.1'), value: 1 },
|
||||
{ text: t('forum.sensitive-word.type.2'), value: 2 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('forum.sensitive-word.status.0') },
|
||||
{ value: 1, label: t('forum.sensitive-word.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('forum.sensitive-word.status.1')}</Tag>
|
||||
: <Tag color="error">{t('forum.sensitive-word.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('forum.sensitive-word.status.0'), value: 0 },
|
||||
{ text: t('forum.sensitive-word.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('forum.sensitive-word.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IForumSensitiveWord> = {
|
||||
api: '/forum/sensitive-word',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'forum.sensitive-word',
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: {
|
||||
width: 600,
|
||||
},
|
||||
cardProps: {
|
||||
variant: 'borderless',
|
||||
},
|
||||
pagination: {
|
||||
size: 'small',
|
||||
style: { marginBottom: 0 },
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('forum.sensitive-word.page.title')}</Title>
|
||||
<Text type="secondary">{t('forum.sensitive-word.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IForumSensitiveWord> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
Reference in New Issue
Block a user