Skip to content

Let's use AI to Earn!

feat: 小红书评论列表

牛文政c81d032f5b5c
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 3d329dbe..013b18a1 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -108,8 +108,9 @@ export abstract class PlatformBase {
},
): Promise<{
list: CommentData[];
- count: number;
- pcursor?: number; // 下一页的游标
+ count?: number;
+ hasMore?: boolean;
+ pcursor?: string; // 下一页的游标
}>;
/**
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index a175ef20..382b1366 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -8,6 +8,7 @@
import { PlatformBase } from '../../PlatformBase';
import {
AccountInfoTypeRV,
+ CommentData,
CookiesType,
DashboardData,
IAccountInfoParams,
@@ -171,11 +172,22 @@ export class Xhs extends PlatformBase {
async getCommentList(account: AccountModel, dataId: string) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- const ret = await xiaohongshuService.getCommentList(cookie, dataId);
+ const res = await xiaohongshuService.getCommentList(cookie, dataId);
+ const list: CommentData[] = res.data.data.comments.map((v) => ({
+ dataId: v.note_id,
+ commentId: v.id,
+ parentCommentId: undefined,
+ content: v.content,
+ likeCount: Number.parseInt(v.like_count),
+ nikeName: v.user_info.nickname,
+ headUrl: v.user_info.image,
+ data: v,
+ }));
return {
- list: [],
- count: 0,
+ list: list,
+ hasMore: res.data.data.has_more,
+ pcursor: res.data.data.cursor,
};
}
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index fafa34a9..73a8dbea 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -1419,7 +1419,7 @@ export class XiaohongshuService {
a1: CookieToString(cookie),
});
- return await requestNet<XhsCommentListResponse>({
+ const res = await requestNet<XhsCommentListResponse>({
url: `https://edith.xiaohongshu.com${url}`,
headers: {
cookie: CookieToString(cookie),
@@ -1432,6 +1432,10 @@ export class XiaohongshuService {
},
method: 'GET',
});
+
+ console.log('---------- 获取评论列表 ---------- res', res);
+
+ return res;
}
/**
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index a060dab4..6dccaa61 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -12,10 +12,11 @@ import {
icpReplyComment,
WorkData,
} from '@/icp/reply';
-import { Button } from 'antd';
+import { Button, Card, Col, Row } from 'antd';
import { useCallback, useState } from 'react';
import AccountSidebar from '../account/components/AccountSidebar/AccountSidebar';
import styles from './reply.module.scss';
+import Meta from 'antd/es/card/Meta';
export default function Page() {
const [wordList, setWordList] = useState<WorkData[]>([]);
@@ -43,8 +44,9 @@ export default function Page() {
*/
async function getCommentList(dataId: string) {
const res = await icpGetCommentList(activeAccountId, dataId);
- setWordList(res.list);
console.log('----- res', res);
+
+ setWordList(res.list);
}
/**
@@ -76,62 +78,69 @@ export default function Page() {
return (
<div className={styles.reply}>
- <p>评论</p>
- <div>
- <AccountSidebar
- activeAccountId={activeAccountId}
- onAccountChange={useCallback(
- (info) => {
- console.log('----- info', info);
-
- setActiveAccountId(info.id);
- getCreatorList();
- },
- [getCreatorList],
- )}
- />
- </div>
- <div>
- <div>
- {wordList.map((item) => (
- <div key={item.dataId}>
- {item.title}
- <Button
- type="primary"
- onClick={() => getCommentList(item.dataId)}
- >
- 获取评论列表
- </Button>
-
- <Button
- type="primary"
- onClick={() => {
- createComment(item.dataId);
- }}
+ <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: 200 }}
+ cover={<img alt="example" src={item.coverUrl} />}
+ actions={[
+ <Button
+ type="primary"
+ onClick={() => getCommentList(item.dataId)}
+ >
+ 评论列表
+ </Button>,
+ <Button
+ type="primary"
+ onClick={() => {
+ createComment(item.dataId);
+ }}
+ >
+ 评论作品
+ </Button>,
+ ]}
>
- 评论作品
- </Button>
- </div>
- ))}
- </div>
- </div>
- <div>
- <div>
- {commentList.map((item) => (
- <div key={item.dataId}>
- <p> {item.title}</p>
- <p>
- <Button
- type="primary"
- // onClick={() => replyComment(item.dataId)}
- >
- 回复该评论
- </Button>
- </p>
- </div>
- ))}
- </div>
- </div>
+ <Meta
+ title={item.title}
+ description="This is the description"
+ />
+ </Card>
+ ))}
+ </div>
+ </Col>
+ <Col span={10}>
+ <div>
+ {commentList.map((item) => (
+ <div key={item.dataId}>
+ <p> {item.title}</p>
+ <p>
+ <Button
+ type="primary"
+ // onClick={() => replyComment(item.dataId)}
+ >
+ 回复
+ </Button>
+ </p>
+ </div>
+ ))}
+ </div>
+ </Col>
+ </Row>
</div>
);
}