Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
pingraren
DESKTOP-ZTS2NQJNA16d420b4b63a
diff --git a/src/icp/replyother.ts b/src/icp/replyother.tsnew file mode 100644index 00000000..285f3513--- /dev/null+++ b/src/icp/replyother.ts@@ -0,0 +1,146 @@+/*+ * @Author: nevin+ * @Date: 2025-01-23 15:48:14+ * @LastEditTime: 2025-03-20 22:39:03+ * @LastEditors: nevin+ * @Description:+ */+export type WorkData = {+ dataId: string;+ readCount?: number;+ likeCount?: number;+ collectCount?: number;+ forwardCount?: number;+ commentCount?: number; // 评论数量+ income?: number;+ title?: string;+ desc?: string;+ coverUrl?: string;+ videoUrl?: string;+};++export type CommentData = {+ dataId: string;+ commentId: string;+ parentCommentId?: string; // 上级评论ID+ content: string;+ likeCount?: number; // 点赞次数+ nikeName?: string;+ headUrl?: string;+ data: any; // 原数据+ subCommentList: CommentData[]; // 子数据+};++export enum PageType {+ paging = 'paging',+ cursor = 'cursor',+}++/**+ * 获取作品列表+ */+export async function icpCreatorList(accountId: number, pcursor?: string) {+ const res: {+ list: WorkData[];+ pageInfo: {+ pageType: PageType;+ count?: number;+ hasMore?: boolean;+ pcursor?: string;+ };+ } = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId, pcursor);+ return res;+}++/**+ * 获取评论列表+ */+export async function icpGetCommentList(+ accountId: number,+ dataId: string,+ pcursor?: string,+) {+ const res: {+ list: CommentData[];+ pageInfo: {+ count?: number;+ hasMore: boolean;+ pcursor?: string;+ };+ } = await window.ipcRenderer.invoke(+ 'ICP_COMMENT_LIST',+ accountId,+ dataId,+ pcursor,+ );+ return res;+}++/**+ * 创建评论+ */+export async function icpCreateComment(+ accountId: number,+ dataId: string,+ content: string,+) {+ const res: boolean = await window.ipcRenderer.invoke(+ 'ICP_CREATE_COMMENT',+ accountId,+ dataId,+ content,+ );+ return res;+}++/**+ * 回复评论+ */+export async function icpReplyComment(+ accountId: number,+ commentId: string,+ content: string,+ option: {+ dataId?: string; // 作品ID+ comment: any; // 辅助数据,原数据+ },+) {+ const res: boolean = await window.ipcRenderer.invoke(+ 'ICP_REPLY_COMMENT',+ accountId,+ commentId,+ content,+ option,+ );+ return res;+}++/**+ * 一键作品回复评论+ */+export async function icpCreateCommentList(accountId: number, dataId: string) {+ const res: boolean = await window.ipcRenderer.invoke(+ 'ICP_REPLY_COMMENT_LIST_BY_AI',+ accountId,+ dataId,+ );+ return res;+}++/**+ * 创建一键回复自动进程+ * @param data+ */+export async function ipcCreateAutoRunOfReply(+ accountId: number,+ dataId: string, // 作品ID+ cycleType: string,+) {+ const res: string = await window.ipcRenderer.invoke(+ 'ICP_AUTO_RUN_CREATE_REPLY',+ accountId,+ dataId,+ cycleType,+ );+ return res;+}diff --git a/src/router/index.tsx b/src/router/index.tsxindex 66fbb776..fc6157e5 100644--- a/src/router/index.tsx+++ b/src/router/index.tsx@@ -44,6 +44,7 @@ import UserWalletAccount from '@/views/finance/userWalletAccount';import Finance from '@/views/finance/index';import UserWalletRecord from '@/views/finance/userWalletRecord';import Reply from '@/views/reply';+import Replyother from '@/views/replyother';import ErrorBoundary from '../components/ErrorBoundary/ErrorBoundary';import AutoRun from '@/views/autoRun';@@ -121,6 +122,11 @@ export const router: CustomRouteObject[] = [element: <Reply />,meta: { name: '评论', icon: MessageOutlined },},+ {+ path: '/Replyother',+ element: <Replyother />,+ meta: { name: '评他人', icon: MessageOutlined },+ },{path: '/autoRun',element: <AutoRun />,diff --git a/src/views/replyother/components/addAutoRun.tsx b/src/views/replyother/components/addAutoRun.tsxnew file mode 100644index 00000000..5f44ecf2--- /dev/null+++ b/src/views/replyother/components/addAutoRun.tsx@@ -0,0 +1,74 @@+/*+ * @Author: nevin+ * @Date: 2025-03-18 21:02:38+ * @LastEditTime: 2025-03-20 22:38:42+ * @LastEditors: nevin+ * @Description: 添加自动运行+ */+import { ipcCreateAutoRunOfReply } from '@/icp/reply';+import { Button, Input, Modal } from 'antd';+import { forwardRef, useImperativeHandle, useState } from 'react';++export interface AddAutoRunRef {+ init: (accountId: number, dataId: string) => Promise<void>;+}++const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {+ const [isModalOpen, setIsModalOpen] = useState(false);+ const [accountId, setAccountId] = useState<number>(0);+ const [dataId, setDataId] = useState<string>('');+ // '周期类型 天 day-22 (例:每天22时) 周 week-2 (例:每周周二,周日0) 月 month-22 (例:每月22号)',+ const [cycleType, setCycleType] = useState<string>('');+ async function init(accountId: number, dataId: string) {+ setAccountId(accountId);+ setDataId(dataId);+ setIsModalOpen(true);+ }++ useImperativeHandle(ref, () => ({+ init: init,+ }));++ function handleCancel() {+ setIsModalOpen(false);+ }++ async function onFinish() {+ console.log('-------- accountId', accountId);+ console.log('-------- dataId', dataId);+ console.log('-------- cycleType', cycleType);++ const res = await ipcCreateAutoRunOfReply(accountId, dataId, cycleType);+ console.log('-------- res', res);+ }++ return (+ <>+ <Modal+ title="创建自动回复评论任务"+ open={isModalOpen}+ onCancel={handleCancel}+ footer={null}+ width={800}+ >+ <p>账号ID{accountId}</p>+ <p>账号ID{accountId}</p>+ <p>+ 周期类型 天 day-22 例:每天22时 周 week-2 例:每周周二,周日0 月 month-22+ 例:每月22号+ </p>++ <Input+ onChange={(e) => {+ setCycleType(e.target.value);+ }}+ />++ <Button type="primary" onClick={onFinish}>+ 创建+ </Button>+ </Modal>+ </>+ );+});+export default Com;diff --git a/src/views/replyother/components/replyComment.tsx b/src/views/replyother/components/replyComment.tsxnew file mode 100644index 00000000..94d4c366--- /dev/null+++ b/src/views/replyother/components/replyComment.tsx@@ -0,0 +1,109 @@+import { toolsApi } from '@/api/tools';+import { CommentData, icpReplyComment } from '@/icp/reply';+import { Button, Form, Input, Modal } from 'antd';+import { forwardRef, useImperativeHandle, useState } from 'react';++export interface ReplyCommentRef {+ init: (accountId: number, inInfo: CommentData) => Promise<void>;+}++interface FormData {+ content: string;+}++const Com = forwardRef<ReplyCommentRef>((props: any, ref) => {+ const [isModalOpen, setIsModalOpen] = useState(false);+ const [accountId, setAccountId] = useState<number>(0);+ const [commentData, setCommentData] = useState<CommentData | null>(null);+ const [form] = Form.useForm<FormData>();+ async function init(accountId: number, inInfo: CommentData) {+ setAccountId(accountId);+ setCommentData(inInfo);+ setIsModalOpen(true);+ }++ useImperativeHandle(ref, () => ({+ init: init,+ }));++ function handleCancel() {+ setIsModalOpen(false);+ }++ /**+ * 回复评论+ */+ async function replyComment(content: string) {+ const res = await icpReplyComment(+ accountId,+ commentData!.commentId,+ content,+ {+ dataId: commentData!.dataId,+ comment: commentData!.data,+ },+ );+ console.log('----- res', res);+ }++ async function onFinish(values: FormData) {+ await replyComment(values.content);+ console.log('Success:', values);+ }++ async function onFinishFailed(errorInfo: any) {+ console.log('Failed:', errorInfo);+ }++ async function getAiContent() {+ if (!commentData?.content) return;+ const res = await toolsApi.apiReviewAiRecover({+ content: commentData?.content,+ });++ form.setFieldsValue({+ content: res,+ });+ }++ return (+ <>+ <Modal+ title={null}+ open={isModalOpen}+ onCancel={handleCancel}+ footer={null}+ width={800}+ >+ <Form+ form={form}+ name="basic"+ labelCol={{ span: 8 }}+ wrapperCol={{ span: 16 }}+ initialValues={{ remember: true }}+ onFinish={onFinish}+ onFinishFailed={onFinishFailed}+ autoComplete="off"+ >+ <Form.Item+ label="content"+ name="content"+ rules={[{ required: true, message: '请输入评论!' }]}+ >+ <Input />+ </Form.Item>++ <Form.Item wrapperCol={{ offset: 8, span: 16 }}>+ <Button type="primary" onClick={getAiContent}>+ AI建议+ </Button>+ <Button type="primary" htmlType="submit">+ 提交+ </Button>+ </Form.Item>+ </Form>+ </Modal>+ </>+ );+});+export default Com;diff --git a/src/views/replyother/components/replyWorks.tsx b/src/views/replyother/components/replyWorks.tsxnew file mode 100644index 00000000..9bd56f84--- /dev/null+++ b/src/views/replyother/components/replyWorks.tsx@@ -0,0 +1,104 @@+import { toolsApi } from '@/api/tools';+import { icpCreateComment, WorkData } from '@/icp/reply';+import { Button, Form, Input, Modal } from 'antd';+import { forwardRef, useImperativeHandle, useState } from 'react';++export interface ReplyWorksRef {+ init: (accountId: number, inWorkData: WorkData) => Promise<void>;+}++interface FormData {+ content: string;+}++const Com = forwardRef<ReplyWorksRef>((props: any, ref) => {+ const [isModalOpen, setIsModalOpen] = useState(false);+ const [accountId, setAccountId] = useState<number>(0);+ const [workData, setWorkData] = useState<WorkData | null>(null);+ const [form] = Form.useForm<FormData>();++ async function init(accountId: number, inWorkData: WorkData) {+ setAccountId(accountId);+ setWorkData(inWorkData);+ setIsModalOpen(true);+ }++ useImperativeHandle(ref, () => ({+ init: init,+ }));++ function handleCancel() {+ setIsModalOpen(false);+ }++ /**+ * 创建评论+ */+ async function createComment(content: string) {+ const res = await icpCreateComment(accountId, workData!.dataId, content);+ console.log('----- res', res);+ }++ async function onFinish(values: FormData) {+ createComment(values.content);+ }++ async function onFinishFailed(errorInfo: any) {+ console.log('Failed:', errorInfo);+ }++ async function getAiContent() {+ if (!workData?.coverUrl) return;+ const res = await toolsApi.apiReviewImgAi({+ imgUrl: workData?.coverUrl,+ });++ console.log('----- res', res);++ form.setFieldsValue({+ content: res,+ });+ }++ return (+ <>+ <Modal+ title={null}+ open={isModalOpen}+ onCancel={handleCancel}+ footer={null}+ width={800}+ >+ <Form+ form={form}+ name="basic"+ labelCol={{ span: 8 }}+ wrapperCol={{ span: 16 }}+ initialValues={{ remember: true }}+ onFinish={onFinish}+ onFinishFailed={onFinishFailed}+ autoComplete="off"+ >+ <Form.Item+ label="评论"+ name="content"+ rules={[{ required: true, message: '请输入评论!' }]}+ >+ <Input />+ </Form.Item>++ <Form.Item wrapperCol={{ offset: 8, span: 16 }}>+ <Button type="primary" onClick={getAiContent}>+ AI建议+ </Button>++ <Button type="primary" htmlType="submit">+ 提交评论+ </Button>+ </Form.Item>+ </Form>+ </Modal>+ </>+ );+});+export default Com;diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsxnew file mode 100644index 00000000..3c8800a2--- /dev/null+++ b/src/views/replyother/index.tsx@@ -0,0 +1,182 @@+/*+ * @Author: nevin+ * @Date: 2025-02-10 22:20:15+ * @LastEditTime: 2025-03-20 21:28:52+ * @LastEditors: nevin+ * @Description: 评论页面 reply+ */+import {+ icpCreatorList,+ icpGetCommentList,+ WorkData,+ CommentData,+ icpCreateCommentList,+} from '@/icp/replyother';+import { Avatar, Button, Card, Col, Row } from 'antd';+import { useCallback, useRef, useState } from 'react';+import AccountSidebar from '../account/components/AccountSidebar/AccountSidebar';+import styles from './reply.module.scss';+import Meta from 'antd/es/card/Meta';+import ReplyWorks, { ReplyWorksRef } from './components/replyWorks';+import ReplyComment, { ReplyCommentRef } from './components/replyComment';+import AddAutoRun, { AddAutoRunRef } from './components/addAutoRun';++export default function Page() {+ const [wordList, setWordList] = useState<WorkData[]>([]);+ const [commentList, setCommentList] = useState<CommentData[]>([]);+ const [activeAccountId, setActiveAccountId] = useState<number>(-1);+ const Ref_ReplyWorks = useRef<ReplyWorksRef>(null);+ const Ref_AddAutoRun = useRef<AddAutoRunRef>(null);+ const Ref_ReplyComment = useRef<ReplyCommentRef>(null);++ async function getCreatorList() {+ if (activeAccountId === -1) {+ return;+ }+ setWordList([]);++ const res = await icpCreatorList(activeAccountId);++ setWordList(res.list);+ }++ /**+ * 获取评论列表+ */+ async function getCommentList(dataId: string) {+ const res = await icpGetCommentList(activeAccountId, dataId);+ console.log('------ res', res);++ setCommentList(res.list);+ }++ /**+ * 一键AI评论+ */+ async function createCommentList(data: WorkData) {+ const res = await icpCreateCommentList(activeAccountId, data.dataId);+ console.log('------ res', res);+ }++ /**+ * 打开作品评论+ * @param data+ */+ function openReplyWorks(data: WorkData) {+ Ref_ReplyWorks.current?.init(activeAccountId, data);+ }++ /**+ * 打开评论回复+ * @param data+ */+ function openReplyComment(data: CommentData) {+ Ref_ReplyComment.current?.init(activeAccountId, data);+ }++ /**+ * 打开创建自动任务+ * @param data+ */+ function openAddAutoRun(data: WorkData) {+ Ref_AddAutoRun.current?.init(activeAccountId, data.dataId);+ }++ return (+ <div className={styles.reply}>+ <Row>+ <Col span={4}>+ <AccountSidebar+ activeAccountId={activeAccountId}+ onAccountChange={useCallback(+ (info) => {+ setActiveAccountId(info.id);+ getCreatorList();+ },+ [getCreatorList],+ )}+ />+ </Col>+ <Col span={10}>+ <div>+ {wordList.map((item) => (+ <Card+ key={item.dataId}+ style={{ width: 500 }}+ cover={<img alt="example" src={item.coverUrl} />}+ actions={[+ <Button+ type="primary"+ onClick={() => getCommentList(item.dataId)}+ >+ 评论列表+ </Button>,+ <Button+ type="primary"+ onClick={() => {+ openReplyWorks(item);+ }}+ >+ 评论作品+ </Button>,+ <Button+ type="primary"+ onClick={() => {+ createCommentList(item);+ }}+ >+ 一键AI评论+ </Button>,+ <Button+ type="primary"+ onClick={() => {+ openAddAutoRun(item);+ }}+ >+ 创建自动任务+ </Button>,+ ]}+ >+ <Meta title={item.title} />+ </Card>+ ))}+ </div>+ </Col>+ <Col span={10}>+ <div>+ {commentList.map((item) => (+ <Card+ key={item.commentId}+ style={{ width: 300 }}+ actions={[+ <Button type="primary" onClick={() => openReplyComment(item)}>+ 回复+ </Button>,+ ]}+ >+ {item.content}+ {item.subCommentList.map((subItem) => (+ <div key={subItem.commentId}>+ {subItem.content}+ <Meta+ avatar={<Avatar src={subItem.headUrl} />}+ description={subItem.nikeName}+ />+ </div>+ ))}+ <Meta+ avatar={<Avatar src={item.headUrl} />}+ description={item.nikeName}+ />+ </Card>+ ))}+ </div>+ </Col>+ </Row>++ <ReplyWorks ref={Ref_ReplyWorks} />+ <ReplyComment ref={Ref_ReplyComment} />+ <AddAutoRun ref={Ref_AddAutoRun} />+ </div>+ );+}diff --git a/src/views/replyother/interact.tsx b/src/views/replyother/interact.tsxnew file mode 100644index 00000000..e69de29bdiff --git a/src/views/replyother/reply.module.scss b/src/views/replyother/reply.module.scssnew file mode 100644index 00000000..be859e55--- /dev/null+++ b/src/views/replyother/reply.module.scss@@ -0,0 +1,5 @@+.reply {+ height: 100%;+ :global {+ }+}\ No newline at end of file