Skip to content

Let's use AI to Earn!

feat: 评论列表接入调试完毕

牛文政b1437c3642e9
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index 1c1f050d..8985d956 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -210,8 +210,9 @@ export class Kwai extends PlatformBase {
const res = await kwaiPub.getCommentList(
cookie,
dataId,
- // Number(pageInfo.pcursor),
+ pageInfo?.pcursor ? Number.parseInt(pageInfo.pcursor) : undefined,
);
+ console.log('------- res ----', res);
const list: CommentData[] = res.data.data.list.map((v) => {
return {
@@ -231,8 +232,8 @@ export class Kwai extends PlatformBase {
pageInfo: {
pageType: PageType.cursor,
count: 0,
- pcursor: '',
- hasMore: true,
+ pcursor: res.data.data.pcursor + '',
+ hasMore: !!res.data.data.pcursor,
},
};
}
diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.ts
index b2e4f3c7..1624df3d 100644
--- a/electron/main/plat/platforms/wxSph/index.ts
+++ b/electron/main/plat/platforms/wxSph/index.ts
@@ -182,6 +182,7 @@ export class WxSph extends PlatformBase {
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await shipinhaoService.getCommentList(cookie, dataId);
+ console.log('----- res ----', res);
const dataList = res.comment.map((item) => {
return {
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index cf3fd8e4..370d771f 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -352,7 +352,11 @@ class KwaiPub {
}
// 获取评论列表
- async getCommentList(cookies: Electron.Cookie[], photoId: string) {
+ async getCommentList(
+ cookies: Electron.Cookie[],
+ photoId: string,
+ pcursor?: number,
+ ) {
return await requestNet<GetCommentListResponse>({
url: `https://cp.kuaishou.com/rest/cp/creator/comment/commentList?__NS_sig3=a7b7f0c019bb25938afaf9f86e97581522c66e82e6e6e4e4ebeae9f3`,
method: 'POST',
@@ -364,6 +368,7 @@ class KwaiPub {
sortType: '',
selectedComment: false,
'kuaishou.web.cp.api_ph': '69799694cfd7e689847219cf678dec275266',
+ ...(pcursor ? { pcursor } : {}),
},
});
}
diff --git a/electron/plat/Kwai/kwai.type.ts b/electron/plat/Kwai/kwai.type.ts
index 9f77aaad..e6d3af39 100644
--- a/electron/plat/Kwai/kwai.type.ts
+++ b/electron/plat/Kwai/kwai.type.ts
@@ -172,6 +172,7 @@ export interface GetCommentListResponse {
currentTime: number; // 1741843263417;
'host-name': string; // 'public-bjxy-rs9-kce-node961.idcyz.hb1.kwaidc.com';
data: {
+ pcursor?: number; // 971109198576;
list: [
{
photoId: number; // 157783681361;
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index 73a8dbea..33005268 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -1433,8 +1433,6 @@ export class XiaohongshuService {
method: 'GET',
});
- console.log('---------- 获取评论列表 ---------- res', res);
-
return res;
}
diff --git a/src/icp/reply.ts b/src/icp/reply.ts
index ee2371b2..8ab2accc 100644
--- a/src/icp/reply.ts
+++ b/src/icp/reply.ts
@@ -19,19 +19,41 @@ export type WorkData = {
videoUrl?: string;
};
+export type CommentData = {
+ dataId: string;
+ commentId: string;
+ parentCommentId?: string; // 上级评论ID
+ content: string;
+ likeCount?: number; // 点赞次数
+ nikeName?: string;
+ headUrl?: string;
+ data: any; // 原数据
+};
+
+export enum PageType {
+ paging = 'paging',
+ cursor = 'cursor',
+}
+
/**
* 获取作品列表
*/
export async function icpCreatorList(
accountId: number,
pageInfo: {
- pageNo: number;
- pageSize: number;
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string; // 分页游标
},
) {
const res: {
list: WorkData[];
- count: number;
+ pageInfo: {
+ pageType: PageType;
+ count?: number;
+ hasMore?: boolean;
+ pcursor?: string;
+ };
} = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId, pageInfo);
return res;
}
@@ -39,10 +61,23 @@ export async function icpCreatorList(
/**
* 获取评论列表
*/
-export async function icpGetCommentList(accountId: number, dataId: string) {
+export async function icpGetCommentList(
+ accountId: number,
+ dataId: string,
+ pageInfo: {
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ },
+) {
const res: {
- list: WorkData[];
- count: number;
+ list: CommentData[];
+ pageInfo: {
+ pageType: PageType;
+ count?: number;
+ hasMore?: boolean;
+ pcursor?: string;
+ };
} = await window.ipcRenderer.invoke('ICP_COMMENT_LIST', accountId, dataId);
return res;
}
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index 6dccaa61..561bbcc9 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -11,8 +11,9 @@ import {
icpGetCommentList,
icpReplyComment,
WorkData,
+ CommentData,
} from '@/icp/reply';
-import { Button, Card, Col, Row } from 'antd';
+import { Avatar, Button, Card, Col, Row } from 'antd';
import { useCallback, useState } from 'react';
import AccountSidebar from '../account/components/AccountSidebar/AccountSidebar';
import styles from './reply.module.scss';
@@ -20,11 +21,10 @@ import Meta from 'antd/es/card/Meta';
export default function Page() {
const [wordList, setWordList] = useState<WorkData[]>([]);
- const [commentList, setComment] = useState<WorkData[]>([]);
+ const [commentList, setCommentList] = useState<CommentData[]>([]);
const [activeAccountId, setActiveAccountId] = useState<number>(-1);
async function getCreatorList() {
- console.log('------ activeAccountId', activeAccountId);
if (activeAccountId === -1) {
return;
}
@@ -34,7 +34,6 @@ export default function Page() {
pageNo: 1,
pageSize: 10,
});
- console.log('------ res', res);
setWordList(res.list);
}
@@ -43,10 +42,8 @@ export default function Page() {
* 获取评论列表
*/
async function getCommentList(dataId: string) {
- const res = await icpGetCommentList(activeAccountId, dataId);
- console.log('----- res', res);
-
- setWordList(res.list);
+ const res = await icpGetCommentList(activeAccountId, dataId, {});
+ setCommentList(res.list);
}
/**
@@ -115,10 +112,7 @@ export default function Page() {
</Button>,
]}
>
- <Meta
- title={item.title}
- description="This is the description"
- />
+ <Meta title={item.title} />
</Card>
))}
</div>
@@ -126,17 +120,17 @@ export default function Page() {
<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>
+ <Card
+ key={item.commentId}
+ style={{ width: 300 }}
+ actions={[<Button type="primary">回复</Button>]}
+ >
+ {item.content}
+ <Meta
+ avatar={<Avatar src={item.headUrl} />}
+ description={item.nikeName}
+ />
+ </Card>
))}
</div>
</Col>