|
@@ -2,17 +2,7 @@ import { useParams, Link } from "react-router-dom";
|
|
|
import { useIntl } from "react-intl";
|
|
import { useIntl } from "react-intl";
|
|
|
import { useState } from "react";
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
-import {
|
|
|
|
|
- Space,
|
|
|
|
|
- Layout,
|
|
|
|
|
- Breadcrumb,
|
|
|
|
|
- Button,
|
|
|
|
|
- Popover,
|
|
|
|
|
- Dropdown,
|
|
|
|
|
- MenuProps,
|
|
|
|
|
- Menu,
|
|
|
|
|
- Table,
|
|
|
|
|
-} from "antd";
|
|
|
|
|
|
|
+import { Space, Button, Popover, Dropdown, MenuProps, Menu, Table } from "antd";
|
|
|
import { ProTable } from "@ant-design/pro-components";
|
|
import { ProTable } from "@ant-design/pro-components";
|
|
|
import { PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
|
import { PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
|
|
|
|
|
|
@@ -65,219 +55,196 @@ const Widget = () => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- <Breadcrumb>
|
|
|
|
|
- <Breadcrumb.Item>
|
|
|
|
|
- <Link to={linkStudio}>
|
|
|
|
|
- {intl.formatMessage({ id: "columns.studio.title" })}
|
|
|
|
|
- </Link>
|
|
|
|
|
- </Breadcrumb.Item>
|
|
|
|
|
- <Breadcrumb.Item>
|
|
|
|
|
- {intl.formatMessage({
|
|
|
|
|
- id: "columns.studio.collaboration.title",
|
|
|
|
|
- })}
|
|
|
|
|
- </Breadcrumb.Item>
|
|
|
|
|
- <Breadcrumb.Item>
|
|
|
|
|
- {intl.formatMessage({ id: "columns.studio.article.title" })}
|
|
|
|
|
- </Breadcrumb.Item>
|
|
|
|
|
- </Breadcrumb>
|
|
|
|
|
- <Layout>
|
|
|
|
|
- <ProTable<DataItem>
|
|
|
|
|
- columns={[
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "dict.fields.sn.label",
|
|
|
|
|
- }),
|
|
|
|
|
- dataIndex: "sn",
|
|
|
|
|
- key: "sn",
|
|
|
|
|
- width: 50,
|
|
|
|
|
- search: false,
|
|
|
|
|
|
|
+ <ProTable<DataItem>
|
|
|
|
|
+ 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",
|
|
|
|
|
+ tip: "过长会自动收缩",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ render: (text, row, index, action) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Link
|
|
|
|
|
+ to={`/studio/${studioname}/article/${row.id}/edit`}
|
|
|
|
|
+ >
|
|
|
|
|
+ {row.title}
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ );
|
|
|
},
|
|
},
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "forms.fields.title.label",
|
|
|
|
|
- }),
|
|
|
|
|
- dataIndex: "title",
|
|
|
|
|
- key: "title",
|
|
|
|
|
- tip: "过长会自动收缩",
|
|
|
|
|
- ellipsis: true,
|
|
|
|
|
- render: (text, row, index, action) => {
|
|
|
|
|
- return (
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: intl.formatMessage({
|
|
|
|
|
+ id: "forms.fields.subtitle.label",
|
|
|
|
|
+ }),
|
|
|
|
|
+ dataIndex: "subtitle",
|
|
|
|
|
+ key: "subtitle",
|
|
|
|
|
+ tip: "过长会自动收缩",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: intl.formatMessage({
|
|
|
|
|
+ id: "forms.fields.summary.label",
|
|
|
|
|
+ }),
|
|
|
|
|
+ dataIndex: "summary",
|
|
|
|
|
+ key: "summary",
|
|
|
|
|
+ tip: "过长会自动收缩",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ title: intl.formatMessage({
|
|
|
|
|
+ id: "forms.fields.publicity.label",
|
|
|
|
|
+ }),
|
|
|
|
|
+ dataIndex: "publicity",
|
|
|
|
|
+ key: "publicity",
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ search: false,
|
|
|
|
|
+ filters: true,
|
|
|
|
|
+ onFilter: true,
|
|
|
|
|
+ valueEnum: PublicityValueEnum(),
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: intl.formatMessage({
|
|
|
|
|
+ id: "forms.fields.created-at.label",
|
|
|
|
|
+ }),
|
|
|
|
|
+ key: "created-at",
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ search: false,
|
|
|
|
|
+ dataIndex: "createdAt",
|
|
|
|
|
+ valueType: "date",
|
|
|
|
|
+ sorter: (a, b) => a.createdAt - b.createdAt,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: intl.formatMessage({ id: "buttons.option" }),
|
|
|
|
|
+ key: "option",
|
|
|
|
|
+ width: 120,
|
|
|
|
|
+ valueType: "option",
|
|
|
|
|
+ render: (text, row, index, action) => {
|
|
|
|
|
+ return [
|
|
|
|
|
+ <Dropdown.Button
|
|
|
|
|
+ key={index}
|
|
|
|
|
+ type="link"
|
|
|
|
|
+ overlay={menu}
|
|
|
|
|
+ >
|
|
|
<Link
|
|
<Link
|
|
|
to={`/studio/${studioname}/article/${row.id}/edit`}
|
|
to={`/studio/${studioname}/article/${row.id}/edit`}
|
|
|
>
|
|
>
|
|
|
- {row.title}
|
|
|
|
|
|
|
+ {intl.formatMessage({
|
|
|
|
|
+ id: "buttons.edit",
|
|
|
|
|
+ })}
|
|
|
</Link>
|
|
</Link>
|
|
|
- );
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "forms.fields.subtitle.label",
|
|
|
|
|
- }),
|
|
|
|
|
- dataIndex: "subtitle",
|
|
|
|
|
- key: "subtitle",
|
|
|
|
|
- tip: "过长会自动收缩",
|
|
|
|
|
- ellipsis: true,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "forms.fields.summary.label",
|
|
|
|
|
- }),
|
|
|
|
|
- dataIndex: "summary",
|
|
|
|
|
- key: "summary",
|
|
|
|
|
- tip: "过长会自动收缩",
|
|
|
|
|
- ellipsis: true,
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "forms.fields.publicity.label",
|
|
|
|
|
- }),
|
|
|
|
|
- dataIndex: "publicity",
|
|
|
|
|
- key: "publicity",
|
|
|
|
|
- width: 100,
|
|
|
|
|
- search: false,
|
|
|
|
|
- filters: true,
|
|
|
|
|
- onFilter: true,
|
|
|
|
|
- valueEnum: PublicityValueEnum(),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: "forms.fields.created-at.label",
|
|
|
|
|
- }),
|
|
|
|
|
- key: "created-at",
|
|
|
|
|
- width: 100,
|
|
|
|
|
- search: false,
|
|
|
|
|
- dataIndex: "createdAt",
|
|
|
|
|
- valueType: "date",
|
|
|
|
|
- sorter: (a, b) => a.createdAt - b.createdAt,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: intl.formatMessage({ id: "buttons.option" }),
|
|
|
|
|
- key: "option",
|
|
|
|
|
- width: 120,
|
|
|
|
|
- valueType: "option",
|
|
|
|
|
- render: (text, row, index, action) => {
|
|
|
|
|
- return [
|
|
|
|
|
- <Dropdown.Button
|
|
|
|
|
- key={index}
|
|
|
|
|
- type="link"
|
|
|
|
|
- overlay={menu}
|
|
|
|
|
- >
|
|
|
|
|
- <Link
|
|
|
|
|
- to={`/studio/${studioname}/article/${row.id}/edit`}
|
|
|
|
|
- >
|
|
|
|
|
- {intl.formatMessage({
|
|
|
|
|
- id: "buttons.edit",
|
|
|
|
|
- })}
|
|
|
|
|
- </Link>
|
|
|
|
|
- </Dropdown.Button>,
|
|
|
|
|
- ];
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ </Dropdown.Button>,
|
|
|
|
|
+ ];
|
|
|
},
|
|
},
|
|
|
- ]}
|
|
|
|
|
- rowSelection={{
|
|
|
|
|
- // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
|
|
|
|
|
- // 注释该行则默认不显示下拉选项
|
|
|
|
|
- selections: [
|
|
|
|
|
- Table.SELECTION_ALL,
|
|
|
|
|
- Table.SELECTION_INVERT,
|
|
|
|
|
- ],
|
|
|
|
|
- }}
|
|
|
|
|
- tableAlertRender={({
|
|
|
|
|
- selectedRowKeys,
|
|
|
|
|
- selectedRows,
|
|
|
|
|
- onCleanSelected,
|
|
|
|
|
- }) => (
|
|
|
|
|
- <Space size={24}>
|
|
|
|
|
- <span>
|
|
|
|
|
- {intl.formatMessage({ id: "buttons.selected" })}
|
|
|
|
|
- {selectedRowKeys.length}
|
|
|
|
|
- <Button
|
|
|
|
|
- type="link"
|
|
|
|
|
- style={{ marginInlineStart: 8 }}
|
|
|
|
|
- onClick={onCleanSelected}
|
|
|
|
|
- >
|
|
|
|
|
- {intl.formatMessage({
|
|
|
|
|
- id: "buttons.unselect",
|
|
|
|
|
- })}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </span>
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ ]}
|
|
|
|
|
+ rowSelection={{
|
|
|
|
|
+ // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
|
|
|
|
|
+ // 注释该行则默认不显示下拉选项
|
|
|
|
|
+ selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
|
|
|
|
|
+ }}
|
|
|
|
|
+ tableAlertRender={({
|
|
|
|
|
+ selectedRowKeys,
|
|
|
|
|
+ selectedRows,
|
|
|
|
|
+ onCleanSelected,
|
|
|
|
|
+ }) => (
|
|
|
|
|
+ <Space size={24}>
|
|
|
|
|
+ <span>
|
|
|
|
|
+ {intl.formatMessage({ id: "buttons.selected" })}
|
|
|
|
|
+ {selectedRowKeys.length}
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="link"
|
|
|
|
|
+ style={{ marginInlineStart: 8 }}
|
|
|
|
|
+ onClick={onCleanSelected}
|
|
|
|
|
+ >
|
|
|
|
|
+ {intl.formatMessage({
|
|
|
|
|
+ id: "buttons.unselect",
|
|
|
|
|
+ })}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ )}
|
|
|
|
|
+ tableAlertOptionRender={() => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Space size={16}>
|
|
|
|
|
+ <Button type="link">
|
|
|
|
|
+ {intl.formatMessage({
|
|
|
|
|
+ id: "buttons.delete.all",
|
|
|
|
|
+ })}
|
|
|
|
|
+ </Button>
|
|
|
</Space>
|
|
</Space>
|
|
|
- )}
|
|
|
|
|
- tableAlertOptionRender={() => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Space size={16}>
|
|
|
|
|
- <Button type="link">
|
|
|
|
|
- {intl.formatMessage({
|
|
|
|
|
- id: "buttons.delete.all",
|
|
|
|
|
- })}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Space>
|
|
|
|
|
- );
|
|
|
|
|
- }}
|
|
|
|
|
- request={async (params = {}, sorter, filter) => {
|
|
|
|
|
- // TODO
|
|
|
|
|
- console.log(params, sorter, filter);
|
|
|
|
|
- let url = `/v2/article?view=studio&name=${studioname}`;
|
|
|
|
|
- const offset =
|
|
|
|
|
- ((params.current ? params.current : 1) - 1) *
|
|
|
|
|
- (params.pageSize ? params.pageSize : 20);
|
|
|
|
|
- url += `&limit=${params.pageSize}&offset=${offset}`;
|
|
|
|
|
- if (typeof params.keyword !== "undefined") {
|
|
|
|
|
- url +=
|
|
|
|
|
- "&search=" +
|
|
|
|
|
- (params.keyword ? params.keyword : "");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ );
|
|
|
|
|
+ }}
|
|
|
|
|
+ request={async (params = {}, sorter, filter) => {
|
|
|
|
|
+ // TODO
|
|
|
|
|
+ console.log(params, sorter, filter);
|
|
|
|
|
+ let url = `/v2/article?view=studio&name=${studioname}`;
|
|
|
|
|
+ const offset =
|
|
|
|
|
+ ((params.current ? params.current : 1) - 1) *
|
|
|
|
|
+ (params.pageSize ? params.pageSize : 20);
|
|
|
|
|
+ url += `&limit=${params.pageSize}&offset=${offset}`;
|
|
|
|
|
+ if (typeof params.keyword !== "undefined") {
|
|
|
|
|
+ url +=
|
|
|
|
|
+ "&search=" + (params.keyword ? params.keyword : "");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const res = await get<IArticleListResponse>(url);
|
|
|
|
|
- const items: DataItem[] = res.data.rows.map(
|
|
|
|
|
- (item, id) => {
|
|
|
|
|
- const date = new Date(item.created_at);
|
|
|
|
|
- return {
|
|
|
|
|
- sn: id + 1,
|
|
|
|
|
- id: item.uid,
|
|
|
|
|
- title: item.title,
|
|
|
|
|
- subtitle: item.subtitle,
|
|
|
|
|
- summary: item.summary,
|
|
|
|
|
- publicity: item.status,
|
|
|
|
|
- createdAt: date.getTime(),
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ const res = await get<IArticleListResponse>(url);
|
|
|
|
|
+ const items: DataItem[] = res.data.rows.map((item, id) => {
|
|
|
|
|
+ const date = new Date(item.created_at);
|
|
|
return {
|
|
return {
|
|
|
- total: res.data.count,
|
|
|
|
|
- succcess: true,
|
|
|
|
|
- data: items,
|
|
|
|
|
|
|
+ sn: id + 1,
|
|
|
|
|
+ id: item.uid,
|
|
|
|
|
+ title: item.title,
|
|
|
|
|
+ subtitle: item.subtitle,
|
|
|
|
|
+ summary: item.summary,
|
|
|
|
|
+ publicity: item.status,
|
|
|
|
|
+ createdAt: date.getTime(),
|
|
|
};
|
|
};
|
|
|
- }}
|
|
|
|
|
- rowKey="id"
|
|
|
|
|
- bordered
|
|
|
|
|
- pagination={{
|
|
|
|
|
- showQuickJumper: true,
|
|
|
|
|
- showSizeChanger: true,
|
|
|
|
|
- }}
|
|
|
|
|
- search={false}
|
|
|
|
|
- options={{
|
|
|
|
|
- search: true,
|
|
|
|
|
- }}
|
|
|
|
|
- toolBarRender={() => [
|
|
|
|
|
- <Popover
|
|
|
|
|
- content={articleCreate}
|
|
|
|
|
- title="Create"
|
|
|
|
|
- placement="bottomRight"
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ return {
|
|
|
|
|
+ total: res.data.count,
|
|
|
|
|
+ succcess: true,
|
|
|
|
|
+ data: items,
|
|
|
|
|
+ };
|
|
|
|
|
+ }}
|
|
|
|
|
+ rowKey="id"
|
|
|
|
|
+ bordered
|
|
|
|
|
+ pagination={{
|
|
|
|
|
+ showQuickJumper: true,
|
|
|
|
|
+ showSizeChanger: true,
|
|
|
|
|
+ }}
|
|
|
|
|
+ search={false}
|
|
|
|
|
+ options={{
|
|
|
|
|
+ search: true,
|
|
|
|
|
+ }}
|
|
|
|
|
+ toolBarRender={() => [
|
|
|
|
|
+ <Popover
|
|
|
|
|
+ content={articleCreate}
|
|
|
|
|
+ title="Create"
|
|
|
|
|
+ placement="bottomRight"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Button
|
|
|
|
|
+ key="button"
|
|
|
|
|
+ icon={<PlusOutlined />}
|
|
|
|
|
+ type="primary"
|
|
|
>
|
|
>
|
|
|
- <Button
|
|
|
|
|
- key="button"
|
|
|
|
|
- icon={<PlusOutlined />}
|
|
|
|
|
- type="primary"
|
|
|
|
|
- >
|
|
|
|
|
- {intl.formatMessage({ id: "buttons.create" })}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Popover>,
|
|
|
|
|
- ]}
|
|
|
|
|
- />
|
|
|
|
|
- </Layout>
|
|
|
|
|
|
|
+ {intl.formatMessage({ id: "buttons.create" })}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Popover>,
|
|
|
|
|
+ ]}
|
|
|
|
|
+ />
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|