Skip to content

Let's use AI to Earn!

feat: 任务记录列表

牛文政0b4defdd488d
diff --git a/src/icp/autoRun.ts b/src/icp/autoRun.ts
index a8583435..2e9815bb 100644
--- a/src/icp/autoRun.ts
+++ b/src/icp/autoRun.ts
@@ -106,8 +106,11 @@ export async function ipcGetAutoRunRecordList(
status?: AutoRunRecordStatus;
cycleType?: string;
},
-) {
- const res: AutoRunRecord[] = await window.ipcRenderer.invoke(
+): Promise<{
+ list: AutoRunRecord[];
+ count: number;
+}> {
+ const res = await window.ipcRenderer.invoke(
'ICP_AUTO_RUN_RECORD_LIST',
pageInfo,
query,
diff --git a/src/views/reply/autoRun.tsx b/src/views/reply/autoRun.tsx
index 44658427..4883fcba 100644
--- a/src/views/reply/autoRun.tsx
+++ b/src/views/reply/autoRun.tsx
@@ -1,5 +1,5 @@
import { AutoRun, AutoRunType, ipcGetAutoRunList } from '@/icp/autoRun';
-import { Space, Table, Tag } from 'antd';
+import { Space, Table } from 'antd';
import React from 'react';
const { Column } = Table;
@@ -39,34 +39,47 @@ const Page: React.FC = () => {
}, [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>
+ <div style={{ width: '100%' }} className="bg-slate-500">
+ <Table
+ dataSource={autoRunList}
+ style={{ width: '100%' }}
+ className="bg-slate-500"
+ pagination={pagination}
+ onChange={(newPagination) => {
+ setPagination({
+ ...pagination,
+ page: newPagination.current!,
+ pageSize: newPagination.pageSize!,
+ });
+ }}
+ >
+ <Column title="ID" dataIndex="id" key="id" />
+ <Column title="用户DI" dataIndex="userId" key="userId" />
+ <Column title="账户ID" dataIndex="accountId" key="accountId" />
+ <Column title="运行次数" dataIndex="runCount" key="runCount" />
+ <Column title="状态" dataIndex="status" key="status" />
+ <Column title="类型" dataIndex="type" key="type" />
+ <Column title="触发周期" dataIndex="cycleType" key="cycleType" />
+ <Column
+ title="创建时间"
+ key="createTime"
+ render={(_: any, record: AutoRun) => (
+ <p>{new Date(record.createTime).toLocaleString()}</p>
+ )}
+ />
+
+ <Column
+ title="操作"
+ key="action"
+ render={(_: any, record: AutoRun) => (
+ <Space size="middle">
+ <a>暂停</a>
+ <a>删除</a>
+ </Space>
+ )}
+ />
+ </Table>
+ </div>
);
};
diff --git a/src/views/reply/components/autoRunRecord.tsx b/src/views/reply/components/autoRunRecord.tsx
new file mode 100644
index 00000000..33fdf904
--- /dev/null
+++ b/src/views/reply/components/autoRunRecord.tsx
@@ -0,0 +1,99 @@
+import { AutoRun, AutoRunRecord, ipcGetAutoRunRecordList } from '@/icp/autoRun';
+import { Modal, Table } from 'antd';
+import React from 'react';
+
+const { Column } = Table;
+
+const Page: React.FC = (props: any, ref) => {
+ const [autoRunRecordList, setAutoRunRecordList] = React.useState<
+ AutoRunRecord[]
+ >([]);
+ const [autoRun, setAutoRun] = React.useState<AutoRun | null>(null);
+ const [pagination, setPagination] = React.useState({
+ page: 1,
+ pageSize: 10,
+ total: 0,
+ });
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
+
+ async function init(inAutoRun: AutoRun) {
+ setAutoRun(inAutoRun);
+ setIsModalOpen(true);
+ }
+
+ React.useImperativeHandle(ref, () => ({
+ init: init,
+ }));
+
+ /**
+ * 获取自动运行的列表
+ */
+ async function getAutoRunList() {
+ if (!autoRun) return;
+
+ const res = await ipcGetAutoRunRecordList(
+ {
+ page: pagination.page,
+ pageSize: pagination.pageSize,
+ },
+ {
+ autoRunId: autoRun.id,
+ },
+ );
+
+ setAutoRunRecordList(res.list);
+ setPagination({
+ ...pagination,
+ total: res.count,
+ });
+ }
+
+ React.useEffect(() => {
+ getAutoRunList();
+ }, [pagination.page, pagination.pageSize]);
+
+ return (
+ <Modal
+ title="任务记录"
+ open={isModalOpen}
+ onCancel={() => {
+ setIsModalOpen(false);
+ }}
+ footer={null}
+ width={600}
+ >
+ <div style={{ width: '100%' }} className="bg-slate-500">
+ <Table
+ dataSource={autoRunRecordList}
+ style={{ width: '100%' }}
+ className="bg-slate-500"
+ pagination={pagination}
+ onChange={(newPagination) => {
+ setPagination({
+ ...pagination,
+ page: newPagination.current!,
+ pageSize: newPagination.pageSize!,
+ });
+ }}
+ >
+ <Column title="ID" dataIndex="id" key="id" />
+ <Column title="用户DI" dataIndex="userId" key="userId" />
+ <Column title="账户ID" dataIndex="accountId" key="accountId" />
+ <Column title="运行次数" dataIndex="runCount" key="runCount" />
+ <Column title="状态" dataIndex="status" key="status" />
+ <Column title="类型" dataIndex="type" key="type" />
+ <Column title="触发周期" dataIndex="cycleType" key="cycleType" />
+ <Column
+ title="创建时间"
+ key="createTime"
+ render={(_: any, record: AutoRun) => (
+ <p>{new Date(record.createTime).toLocaleString()}</p>
+ )}
+ />
+ </Table>
+ </div>
+ </Modal>
+ );
+};
+
+export default Page;
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index c3d17d84..8336dda4 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -104,7 +104,7 @@ export default function Page() {
}, [])}
/>
- <div className="m-4 ">
+ <div className="m-4">
<Tabs defaultActiveKey="1">
<Tabs.TabPane tab="作品列表" key="1">
<div className="grid grid-cols-5 p-4 account-con bg-slate-300">
@@ -179,7 +179,9 @@ export default function Page() {
</div>
</Tabs.TabPane>
<Tabs.TabPane tab="自动任务" key="2">
- <AutoRun />
+ <div style={{ width: '100%' }}>
+ <AutoRun />
+ </div>
</Tabs.TabPane>
</Tabs>
</div>