Skip to content

Let's use AI to Earn!

feat: 任务列表页面

牛文政b328f7e0c1a0
diff --git a/src/icp/autoRun.ts b/src/icp/autoRun.ts
index 4f0f0373..a8583435 100644
--- a/src/icp/autoRun.ts
+++ b/src/icp/autoRun.ts
@@ -37,6 +37,7 @@ export enum AutoRunRecordStatus {
export interface AutoRunRecord {
id: number;
+ autoRunId: number;
userId: string;
status: AutoRunRecordStatus;
type: AutoRunType;
@@ -78,8 +79,11 @@ export async function ipcGetAutoRunList(
accountId?: number;
dataId?: string;
},
-) {
- const res: AutoRun[] = await window.ipcRenderer.invoke(
+): Promise<{
+ list: AutoRun[];
+ count: number;
+}> {
+ const res = await window.ipcRenderer.invoke(
'ICP_AUTO_RUN_LIST',
pageInfo,
query,
diff --git a/src/views/reply/autoRun.tsx b/src/views/reply/autoRun.tsx
index 841ebcf9..44658427 100644
--- a/src/views/reply/autoRun.tsx
+++ b/src/views/reply/autoRun.tsx
@@ -1,74 +1,73 @@
+import { AutoRun, AutoRunType, ipcGetAutoRunList } from '@/icp/autoRun';
import { Space, Table, Tag } from 'antd';
import React from 'react';
const { Column } = Table;
-interface DataType {
- key: React.Key;
- firstName: string;
- lastName: string;
- age: number;
- address: string;
- tags: string[];
-}
+const Page: React.FC = () => {
+ const [autoRunList, setAutoRunList] = React.useState<AutoRun[]>([]);
+ // 分页组件的数据
+ const [pagination, setPagination] = React.useState({
+ page: 1,
+ pageSize: 10,
+ total: 0,
+ });
-const data: DataType[] = [
- {
- key: '1',
- firstName: 'John',
- lastName: 'Brown',
- age: 32,
- address: 'New York No. 1 Lake Park',
- tags: ['nice', 'developer'],
- },
- {
- key: '2',
- firstName: 'Jim',
- lastName: 'Green',
- age: 42,
- address: 'London No. 1 Lake Park',
- tags: ['loser'],
- },
- {
- key: '3',
- firstName: 'Joe',
- lastName: 'Black',
- age: 32,
- address: 'Sydney No. 1 Lake Park',
- tags: ['cool', 'teacher'],
- },
-];
+ /**
+ * 获取自动运行的列表
+ */
+ async function getAutoRunList() {
+ const res = await ipcGetAutoRunList(
+ {
+ page: pagination.page,
+ pageSize: pagination.pageSize,
+ },
+ {
+ type: AutoRunType.ReplyComment,
+ },
+ );
-const Page: React.FC = () => (
- <Table dataSource={data}>
- <Column title="Age" dataIndex="age" key="age" />
- <Column title="Age" dataIndex="age" key="age" />
- <Column title="Address" dataIndex="address" key="address" />
- <Column
- title="Tags"
- dataIndex="tags"
- key="tags"
- render={(tags: string[]) => (
- <>
- {tags.map((tag) => (
- <Tag color="blue" key={tag}>
- {tag}
- </Tag>
- ))}
- </>
- )}
- />
- <Column
- title="Action"
- key="action"
- render={(_: any, record: DataType) => (
- <Space size="middle">
- <a>Invite {record.lastName}</a>
- <a>Delete</a>
- </Space>
- )}
- />
- </Table>
-);
+ setAutoRunList(res.list);
+ setPagination({
+ ...pagination,
+ total: res.count,
+ });
+ }
+
+ React.useEffect(() => {
+ getAutoRunList();
+ }, [pagination.page, pagination.pageSize]);
+
+ return (
+ <Table dataSource={autoRunList}>
+ <Column title="Age" dataIndex="age" key="age" />
+ <Column title="Age" dataIndex="age" key="age" />
+ <Column title="Address" dataIndex="address" key="address" />
+ <Column
+ title="Tags"
+ dataIndex="tags"
+ key="tags"
+ render={(tags: string[]) => (
+ <>
+ {tags.map((tag) => (
+ <Tag color="blue" key={tag}>
+ {tag}
+ </Tag>
+ ))}
+ </>
+ )}
+ />
+ <Column
+ title="Action"
+ key="action"
+ render={(_: any, record: AutoRun) => (
+ <Space size="middle">
+ <a>Delete</a>
+ </Space>
+ )}
+ />
+ </Table>
+ );
+};
export default Page;