Skip to content

Let's use AI to Earn!

feat: 自动任务的通知

yikaJasonMic623020c03fb8
diff --git a/commont/UtilsEnum.ts b/commont/UtilsEnum.ts
index 95fded8b..e6a48379 100644
--- a/commont/UtilsEnum.ts
+++ b/commont/UtilsEnum.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-03-01 19:27:31
- * @LastEditTime: 2025-03-23 11:46:42
+ * @LastEditTime: 2025-03-23 18:23:09
* @LastEditors: nevin
* @Description: 工具枚举
*/
@@ -11,6 +11,6 @@ export enum SendChannelEnum {
AccountLoginFinish = 'AccountLoginFinish',
// 视频发布进度发送
VideoPublishProgress = 'VideoPublishProgress',
- // 自动运行失败
- AutoRunError = 'AutoRunError',
+ // 自动运行进度或状态
+ AutoRun = 'AutoRun',
}
diff --git a/electron/main/autoRun/controller.ts b/electron/main/autoRun/controller.ts
index 25161bfb..e7afa7a7 100644
--- a/electron/main/autoRun/controller.ts
+++ b/electron/main/autoRun/controller.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-01-20 22:02:54
- * @LastEditTime: 2025-03-23 15:18:02
+ * @LastEditTime: 2025-03-23 18:34:36
* @LastEditors: nevin
* @Description: autoRun AutoRun
*/
@@ -11,8 +11,6 @@ import { AutoRunType } from '../../db/models/autoRun';
import { getUserInfo } from '../user/comment';
import { EtEvent } from '../../global/event';
import { autoRunTypeEtTag, hasTriggered } from './comment';
-import windowOperate from '../../util/windowOperate';
-import { SendChannelEnum } from '../../../commont/UtilsEnum';
@Controller()
export class AutoRunController {
@@ -111,10 +109,6 @@ export class AutoRunController {
// 每5分钟进行一次自动启动
@Scheduled('*/1 * * * *', 'all_auto_run_start')
async syncAllAutoRunStart() {
- console.log('------111', 222);
-
- windowOperate.sendRenderMsg(SendChannelEnum.AutoRunError, 111);
-
try {
const userInfo = getUserInfo();
@@ -122,6 +116,7 @@ export class AutoRunController {
userInfo.id,
);
+ // 遍历自动运行列表,满足运行条件的通知运行
for (const item of autoRunList) {
const tag = autoRunTypeEtTag.get(item.type);
if (!tag) continue;
@@ -130,8 +125,7 @@ export class AutoRunController {
EtEvent.emit(tag, item);
}
} catch (error) {
- windowOperate.sendRenderMsg(SendChannelEnum.AutoRunError, error);
- console.error('Failed to sync accounts:', error);
+ console.error('---- syncAllAutoRunStart ---- error', error);
}
}
}
diff --git a/electron/main/autoRun/service.ts b/electron/main/autoRun/service.ts
index 0f719dd1..7cfa7223 100644
--- a/electron/main/autoRun/service.ts
+++ b/electron/main/autoRun/service.ts
@@ -12,6 +12,8 @@ import {
} from '../../db/models/autoRunRecord';
import { Repository } from 'typeorm';
import { AppDataSource } from '../../db';
+import windowOperate from '../../util/windowOperate';
+import { SendChannelEnum } from '../../../commont/UtilsEnum';
@Injectable()
export class AutoRunService {
@@ -102,4 +104,17 @@ export class AutoRunService {
status,
});
}
+
+ // 发送自动任务进度通知
+ async sendAutoRunProgress(id: number, status: -1 | 0 | 1 | 2, error?: any) {
+ const autoRunInfo = await this.findAutoRunById(id);
+ if (!autoRunInfo) return;
+
+ windowOperate.sendRenderMsg(
+ SendChannelEnum.AutoRun,
+ status,
+ autoRunInfo,
+ error,
+ );
+ }
}
diff --git a/electron/main/reply/service.ts b/electron/main/reply/service.ts
index f52a7b14..ece1c479 100644
--- a/electron/main/reply/service.ts
+++ b/electron/main/reply/service.ts
@@ -35,9 +35,7 @@ export class ReplyService {
pageInfo: { pcursor, hasMore },
} = await platController.getCommentList(account, dataId, thePcursor);
- for (const item of list) {
- list.push(item);
- }
+ for (const item of list) list.push(item);
thePcursor = pcursor;
theHasMore = !!hasMore;
@@ -58,6 +56,11 @@ export class ReplyService {
return true;
}
+ /**
+ * 添加作品回复评论的任务到队列
+ * @param account
+ * @param dataId
+ */
addReplyQueue(account: AccountModel, dataId: string) {
this.replyQueue.add(() => {
this.autorReplyComment(account, dataId);
diff --git a/src/components/Inform/index.tsx b/src/components/Inform/index.tsx
index 269ed81e..3c2afb28 100644
--- a/src/components/Inform/index.tsx
+++ b/src/components/Inform/index.tsx
@@ -1,26 +1,34 @@
/*
* @Author: nevin
* @Date: 2025-03-23 14:53:37
- * @LastEditTime: 2025-03-23 15:16:11
+ * @LastEditTime: 2025-03-23 18:23:23
* @LastEditors: nevin
* @Description: 通知的全局组件
*/
//
import { SendChannelEnum } from '@@/UtilsEnum';
+import { notification } from 'antd';
import React, { FC, useEffect } from 'react';
interface InformProps {
onChooseItem: () => void;
}
const Inform: FC<InformProps> = ({}) => {
- useEffect(() => {
- const e = window.ipcRenderer.on(SendChannelEnum.AutoRunError, (e, args) => {
- // window.ipcRenderer.off('AutoRunError', e);
- console.log('---------');
- console.log('--------- e', e);
- console.log('--------- args', args);
+ const e = window.ipcRenderer.on(SendChannelEnum.AutoRun, (e, args) => {
+ console.log('--------- e', e);
+ console.log('--------- args', args);
+
+ notification.open({
+ message: '自动化任务',
+ description:
+ 'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
+ onClick: () => {
+ console.log('Notification Clicked!');
+ },
});
- }, []);
+ });
+
+ useEffect(() => {}, []);
function onChooseItem() {
console.log('onChooseItem');