Skip to content

Let's use AI to Earn!

feat: 评论页面

牛文政4f508848f1b2
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index 8985d956..ae63f79c 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -212,7 +212,6 @@ export class Kwai extends PlatformBase {
dataId,
pageInfo?.pcursor ? Number.parseInt(pageInfo.pcursor) : undefined,
);
- console.log('------- res ----', res);
const list: CommentData[] = res.data.data.list.map((v) => {
return {
diff --git a/src/views/reply/components/replyComment.tsx b/src/views/reply/components/replyComment.tsx
new file mode 100644
index 00000000..1321f6f8
--- /dev/null
+++ b/src/views/reply/components/replyComment.tsx
@@ -0,0 +1,56 @@
+import { CommentData, icpReplyComment } from '@/icp/reply';
+import { Modal } from 'antd';
+import { forwardRef, useImperativeHandle, useState } from 'react';
+
+export interface ReplyCommentRef {
+ init: (accountId: number, inInfo: CommentData) => Promise<void>;
+}
+
+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);
+
+ async function init(accountId: number, inInfo: CommentData) {
+ setAccountId(accountId);
+ setCommentData(inInfo);
+ setIsModalOpen(true);
+ }
+
+ useImperativeHandle(ref, () => ({
+ init: init,
+ }));
+
+ function handleCancel() {
+ setIsModalOpen(false);
+ }
+
+ /**
+ * 回复评论
+ */
+ async function replyComment(
+ commentId: string,
+ option: {
+ dataId?: string; // 作品ID
+ data: any; // 辅助数据,原数据
+ },
+ ) {
+ const res = await icpReplyComment(accountId, commentId, '真不错', option);
+ console.log('----- res', res);
+ }
+
+ return (
+ <>
+ <Modal
+ title={null}
+ open={isModalOpen}
+ onCancel={handleCancel}
+ footer={null}
+ width={800}
+ >
+ 1111
+ </Modal>
+ </>
+ );
+});
+export default Com;
diff --git a/src/views/reply/components/replyWorks.tsx b/src/views/reply/components/replyWorks.tsx
new file mode 100644
index 00000000..97d1d9da
--- /dev/null
+++ b/src/views/reply/components/replyWorks.tsx
@@ -0,0 +1,57 @@
+import { icpCreateComment, WorkData } from '@/icp/reply';
+import { Button, Modal } from 'antd';
+import { forwardRef, useImperativeHandle, useState } from 'react';
+
+export interface ReplyWorksRef {
+ init: (accountId: number, inWorkData: WorkData) => Promise<void>;
+}
+
+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);
+
+ 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);
+ }
+
+ return (
+ <>
+ <Modal
+ title={null}
+ open={isModalOpen}
+ onCancel={handleCancel}
+ footer={null}
+ width={800}
+ >
+ <Button
+ type="primary"
+ onClick={() => {
+ createComment('测试评论');
+ }}
+ >
+ 测试评论
+ </Button>
+ </Modal>
+ </>
+ );
+});
+export default Com;
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index 561bbcc9..dd2a5bfa 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -6,24 +6,27 @@
* @Description: 评论页面 reply
*/
import {
- icpCreateComment,
icpCreatorList,
icpGetCommentList,
- icpReplyComment,
WorkData,
CommentData,
} from '@/icp/reply';
import { Avatar, Button, Card, Col, Row } from 'antd';
-import { useCallback, useState } from 'react';
+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';
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_ReplyComment = useRef<ReplyCommentRef>(null);
+
async function getCreatorList() {
if (activeAccountId === -1) {
return;
@@ -47,30 +50,19 @@ export default function Page() {
}
/**
- * 创建评论
+ * 打开作品评论
+ * @param data
*/
- async function createComment(dataId: string) {
- const res = await icpCreateComment(activeAccountId, dataId, '真不错');
- console.log('----- res', res);
+ function openReplyWorks(data: WorkData) {
+ Ref_ReplyWorks.current?.init(activeAccountId, data);
}
/**
- * 回复评论
+ * 打开评论回复
+ * @param data
*/
- async function replyComment(
- commentId: string,
- option: {
- dataId?: string; // 作品ID
- data: any; // 辅助数据,原数据
- },
- ) {
- const res = await icpReplyComment(
- activeAccountId,
- commentId,
- '真不错',
- option,
- );
- console.log('----- res', res);
+ function openReplyComment(data: CommentData) {
+ Ref_ReplyComment.current?.init(activeAccountId, data);
}
return (
@@ -105,7 +97,7 @@ export default function Page() {
<Button
type="primary"
onClick={() => {
- createComment(item.dataId);
+ openReplyWorks(item);
}}
>
评论作品
@@ -123,7 +115,11 @@ export default function Page() {
<Card
key={item.commentId}
style={{ width: 300 }}
- actions={[<Button type="primary">回复</Button>]}
+ actions={[
+ <Button type="primary" onClick={() => openReplyComment(item)}>
+ 回复
+ </Button>,
+ ]}
>
{item.content}
<Meta
@@ -135,6 +131,9 @@ export default function Page() {
</div>
</Col>
</Row>
+
+ <ReplyWorks ref={Ref_ReplyWorks} />
+ <ReplyComment ref={Ref_ReplyComment} />
</div>
);
}
diff --git a/src/views/task/components/carInfo.tsx b/src/views/task/components/carInfo.tsx
index fbb490fc..88d676cb 100644
--- a/src/views/task/components/carInfo.tsx
+++ b/src/views/task/components/carInfo.tsx
@@ -40,10 +40,10 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
const res = await taskApi.taskApply(taskInfo?._id);
setTaskInfo(res as any);
setIsModalOpen(false);
-
+
// 添加成功提示
message.success('任务接受成功');
-
+
// 跳转到已参与任务选项卡
const taskTabElement = document.querySelector('[data-tab="mine"]');
if (taskTabElement) {