Skip to content

Let's use AI to Earn!

feat: 作品一键回复

牛文政9efdedb9fa08
diff --git a/electron/main/api/tools.ts b/electron/main/api/tools.ts
index 7dd7650f..31852c59 100644
--- a/electron/main/api/tools.ts
+++ b/electron/main/api/tools.ts
@@ -2,21 +2,28 @@ import netRequest from '.';
class ToolsApi {
// 获取AI的评论回复
- async aiRecoverReview(data: {
+ async aiRecoverReview(inData: {
content: string;
title?: string;
desc?: string;
max?: number;
- }): Promise<any> {
- const res = await netRequest<any>({
+ }): Promise<string> {
+ const res = await netRequest<{
+ data: string;
+ code: number;
+ msg: string;
+ }>({
method: 'POST',
url: 'tools/ai/recover/review',
- body: data,
+ body: inData,
});
-
- console.log('------ res', res);
-
- return res;
+ const {
+ status,
+ data: { data, code },
+ } = res;
+ if (status !== 200 && status !== 201) return '';
+ if (!!code) return '';
+ return data;
}
}
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index b936eb58..8ca9c503 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -85,12 +85,6 @@ export class ReplyController {
accountId: number,
dataId: string,
): Promise<any> {
- const res1 = await toolsApi.aiRecoverReview({
- content: '今天天气真好',
- });
-
- console.log('------ res1', res1);
-
const account = await this.accountService.getAccountById(accountId);
if (!account) return null;
@@ -118,7 +112,11 @@ export class ReplyController {
// 2. 循环AI回复评论
for (const element of list) {
- platController.replyComment(account, element.commentId, '嗨', {
+ const aiRes = await toolsApi.aiRecoverReview({
+ content: element.content,
+ });
+
+ platController.replyComment(account, element.commentId, aiRes, {
dataId,
comment: element,
});
diff --git a/src/views/reply/interact.tsx b/src/views/reply/interact.tsx
new file mode 100644
index 00000000..e69de29b