Skip to content

Let's use AI to Earn!

feat: 补充评论的AI接口

牛文政192bd1d1b973
diff --git a/src/api/tools.ts b/src/api/tools.ts
index 8b1034e9..b0bc5a2d 100644
--- a/src/api/tools.ts
+++ b/src/api/tools.ts
@@ -23,6 +23,20 @@ export const toolsApi = {
);
},
+ /**
+ * 智能图文
+ */
+ apiReviewImgAi(data: {
+ imgUrl: string;
+ title?: string;
+ desc?: string;
+ max?: number;
+ }) {
+ return http.post<string>('/tools/ai/reviewImg', data, {
+ isToken: true,
+ });
+ },
+
/**
* 智能评论
*/
diff --git a/src/views/reply/components/replyWorks.tsx b/src/views/reply/components/replyWorks.tsx
index 2229ea0c..eaff1a85 100644
--- a/src/views/reply/components/replyWorks.tsx
+++ b/src/views/reply/components/replyWorks.tsx
@@ -1,3 +1,4 @@
+import { toolsApi } from '@/api/tools';
import { icpCreateComment, WorkData } from '@/icp/reply';
import { Button, Form, Input, Modal } from 'antd';
import { forwardRef, useImperativeHandle, useState } from 'react';
@@ -15,6 +16,7 @@ const Com = forwardRef<ReplyWorksRef>((props: any, ref) => {
const [accountId, setAccountId] = useState<number>(0);
const [workData, setWorkData] = useState<WorkData | null>(null);
const [formData, setFormData] = useState<Partial<FormData>>();
+ const [form] = Form.useForm<FormData>();
async function init(accountId: number, inWorkData: WorkData) {
setAccountId(accountId);
@@ -46,6 +48,17 @@ const Com = forwardRef<ReplyWorksRef>((props: any, ref) => {
console.log('Failed:', errorInfo);
}
+ async function getAiContent() {
+ if (!workData?.coverUrl) return;
+ const res = await toolsApi.apiReviewImgAi({
+ imgUrl: workData?.coverUrl,
+ });
+
+ form.setFieldsValue({
+ content: res,
+ });
+ }
+
return (
<>
<Modal
@@ -73,6 +86,10 @@ const Com = forwardRef<ReplyWorksRef>((props: any, ref) => {
</Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
+ <Button type="primary" onClick={getAiContent}>
+ AI建议
+ </Button>
+
<Button type="primary" htmlType="submit">
提交评论
</Button>