Skip to content

Let's use AI to Earn!

feat: 页面整理

yikaJasonMiccea9731613fd
diff --git a/src/views/reply/components/addAutoRun.tsx b/src/views/reply/components/addAutoRun.tsx
index 5f44ecf2..b57c22de 100644
--- a/src/views/reply/components/addAutoRun.tsx
+++ b/src/views/reply/components/addAutoRun.tsx
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-03-18 21:02:38
- * @LastEditTime: 2025-03-20 22:38:42
+ * @LastEditTime: 2025-03-25 13:41:14
* @LastEditors: nevin
* @Description: 添加自动运行
*/
@@ -34,10 +34,6 @@ const Com = forwardRef<AddAutoRunRef>((props: any, ref) => {
}
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);
}
diff --git a/src/views/reply/components/commentList.tsx b/src/views/reply/components/commentList.tsx
new file mode 100644
index 00000000..7ada6994
--- /dev/null
+++ b/src/views/reply/components/commentList.tsx
@@ -0,0 +1,115 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-03-18 21:02:38
+ * @LastEditTime: 2025-03-25 14:28:36
+ * @LastEditors: nevin
+ * @Description: 评论列表
+ */
+import { CommentData, icpGetCommentList, WorkData } from '@/icp/reply';
+import { Avatar, Button, Card, Col, Modal, Row } from 'antd';
+import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
+import Meta from 'antd/es/card/Meta';
+import ReplyComment, { ReplyCommentRef } from './replyComment';
+
+export interface CommentListRef {
+ init: (accountId: number, workData: WorkData) => Promise<void>;
+}
+
+const Com = forwardRef<CommentListRef>((props: any, ref) => {
+ const [commentList, setCommentList] = useState<CommentData[]>([]);
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const [accountId, setAccountId] = useState<number>(0);
+ const [workData, setWorkData] = useState<WorkData | null>(null);
+ const Ref_ReplyComment = useRef<ReplyCommentRef>(null);
+
+ async function init(accountId: number, workData: WorkData) {
+ setAccountId(accountId);
+ setWorkData(workData);
+ setIsModalOpen(true);
+ }
+
+ useImperativeHandle(ref, () => ({
+ init: init,
+ }));
+
+ function handleCancel() {
+ setIsModalOpen(false);
+ }
+
+ /**
+ * 获取评论列表
+ */
+ async function getCommentList(dataId: string) {
+ const res = await icpGetCommentList(accountId, dataId);
+ setCommentList(res.list);
+ }
+
+ /**
+ * 打开评论回复
+ * @param data
+ */
+ function openReplyComment(data: CommentData) {
+ Ref_ReplyComment.current?.init(accountId, data);
+ }
+
+ /**
+ *
+ * @param param0
+ * @returns
+ */
+ function WorkDataDom() {
+ if (!workData) return <div>数据有误</div>;
+
+ return (
+ <Card
+ style={{ width: 200 }}
+ cover={<img alt="example" src={workData.coverUrl} />}
+ >
+ <Button type="primary" onClick={() => getCommentList(workData.dataId)}>
+ 评论列表
+ </Button>
+ <Meta title={workData.title} />
+ </Card>
+ );
+ }
+
+ return (
+ <>
+ <Modal
+ title="评论列表"
+ open={isModalOpen}
+ onCancel={handleCancel}
+ footer={null}
+ width={1200}
+ >
+ <Row>
+ <Col span={6}>{WorkDataDom()}</Col>
+
+ <Col span={18}>
+ {commentList.map((item) => (
+ <Card key={item.commentId}>
+ <p>
+ <Avatar src={item.headUrl} />
+ {/* <p>{item.nikeName}</p> */}
+ {item.content}
+ <Button type="primary" onClick={() => openReplyComment(item)}>
+ 回复
+ </Button>
+ </p>
+ {item.subCommentList.map((subItem) => (
+ <p key={subItem.commentId}>
+ <Avatar src={subItem.headUrl} />
+ {subItem.content}
+ </p>
+ ))}
+ </Card>
+ ))}
+ </Col>
+ </Row>
+ </Modal>
+
+ <ReplyComment ref={Ref_ReplyComment} />
+ </>
+ );
+});
+export default Com;
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index 0406d589..8b887a4c 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -1,34 +1,26 @@
/*
* @Author: nevin
* @Date: 2025-02-10 22:20:15
- * @LastEditTime: 2025-03-25 13:14:52
+ * @LastEditTime: 2025-03-25 14:17:27
* @LastEditors: nevin
* @Description: 评论页面 reply
*/
-import {
- icpCreatorList,
- icpGetCommentList,
- WorkData,
- CommentData,
- icpCreateCommentList,
-} from '@/icp/reply';
-import { Avatar, Button, Card, Col, message, Row } from 'antd';
+import { icpCreatorList, WorkData, icpCreateCommentList } from '@/icp/reply';
+import { Button, Col, message, 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';
+import CommentList, { CommentListRef } from './components/commentList';
import { SendChannelEnum } from '@@/UtilsEnum';
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);
+ const Ref_CommentList = useRef<CommentListRef>(null);
// 注册监听
(() => {
@@ -51,19 +43,9 @@ export default function Page() {
if (accountId === -1) return;
setWordList([]);
const res = await icpCreatorList(accountId);
- console.log('------ res', res);
-
setWordList(res.list);
}
- /**
- * 获取评论列表
- */
- async function getCommentList(dataId: string) {
- const res = await icpGetCommentList(activeAccountId, dataId);
- setCommentList(res.list);
- }
-
/**
* 一键AI评论
*/
@@ -81,11 +63,11 @@ export default function Page() {
}
/**
- * 打开评论回复
+ * 打开评论列表
* @param data
*/
- function openReplyComment(data: CommentData) {
- Ref_ReplyComment.current?.init(activeAccountId, data);
+ function openCommentList(data: WorkData) {
+ Ref_CommentList.current?.init(activeAccountId, data);
}
/**
@@ -108,86 +90,50 @@ export default function Page() {
}, [])}
/>
</Col>
- <Col span={10}>
+ <Col span={20}>
<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 key={item.dataId}>
+ <img alt="example" src={item.coverUrl} />
+ <p>{item.title}</p>
+ <Button type="primary" onClick={() => openCommentList(item)}>
+ 评论列表
+ </Button>
+
+ <Button
+ type="primary"
+ onClick={() => {
+ openReplyWorks(item);
+ }}
+ >
+ 评论作品
+ </Button>
+ <Button
+ type="primary"
+ onClick={() => {
+ createCommentList(item);
+ }}
+ >
+ 一键AI评论
+ </Button>
+
+ <Button
+ type="primary"
+ onClick={() => {
+ openAddAutoRun(item);
+ }}
+ >
+ 创建自动任务
+ </Button>
+ </div>
))}
</div>
</Col>
</Row>
<ReplyWorks ref={Ref_ReplyWorks} />
- <ReplyComment ref={Ref_ReplyComment} />
<AddAutoRun ref={Ref_AddAutoRun} />
+ <CommentList ref={Ref_CommentList} />
</div>
);
}