Skip to content

Let's use AI to Earn!

feat: 自动化任务界面

yikaJasonMic2fe141cf9b1a
diff --git a/electron/db/index.ts b/electron/db/index.ts
index d1b94ea5..6ba044f3 100644
--- a/electron/db/index.ts
+++ b/electron/db/index.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-01-20 16:22:03
- * @LastEditTime: 2025-02-22 19:25:00
+ * @LastEditTime: 2025-03-18 22:53:17
* @LastEditors: nevin
* @Description: 数据库
*/
@@ -19,6 +19,8 @@ import { isDev } from '../util';
import fs from 'fs/promises';
import { asyData as accountExamine } from './scripts/account';
import { logger } from '../global/log';
+import { AutoRunModel } from './models/autoRun';
+import { AutoRunRecordModel } from './models/autoRunRecord';
const configPath = app.getPath('userData');
const database = path.join(configPath, 'database.sqlite');
@@ -36,6 +38,8 @@ export const AppDataSource = new DataSource({
VideoModel,
AccountStatsModel,
VideoStatsModel,
+ AutoRunModel,
+ AutoRunRecordModel,
], // 实体或模型表
migrations: Object.values(migrations), // 迁移类
migrationsRun: true, // 确保在连接时自动运行迁移
diff --git a/electron/main/autoRun/service.ts b/electron/main/autoRun/service.ts
index b0d79c0b..5effbc81 100644
--- a/electron/main/autoRun/service.ts
+++ b/electron/main/autoRun/service.ts
@@ -26,9 +26,15 @@ export class AutoRunService {
// 创建进程
async createAutoRun(data: Partial<AutoRunModel>) {
- return await this.autoRunRepository.save(data);
- }
+ console.log('------', data);
+ try {
+ return await this.autoRunRepository.save(data);
+ } catch (error) {
+ console.log('----- error', error);
+ }
+ }
+
// 查询进程列表
async findAutoRunList(data: Partial<AutoRunModel>) {
return await this.autoRunRepository.find({
diff --git a/src/views/autoRun/comment.ts b/src/views/autoRun/comment.ts
index 1879055d..6b29fc62 100644
--- a/src/views/autoRun/comment.ts
+++ b/src/views/autoRun/comment.ts
@@ -1,8 +1,12 @@
/*
* @Author: nevin
* @Date: 2025-03-18 21:08:32
- * @LastEditTime: 2025-03-18 21:21:37
+ * @LastEditTime: 2025-03-19 07:32:45
* @LastEditors: nevin
* @Description:
*/
+import { AutoRunType } from '@/icp/autoRun';
+export const AutoRunNameMap = new Map<AutoRunType, string>([
+ [AutoRunType.ReplyComment, '自动回复评论'],
+]);
diff --git a/src/views/autoRun/components/addAutoRun.tsx b/src/views/autoRun/components/addAutoRun.tsx
index 24a1dd20..00d9d741 100644
--- a/src/views/autoRun/components/addAutoRun.tsx
+++ b/src/views/autoRun/components/addAutoRun.tsx
@@ -1,3 +1,10 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-03-18 21:02:38
+ * @LastEditTime: 2025-03-19 07:25:32
+ * @LastEditors: nevin
+ * @Description:
+ */
import { AutoRunType, ipcCreateAutoRun } from '@/icp/autoRun';
import { Button, Form, Input, Modal, Select } from 'antd';
import { forwardRef, useImperativeHandle, useState } from 'react';
@@ -53,6 +60,7 @@ const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {
footer={null}
width={800}
>
+ <p>账号ID{accountId}</p>
<Form
form={form}
name="basic"
@@ -63,19 +71,19 @@ const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {
onFinishFailed={onFinishFailed}
autoComplete="off"
>
+ <p>
+ 周期类型 天 day-22 例:每天22时 周 week-2 例:每周周二,周日0 月
+ month-22 例:每月22号
+ </p>
<Form.Item
label="重复周期类型"
name="cycleType"
rules={[{ required: true, message: '重复周期类型!' }]}
>
- <p>
- 周期类型 天 day-22 例:每天22时 周 week-2 例:每周周二,周日0 月
- month-22 例:每月22号
- </p>
<Input />
</Form.Item>
- <Form.Item name="gender" label="类型" rules={[{ required: true }]}>
+ <Form.Item name="type" label="类型" rules={[{ required: true }]}>
<Select placeholder="选择任务类型" allowClear>
<Option value={AutoRunType.ReplyComment}>自动回复评论</Option>
</Select>
diff --git a/src/views/autoRun/index.tsx b/src/views/autoRun/index.tsx
index a7ae81e0..b7bb9c1b 100644
--- a/src/views/autoRun/index.tsx
+++ b/src/views/autoRun/index.tsx
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-02-10 22:20:15
- * @LastEditTime: 2025-03-18 22:25:37
+ * @LastEditTime: 2025-03-19 07:34:14
* @LastEditors: nevin
* @Description: 评论页面 reply
*/
@@ -16,6 +16,7 @@ import {
ipcGetAutoRunList,
ipcGetAutoRunRecordList,
} from '@/icp/autoRun';
+import { AutoRunNameMap } from './comment';
export default function Page() {
const [autoRunList, setAutoRunList] = useState<AutoRun[]>([]);
@@ -27,7 +28,6 @@ export default function Page() {
const Ref_AddAutoRun = useRef<AddAutoRunRef>(null);
async function getAutoRunList() {
- if (activeAccountId === -1) return;
setAutoRunList([]);
const res = await ipcGetAutoRunList();
setAutoRunList(res);
@@ -65,6 +65,15 @@ export default function Page() {
>
创建自动化
</Button>
+
+ <Button
+ type="primary"
+ onClick={() => {
+ getAutoRunList();
+ }}
+ >
+ 获取列表
+ </Button>
<Row>
<Col span={4}>
<AccountSidebar
@@ -93,7 +102,12 @@ export default function Page() {
查看记录
</Button>,
]}
- ></Card>
+ >
+ <Card.Meta
+ title={AutoRunNameMap.get(item.type) || '无'}
+ description={item.cycleType}
+ />
+ </Card>
))}
</div>
</Col>