Skip to content

Let's use AI to Earn!

小红书完成

DESKTOP-ZTS2NQJNAf8fc86064739
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 397050ee..98ab3bb8 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -134,14 +134,29 @@ export abstract class PlatformBase {
* @param dataId
* @param pcursor
*/
- abstract getCreatorCommentListByOther(
- account: AccountModel,
- dataId: string,
- pcursor?: string,
- ): Promise<{
- list: CommentData[];
- pageInfo: ResponsePageInfo;
- }>;
+ // abstract getCreatorCommentListByOther(
+ // account: AccountModel,
+ // dataId: string,
+ // pcursor?: string,
+ // ): Promise<{
+ // list: CommentData[];
+ // pageInfo: ResponsePageInfo;
+ // }>;
+
+
+ /**
+ * 获取他人作品的二级评论列表
+ * @param account
+ * @param dataId
+ * @param pcursor
+ */
+ abstract getCreatorSecondCommentListByOther(
+ account: AccountModel,
+ dataId: string,
+ root_comment_id: string,
+ pcursor?: string,
+ ): Promise<any>;
+
/**
* 获取评论列表
diff --git a/electron/main/plat/index.ts b/electron/main/plat/index.ts
index 7471b3fd..9bceacc3 100644
--- a/electron/main/plat/index.ts
+++ b/electron/main/plat/index.ts
@@ -240,6 +240,28 @@ class PlatController {
);
}
+
+ /**
+ * 获取二级评论列表
+ * @param account
+ * @param dataId
+ * @param pcursor
+ */
+ public async getCreatorSecondCommentListByOther(
+ account: AccountModel,
+ dataId: string,
+ root_comment_id: string,
+ pcursor?: string,
+ ) {
+ const platform = this.platforms.get(account.type)!;
+ return await platform.getCreatorSecondCommentListByOther(
+ account,
+ dataId,
+ root_comment_id,
+ pcursor,
+ );
+ }
+
/**
* 创建评论
* @param account
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index 36af6bcc..3d4d5ff6 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -284,6 +284,44 @@ export class Xhs extends PlatformBase {
};
}
+ async getCreatorSecondCommentListByOther(
+ account: AccountModel,
+ dataId: string,
+ root_comment_id: string,
+ pcursor?: string,
+ ) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ console.log('------ getCreatorSecondCommentListByOther xhs dataId---', dataId);
+ const res = await xiaohongshuService.getSecondCommentList(cookie, dataId, root_comment_id, pcursor );
+ console.log('------ getCreatorSecondCommentListByOther xhs res---', res);
+
+ const list: CommentData[] = [];
+
+ for (const v of res.data.data.comments) {
+
+ list.push({
+ userId: v.user_info.user_id,
+ 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,
+ subCommentList: [],
+ });
+ }
+
+ return {
+ list: list,
+ pageInfo: {
+ hasMore: res.data.data.has_more,
+ pcursor: res.data.data.cursor,
+ },
+ };
+ }
+
async createCommentByOther(
account: AccountModel,
dataId: string, // 作品ID
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 233d436b..485d24e5 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -130,6 +130,30 @@ export class ReplyController {
return res;
}
+
+ /**
+ * 获取二级评论列表
+ */
+ @Icp('ICP_SECOND_COMMENT_LIST_BY_OTHER')
+ async getSecondCommentListByOther(
+ event: Electron.IpcMainInvokeEvent,
+ accountId: number,
+ dataId: string,
+ root_comment_id: string,
+ pcursor?: string,
+ ): Promise<any> {
+ const account = await this.accountService.getAccountById(accountId);
+ if (!account) return null;
+
+ const res = await platController.getCreatorSecondCommentListByOther(
+ account,
+ dataId,
+ root_comment_id,
+ pcursor,
+ );
+ return res;
+ }
+
/**
* 创建评论
*/
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index c4891328..bd5275aa 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -43,6 +43,8 @@ export type XSLPlatformSettingType = {
privacy: boolean;
};
+let esec_token = 'ABrmhLmsdmsu9bCQ80qvGPN2CYSjEqwi5G1l2dirNUjaw%3D';
+
export class XiaohongshuService {
private defaultUserAgent =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36';
@@ -1419,7 +1421,7 @@ export class XiaohongshuService {
noteId: string,
cursor?: number,
) {
- const url = `/api/sns/web/v2/comment/page?note_id=${noteId}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=AB_MsaT7Zyowo9N1n4eq0PL4xN9QLxe6JstFjA_Isc9x8%3D`;
+ const url = `/api/sns/web/v2/comment/page?note_id=${noteId}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=${esec_token}`;
const reverseRes: any = await this.getReverseResult({
url,
a1: CookieToString(cookie),
@@ -1444,6 +1446,40 @@ export class XiaohongshuService {
return res;
}
+
+ // 获取二级评论列表
+ async getSecondCommentList(
+ cookie: Electron.Cookie[],
+ noteId: string,
+ root_comment_id: string,
+ cursor?: string,
+ ) {
+ const url = `/api/sns/web/v2/comment/sub/page?note_id=${noteId}&root_comment_id=${root_comment_id}&num=10&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=${esec_token}`;
+ const reverseRes: any = await this.getReverseResult({
+ url,
+ a1: CookieToString(cookie),
+ });
+
+ const res = await requestNet<XhsCommentListResponse>({
+ url: `https://edith.xiaohongshu.com${url}`,
+ headers: {
+ cookie: CookieToString(cookie),
+ Referer: this.loginUrlHome,
+ origin: this.loginUrlHome,
+ 'X-S': reverseRes['X-s'],
+ 'X-T': reverseRes['X-t'],
+ userAgent:
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',
+ },
+ method: 'GET',
+ });
+
+ console.log('------- xhs getSecondCommentList ---', res);
+
+ return res;
+ }
+
+
/**
* 点赞作品
* @param cookie
@@ -1484,7 +1520,7 @@ export class XiaohongshuService {
}
/**
- * 点赞作品
+ * 收藏作品
* @param cookie
* @param noteId
* @param content
diff --git a/src/icp/replyother.ts b/src/icp/replyother.ts
index e2a25c5c..f677f7e4 100644
--- a/src/icp/replyother.ts
+++ b/src/icp/replyother.ts
@@ -100,6 +100,25 @@ export async function icpGetCommentListByOther(
return res;
}
+/**
+ * 获取二级评论列表
+ */
+export async function icpGetSecondCommentListByOther(
+ accountId: number,
+ dataId: string,
+ root_comment_id: string,
+ pcursor?: string,
+) {
+ const res: any = await window.ipcRenderer.invoke(
+ 'ICP_SECOND_COMMENT_LIST_BY_OTHER',
+ accountId,
+ dataId,
+ root_comment_id,
+ pcursor,
+ );
+ return res;
+}
+
/**
* 创建评论
*/
diff --git a/src/views/replyother/components/replyComment.tsx b/src/views/replyother/components/replyComment.tsx
index b7ef1df9..9340c3ba 100644
--- a/src/views/replyother/components/replyComment.tsx
+++ b/src/views/replyother/components/replyComment.tsx
@@ -43,7 +43,7 @@ const Com = forwardRef<ReplyCommentRef>((props: any, ref) => {
comment: commentData!.data,
},
);
- console.log('----- replyComment res', res);
+ console.log('----- replyComment res', res);
if (res.status_code == 0 || res.data.code == 0) {
message.success('回复成功');
setIsModalOpen(false);
diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsx
index adbb9d9a..f9651b65 100644
--- a/src/views/replyother/index.tsx
+++ b/src/views/replyother/index.tsx
@@ -8,6 +8,7 @@
import {
icpCreatorList,
icpGetCommentListByOther,
+ icpGetSecondCommentListByOther,
WorkData,
CommentData,
icpCreateCommentList,
@@ -21,10 +22,12 @@ import ReplyWorks, { ReplyWorksRef } from './components/replyWorks';
import ReplyComment, { ReplyCommentRef } from './components/replyComment';
import AddAutoRun, { AddAutoRunRef } from './components/addAutoRun';
import { icpDianzanDyOther, icpShoucangDyOther } from '@/icp/replyother';
+import { commentApi } from '@/api/comment';
export default function Page() {
const [wordList, setWordList] = useState<WorkData[]>([]);
const [commentList, setCommentList] = useState<CommentData[]>([]);
+ const [secondCommentList, setSecondCommentList] = useState<any[]>([]);
const [activeAccountId, setActiveAccountId] = useState<number>(-1);
const Ref_ReplyWorks = useRef<ReplyWorksRef>(null);
const Ref_AddAutoRun = useRef<AddAutoRunRef>(null);
@@ -36,11 +39,21 @@ export default function Page() {
return;
}
const thisida = thisid ? thisid : activeAccountId;
+ console.log('------ getCreatorList thisida', thisida);
const res = await icpCreatorList(thisida);
console.log('------ icpCreatorList', res);
setWordList(res.list);
}
+ async function getFwqCreatorList() {
+ setWordList([]);
+ const res = await commentApi.runCommentSearchNotesTask('xhs_comments', '美妆');
+ console.log('------ getFwqCreatorList', res);
+ // setWordList(res.list);
+ const list = await commentApi.getCommentSearchNotes('xhs_comments', '414381229d04c46cb39f97a5a0b7f9eb');
+ console.log('------ getCommentSearchNotes', list);
+ }
+
/**
* 获取评论列表
*/
@@ -49,13 +62,30 @@ export default function Page() {
const res = await icpGetCommentListByOther(
activeAccountId,
// '7480598266392972596',
- '67d624a2000000001d02c637',
+ '67dfda09000000000903912c',
);
console.log('------ icpGetCommentList', res);
setCommentList(res.list);
}
+
+ /**
+ * 获取二级评论列表
+ */
+ async function getSecondCommentList(item: any) {
+ const res = await icpGetSecondCommentListByOther(
+ activeAccountId,
+ // '7480598266392972596',
+ item.dataId,
+ item.data.id,
+ item.data.sub_comment_cursor
+ );
+ console.log('------ icpGetCommentList', res);
+
+ setSecondCommentList(res.list);
+ }
+
/**
* 一键AI评论
*/
@@ -132,14 +162,21 @@ export default function Page() {
activeAccountId={activeAccountId}
onAccountChange={useCallback(
(info) => {
- setActiveAccountId(info.id);
- getCreatorList(info.id);
+ console.log('------ onAccountChange', info);
+ if (info.type == 'xhs') {
+ setActiveAccountId(info.id);
+ // getFwqCreatorList();
+ getCreatorList(info.id);
+ }else{
+ setActiveAccountId(info.id);
+ getCreatorList(info.id);
+ }
},
[getCreatorList],
)}
/>
</Col>
- <Col span={10}>
+ <Col span={8}>
<div>
{wordList.map((item) => (
<Card
@@ -201,7 +238,7 @@ export default function Page() {
))}
</div>
</Col>
- <Col span={10}>
+ <Col span={6}>
<div>
{commentList.map((item) => (
<Card
@@ -211,6 +248,43 @@ export default function Page() {
<Button type="primary" onClick={() => openReplyComment(item)}>
回复
</Button>,
+ <Button type="primary" onClick={() => getSecondCommentList(item)}>
+ {item.data.sub_comment_has_more ? '二级评论' : '无'}
+ </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>
+
+
+
+ <Col span={6}>
+ <div>
+ {secondCommentList.map((item) => (
+ <Card
+ key={item.commentId}
+ style={{ width: 300 }}
+ actions={[
+ <Button type="primary" onClick={() => openReplyComment(item)}>
+ 回复
+ </Button>,
+
]}
>
{item.content}