Skip to content

Let's use AI to Earn!

feat: 自动化任务事件传递

yikaJasonMic9a92f037dbf2
diff --git a/electron/global/event.ts b/electron/global/event.ts
index 8b3f02ab..7cb6358a 100644
--- a/electron/global/event.ts
+++ b/electron/global/event.ts
@@ -1,9 +1,9 @@
/*
* @Author: nevin
* @Date: 2025-02-06 19:15:58
- * @LastEditTime: 2025-02-07 10:38:24
+ * @LastEditTime: 2025-03-19 14:26:43
* @LastEditors: nevin
* @Description: 全局事件
*/
import { EventEmitter } from 'events';
-export const Event = new EventEmitter();
+export const EtEvent = new EventEmitter();
diff --git a/electron/main/autoRun/controller.ts b/electron/main/autoRun/controller.ts
index 33ecbe5d..5041de0c 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-19 14:08:16
+ * @LastEditTime: 2025-03-19 14:27:36
* @LastEditors: nevin
* @Description: autoRun AutoRun
*/
@@ -9,6 +9,7 @@ import { Controller, Icp, Inject, Scheduled } from '../core/decorators';
import { AutoRunService } from './service';
import { AutoRunType } from '../../db/models/autoRun';
import { getUserInfo } from '../user/comment';
+import { EtEvent } from '../../global/event';
@Controller()
export class AutoRunController {
@@ -108,6 +109,7 @@ export class AutoRunController {
async syncAllAutoRunStart() {
try {
console.log('------- 111');
+ EtEvent.emit('ET_RUN_AUTO_RUN', 1111);
} catch (error) {
console.error('Failed to sync accounts:', error);
}
diff --git a/electron/main/plat/pub/PubItemVideo.ts b/electron/main/plat/pub/PubItemVideo.ts
index 40f313be..a78860f6 100644
--- a/electron/main/plat/pub/PubItemVideo.ts
+++ b/electron/main/plat/pub/PubItemVideo.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-02-07 20:00:47
- * @LastEditTime: 2025-02-13 13:53:55
+ * @LastEditTime: 2025-03-19 14:27:53
* @LastEditors: nevin
* @Description:
*/
@@ -10,7 +10,7 @@ import { AccountModel } from '../../../db/models/account';
import { PubItemBase } from './PubItemBase';
import { PlatformBase } from '../PlatformBase';
import { PubStatus } from '../../../db/models/pubRecord';
-import { Event } from '../../../global/event';
+import { EtEvent } from '../../../global/event';
import { VisibleTypeEnum } from '../../../../commont/publish/PublishEnum';
import windowOperate from '../../../util/windowOperate';
import { SendChannelEnum } from '../../../../commont/UtilsEnum';
@@ -84,6 +84,6 @@ export class PubItemVideo extends PubItemBase {
* 更新视频记录
*/
async uploadRecord() {
- Event.emit('ET_PUBLISH_UPDATE_VIDEO_PUL', this.videoModel);
+ EtEvent.emit('ET_PUBLISH_UPDATE_VIDEO_PUL', this.videoModel);
}
}
diff --git a/electron/main/publish/service.ts b/electron/main/publish/service.ts
index 68ce1977..fe81ad77 100644
--- a/electron/main/publish/service.ts
+++ b/electron/main/publish/service.ts
@@ -9,7 +9,7 @@ import { Injectable } from '../core/decorators';
import { FindManyOptions, FindOptionsWhere, Repository } from 'typeorm';
import { CorrectQuery, backPageData } from '../../global/table';
import { PubRecordModel, PubStatus } from '../../db/models/pubRecord';
-import { Event } from '../../global/event';
+import { EtEvent } from '../../global/event';
@Injectable()
export class PublishService {
private pubRecordRepository: Repository<PubRecordModel>;
@@ -53,7 +53,7 @@ export class PublishService {
async deletePubRecordById(id: number): Promise<boolean> {
const { affected } = await this.pubRecordRepository.delete(id);
const res = affected ? true : false;
- if (res) Event.emit('ET_DEL_PUB_RECORD_ITEM', id);
+ if (res) EtEvent.emit('ET_DEL_PUB_RECORD_ITEM', id);
return res;
}
}
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 1ba677ef..6814eea0 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -1,13 +1,14 @@
/*
* @Author: nevin
* @Date: 2025-01-20 22:02:54
- * @LastEditTime: 2025-03-19 12:18:37
+ * @LastEditTime: 2025-03-19 14:25:31
* @LastEditors: nevin
* @Description: reply Reply
*/
+import { AutoRunModel } from '../../db/models/autoRun';
import { AccountService } from '../account/service';
import { toolsApi } from '../api/tools';
-import { Controller, Icp, Inject } from '../core/decorators';
+import { Controller, Et, Icp, Inject } from '../core/decorators';
import platController from '../plat';
import type { CommentData } from '../plat/plat.type';
import { ReplyService } from './service';
@@ -148,4 +149,10 @@ export class ReplyController {
);
return res;
}
+
+ // 运行自动任务
+ @Et('ET_RUN_AUTO_RUN')
+ async runAutoReplyComment(autoRunData: AutoRunModel): Promise<any> {
+ console.log('------ runAutoReplyComment ------', autoRunData.createTime);
+ }
}