Skip to content

Let's use AI to Earn!

评论自己的作品

DESKTOP-ZTS2NQJNA101ecb631488
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index f24dcf5c..e049b8dd 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -147,6 +147,16 @@ export abstract class PlatformBase {
): Promise<boolean>;
+
+ /**
+ * 创建评论
+ */
+ abstract createCommentByOther(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ): Promise<any>;
+
/**
* 回复评论
*/
diff --git a/electron/main/plat/index.ts b/electron/main/plat/index.ts
index e7ca68e8..991b6f1a 100644
--- a/electron/main/plat/index.ts
+++ b/electron/main/plat/index.ts
@@ -206,6 +206,22 @@ class PlatController {
}
+ /**
+ * 创建评论
+ * @param account
+ * @param pageInfo
+ */
+ public async createCommentByOther(
+ account: AccountModel,
+ dataId: string,
+ content: string,
+ ) {
+ const platform = this.platforms.get(account.type)!;
+ return await platform.createCommentByOther(account, dataId, content);
+ }
+
+
+
/**
* 回复评论
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index a60c92bc..31d1ecfa 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -294,6 +294,38 @@ export class Douyin extends PlatformBase {
}
+
+
+ async createCommentByOther(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ content: string,
+ ) {
+ // const cookie: CookiesType = JSON.parse(account.loginCookie);
+ // const res = await douyinService.creatorCommentReply(cookie, {
+ // comment_Id: '',
+ // item_id: dataId,
+ // text: content,
+ // });
+
+ // return res.status === 200 && res.data.status_code === 0;
+
+
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await douyinService.creatorCommentReplyOther(cookie, {
+ aweme_id: dataId,
+ text: content,
+ one_level_comment_rank: -1
+ });
+
+ console.log('------ res', res);
+
+ return res;
+
+ }
+
+
+
async createComment(
account: AccountModel,
dataId: string, // 作品ID
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index bb52766a..015f700c 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -99,6 +99,24 @@ export class ReplyController {
return res;
}
+
+ /**
+ * 创建评论
+ */
+ @Icp('ICP_CREATE_COMMENT_BY_OTHER')
+ async createCommentByOther(
+ event: Electron.IpcMainInvokeEvent,
+ accountId: number,
+ dataId: string,
+ content: string,
+ ): Promise<any> {
+ const account = await this.accountService.getAccountById(accountId);
+ if (!account) return null;
+
+ const res = await platController.createCommentByOther(account, dataId, content);
+ return res;
+ }
+
/**
* 作品一键AI评论
*/
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index 7e6b00b0..cecf39b2 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -2377,12 +2377,7 @@ export class DouyinService {
// 回复其他人的评论
async creatorCommentReplyOther(
cookie: Electron.Cookie[],
- data: {
- aweme_id: string; // 空字符串, 直接回复
- reply_id: string; // '@j/do779EQE//uctS8rzvvch6oCaTZCH0JqwsPqxpgahhkia+W5A7RJEoPQpq6PZl7wq9uxSqSWCjcIdbPzF8fQ==';
- text: string; //'哈哈哈';
- one_level_comment_rank: number; // 3
- },
+ data: any,
) {
let thisUri = `https://www.douyin.com/aweme/v1/web/comment/publish/?${jsonToQueryString({
aid: '6383'
diff --git a/src/icp/replyother.ts b/src/icp/replyother.ts
index 62ff686c..572c6ca5 100644
--- a/src/icp/replyother.ts
+++ b/src/icp/replyother.ts
@@ -86,8 +86,8 @@ export async function icpCreateComment(
dataId: string,
content: string,
) {
- const res: boolean = await window.ipcRenderer.invoke(
- 'ICP_CREATE_COMMENT',
+ const res: any = await window.ipcRenderer.invoke(
+ 'ICP_CREATE_COMMENT_BY_OTHER',
accountId,
dataId,
content,
diff --git a/src/views/replyother/components/replyWorks.tsx b/src/views/replyother/components/replyWorks.tsx
index 3f16dac5..f76237ab 100644
--- a/src/views/replyother/components/replyWorks.tsx
+++ b/src/views/replyother/components/replyWorks.tsx
@@ -1,6 +1,6 @@
import { toolsApi } from '@/api/tools';
-import { icpCreateComment, WorkData } from '@/icp/reply';
-import { Button, Form, Input, Modal } from 'antd';
+import { icpCreateComment, WorkData } from '@/icp/replyother';
+import { Button, Form, Input, message, Modal } from 'antd';
import { forwardRef, useImperativeHandle, useState } from 'react';
export interface ReplyWorksRef {
@@ -35,9 +35,15 @@ const Com = forwardRef<ReplyWorksRef>((props: any, ref) => {
* 创建评论
*/
async function createComment(content: string) {
- console.log('----- createComment', accountId, '7480598266392972596', content);
- const res = await icpCreateComment(accountId, '7480598266392972596', content);
+ const res = await icpCreateComment(accountId, '7484585415068880139', content);
console.log('----- res', res);
+ if (res.status_code == 0) {
+ message.success('评论成功');
+ setIsModalOpen(false);
+ } else {
+ message.error('评论失败');
+ }
+
}
async function onFinish(values: FormData) {