Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 任务执行状态更新
牛文政d64840226819
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.tsindex 0586e6b3..6fd530f4 100644--- a/electron/main/reply/controller.ts+++ b/electron/main/reply/controller.ts@@ -130,7 +130,6 @@ export class ReplyController {return res;}-/*** 获取二级评论列表*/@@ -220,22 +219,6 @@ export class ReplyController {return res;}- /**- * 测试- */- @Icp('ICP_REPLY_TEST_NOTICE')- async testNotice(event: Electron.IpcMainInvokeEvent): Promise<any> {- console.log('----1111');-- windowOperate.sendRenderMsg(SendChannelEnum.CommentRelyProgress, {- tag: AutorReplyCommentScheduleEvent,- status: 1,- error: '测试',- });-- return 1;- }-/*** 回复评论*/@@ -322,8 +305,5 @@ export class ReplyController {if (!account) return null;this.replyService.addReplyQueue(account, dataId, autoRunData);-- // 创建记录- this.autoRunService.createAutoRunRecord(autoRunData);}}diff --git a/electron/main/reply/service.ts b/electron/main/reply/service.tsindex 02318ce5..39079a11 100644--- a/electron/main/reply/service.ts+++ b/electron/main/reply/service.ts@@ -17,6 +17,7 @@ import { Repository } from 'typeorm';import { ReplyCommentRecordModel } from '../../db/models/replyCommentRecord';import { AppDataSource } from '../../db';import { getUserInfo } from '../user/comment';+import { AutoRunRecordStatus } from '../../db/models/autoRunRecord';@Injectable()export class ReplyService {@@ -222,7 +223,15 @@ export class ReplyService {* @param account* @param dataId*/- addReplyQueue(account: AccountModel, dataId: string, autoRun: AutoRunModel) {+ async addReplyQueue(+ account: AccountModel,+ dataId: string,+ autoRun: AutoRunModel,+ ) {+ // 创建任务执行记录+ const recordData = await this.autoRunService.createAutoRunRecord(autoRun);++ // 添加到队列this.replyQueue.add(() => {this.autorReplyComment(account,@@ -232,16 +241,25 @@ export class ReplyService {status: -1 | 0 | 1;error?: any;}) => {- this.autoRunService.sendAutoRunProgress(- autoRun.id,- e.status,- e.error,- );+ if (e.tag === AutorReplyCommentScheduleEvent.Start) {+ sysNotice('自动机评论回复任务执行开始', `任务ID:${autoRun.id}`);+ }- sysNotice(- '评论回复任务执行',- `评论回复任务执行--${e.tag}--${e.status}`,- );+ if (e.tag === AutorReplyCommentScheduleEvent.End) {+ sysNotice('自动机评论回复任务执行结束', `任务ID:${autoRun.id}`);+ this.autoRunService.updateAutoRunRecordStatus(+ recordData.id,+ AutoRunRecordStatus.SUCCESS,+ );+ }++ if (e.tag === AutorReplyCommentScheduleEvent.Error) {+ sysNotice('自动机评论回复任务-错误!!!', `任务ID:${autoRun.id}`);+ this.autoRunService.updateAutoRunRecordStatus(+ recordData.id,+ AutoRunRecordStatus.FAIL,+ );+ }},);});