import { useIntl } from "react-intl"; import { Progress, Typography } from "antd"; import { ProTable } from "@ant-design/pro-components"; import { Link } from "react-router"; import { Button, Dropdown } from "antd"; import { DeleteOutlined } from "@ant-design/icons"; import { get } from "../../request"; import type { IChapterListResponse } from "../../api/Corpus"; import type { IArticleParam } from "../../pages/studio/recent/list"; const { Text } = Typography; interface IItem { sn: number; title: string; subTitle: string; summary: string; book: number; paragraph: number; path: string; progress: number; view: number; created_at: string; updated_at: string; } interface IWidget { channelId?: string; onSelect?: Function; } const ChapterInChannelListWidget = ({ channelId, onSelect }: IWidget) => { const intl = useIntl(); return ( columns={[ { title: intl.formatMessage({ id: "dict.fields.sn.label", }), dataIndex: "sn", key: "sn", width: 50, search: false, }, { title: intl.formatMessage({ id: "forms.fields.title.label", }), dataIndex: "title", key: "title", tooltip: "过长会自动收缩", ellipsis: true, render: (_text, row, index, _action) => { return (
{row.subTitle}
); }, }, { title: intl.formatMessage({ id: "forms.fields.summary.label", }), dataIndex: "summary", key: "summary", tooltip: "过长会自动收缩", ellipsis: true, }, { title: intl.formatMessage({ id: "forms.fields.publicity.label", }), dataIndex: "progress", key: "progress", width: 100, search: false, render: (_text, row, index, _action) => { const per = Math.round(row.progress * 100); return ; }, }, { title: intl.formatMessage({ id: "forms.fields.publicity.label", }), dataIndex: "view", key: "view", width: 100, search: false, }, { title: intl.formatMessage({ id: "forms.fields.created-at.label", }), key: "created-at", width: 100, search: false, dataIndex: "created_at", valueType: "date", sorter: false, }, { title: intl.formatMessage({ id: "buttons.option" }), key: "option", width: 120, valueType: "option", render: (_text, row, index, _action) => { let editLink = `/article/chapter/${row.book}-${row.paragraph}?mode=edit`; editLink += channelId ? `&channel=${channelId}` : ""; return [ , }, ], onClick: (e) => { switch (e.key) { case "remove": break; default: break; } }, }} > {intl.formatMessage({ id: "buttons.translate", })} , ]; }, }, ]} request={async (params = {}, sorter, filter) => { // TODO 加排序 console.log(params, sorter, filter); const offset = ((params.current || 1) - 1) * (params.pageSize || 20); const res = await get( `/v2/progress?view=chapter&channel=${channelId}&progress=0.01&offset=${offset}` ); console.log(res.data.rows); const items: IItem[] = res.data.rows.map((item, id) => { return { sn: id + offset + 1, book: item.book, paragraph: item.para, view: item.view, title: item.title, subTitle: item.toc, summary: item.summary, path: item.path, progress: item.progress, created_at: item.created_at, updated_at: item.updated_at, }; }); return { total: res.data.count, succcess: true, data: items, }; }} rowKey="id" bordered pagination={{ showQuickJumper: true, showSizeChanger: true, }} search={false} options={{ search: true, }} /> ); }; export default ChapterInChannelListWidget;