返回 AiToEarn
addAutoRun.tsx
1 /*
2 * @Author: nevin
3 * @Date: 2025-03-18 21:02:38
4 * @LastEditTime: 2025-03-20 22:38:42
5 * @LastEditors: nevin
6 * @Description: 添加自动运行
7 */
8 import { Button, Input, Modal } from 'antd';
9 import { forwardRef, useImperativeHandle, useState } from 'react';
10
11 export interface AddAutoRunRef {
12 init: (accountId: number, dataId: string) => Promise<void>;
13 }
14
15 const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {
16 const [isModalOpen, setIsModalOpen] = useState(false);
17 const [accountId, setAccountId] = useState<number>(0);
18 const [dataId, setDataId] = useState<string>('');
19 // '周期类型 天 day-22 (例:每天22时) 周 week-2 (例:每周周二,周日0) 月 month-22 (例:每月22号)',
20 const [cycleType, setCycleType] = useState<string>('');
21 async function init(accountId: number, dataId: string) {
22 setAccountId(accountId);
23 setDataId(dataId);
24 setIsModalOpen(true);
25 }
26
27 useImperativeHandle(ref, () => ({
28 init: init,
29 }));
30
31 function handleCancel() {
32 setIsModalOpen(false);
33 }
34
35 async function onFinish() {
36 console.log('-------- accountId', accountId);
37 console.log('-------- dataId', dataId);
38 console.log('-------- cycleType', cycleType);
39
40 // const res = await ipcCreateAutoRunOfReply(accountId, dataId, cycleType);
41 // console.log('-------- res', res);
42 }
43
44 return (
45 <>
46 <Modal
47 title="创建自动回复评论任务"
48 open={isModalOpen}
49 onCancel={handleCancel}
50 footer={null}
51 width={800}
52 >
53 <p>账号ID{accountId}</p>
54 <p>账号ID{accountId}</p>
55 <p>
56 周期类型 天 day-22 例:每天22时 周 week-2 例:每周周二,周日0 月 month-22
57 例:每月22号
58 </p>
59
60 <Input
61 onChange={(e) => {
62 setCycleType(e.target.value);
63 }}
64 />
65
66 <Button type="primary" onClick={onFinish}>
67 创建
68 </Button>
69 </Modal>
70 </>
71 );
72 });
73 export default Com;
74
74 lines Plain Text