Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 自动化记录
yikaJasonMice97f3c860cc9
diff --git a/electron/main/autoRun/controller.ts b/electron/main/autoRun/controller.tsindex c4e7566f..5769377d 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-18 22:17:16+ * @LastEditTime: 2025-03-19 07:46:54* @LastEditors: nevin* @Description: autoRun AutoRun*/@@ -66,12 +66,12 @@ export class AutoRunController {@Icp('ICP_AUTO_RUN_RECORD_CREATE')async createAutoRunRecord(event: Electron.IpcMainInvokeEvent,- data: {- accountId: number;- type: AutoRunType;- },+ autoRunId: number,) {- const autoRunRecord = await this.autoRunService.createAutoRunRecord(data);+ const autoData = await this.autoRunService.findAutoRunById(autoRunId);+ if (!autoData) return null;+ const autoRunRecord =+ await this.autoRunService.createAutoRunRecord(autoData);return autoRunRecord;}diff --git a/electron/main/autoRun/service.ts b/electron/main/autoRun/service.tsindex 5effbc81..216a65c8 100644--- a/electron/main/autoRun/service.ts+++ b/electron/main/autoRun/service.ts@@ -34,7 +34,16 @@ export class AutoRunService {console.log('----- error', error);}}-++ // 根据ID查询进程信息+ async findAutoRunById(id: number) {+ return await this.autoRunRepository.findOne({+ where: {+ id,+ },+ });+ }+// 查询进程列表async findAutoRunList(data: Partial<AutoRunModel>) {return await this.autoRunRepository.find({@@ -50,7 +59,13 @@ export class AutoRunService {}// 创建进程记录- async createAutoRunRecord(data: Partial<AutoRunRecordModel>) {+ async createAutoRunRecord(autoRun: AutoRunModel) {+ const data = {+ userId: autoRun.userId,+ type: autoRun.type,+ cycleType: autoRun.cycleType,+ status: AutoRunRecordStatus.DOING,+ };return await this.autoRunRecordRepository.save(data);}diff --git a/src/icp/autoRun.ts b/src/icp/autoRun.tsindex 1a860012..f6febd8e 100644--- a/src/icp/autoRun.ts+++ b/src/icp/autoRun.ts@@ -1,7 +1,7 @@/** @Author: nevin* @Date: 2025-01-23 15:48:14- * @LastEditTime: 2025-03-18 22:23:06+ * @LastEditTime: 2025-03-19 07:50:43* @LastEditors: nevin* @Description: 自动进程*/@@ -80,3 +80,15 @@ export async function ipcGetAutoRunRecordList() {);return res;}++/**+ * 创建自动进程+ * @param data+ */+export async function ipcCreateAutoRunRecord(autoRunId: number) {+ const res: string = await window.ipcRenderer.invoke(+ 'ICP_AUTO_RUN_RECORD_CREATE',+ autoRunId,+ );+ return res;+}diff --git a/src/views/autoRun/index.tsx b/src/views/autoRun/index.tsxindex b7bb9c1b..d1056eaf 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-19 07:34:14+ * @LastEditTime: 2025-03-19 07:51:47* @LastEditors: nevin* @Description: 评论页面 reply*/@@ -13,6 +13,7 @@ import AddAutoRun, { AddAutoRunRef } from './components/addAutoRun';import {AutoRun,AutoRunRecord,+ ipcCreateAutoRunRecord,ipcGetAutoRunList,ipcGetAutoRunRecordList,} from '@/icp/autoRun';@@ -43,8 +44,8 @@ export default function Page() {* 运行*/async function runAutoRun(data: AutoRun) {- // const res = await icpCreateCommentList(activeAccountId, data.dataId);- // console.log('------ res', res);+ const res = await ipcCreateAutoRunRecord(data.id);+ console.log('------ res', res);}/**