Skip to content

Let's use AI to Earn!

feat: 整理分页进出参

牛文政f2c4ac7ea1a1
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 013b18a1..dc30c1b7 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -17,6 +17,7 @@ import {
IGetUsersParams,
IGetUsersResponse,
IVideoPublishParams,
+ PageType,
StatisticsData,
VideoCallbackType,
WorkData,
@@ -85,8 +86,12 @@ export abstract class PlatformBase {
},
): Promise<{
list: WorkData[];
- count: number;
- pcursor?: number;
+ pageInfo: {
+ pageType: PageType;
+ count?: number;
+ hasMore?: boolean;
+ pcursor?: string; // 下一页的游标
+ };
}>;
/**
@@ -101,16 +106,19 @@ export abstract class PlatformBase {
abstract getCommentList(
account: AccountModel,
dataId: string,
- pageInfo?: {
+ pageInfo: {
pageNo?: number;
pageSize?: number;
- pcursor?: number; // 下一页的游标
+ pcursor?: string;
},
): Promise<{
list: CommentData[];
- count?: number;
- hasMore?: boolean;
- pcursor?: string; // 下一页的游标
+ pageInfo: {
+ pageType: PageType;
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ };
}>;
/**
diff --git a/electron/main/plat/plat.type.ts b/electron/main/plat/plat.type.ts
index 93281441..544754d7 100644
--- a/electron/main/plat/plat.type.ts
+++ b/electron/main/plat/plat.type.ts
@@ -11,6 +11,11 @@ import { DiffParmasType, ILableValue } from '../../db/models/video';
export type CookiesType = Electron.Cookie[];
+export enum PageType {
+ paging = 'paging',
+ cursor = 'cursor',
+}
+
// 获取平台账户信息入参
export interface IAccountInfoParams {
cookies: CookiesType;
@@ -46,11 +51,12 @@ export type WorkData = {
collectCount?: number;
forwardCount?: number;
commentCount?: number; // 评论数量
- income?: number;
+ income?: number; // 收入
title?: string;
desc?: string;
coverUrl?: string;
videoUrl?: string;
+ createTime?: string;
};
// 评论
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index d6b1cffa..16cbb0a4 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -8,6 +8,7 @@
import { PlatformBase } from '../../PlatformBase';
import {
AccountInfoTypeRV,
+ CommentData,
CookiesType,
DashboardData,
IAccountInfoParams,
@@ -16,6 +17,7 @@ import {
IGetTopicsResponse,
IGetUsersParams,
IVideoPublishParams,
+ PageType,
VideoCallbackType,
WorkData,
} from '../../plat.type';
@@ -157,10 +159,12 @@ export class Kwai extends PlatformBase {
*/
async getWorkList(
account: AccountModel,
- pageInfo: { pageNo: number; pageSize: number },
+ pageInfo: {
+ pcursor?: string;
+ },
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- const res = await kwaiPub.getPhotoList(cookie, pageInfo.pageNo);
+ const res = await kwaiPub.getPhotoList(cookie, Number(pageInfo.pcursor));
const photoList = res.data.data.photoList;
const list: WorkData[] = photoList.map((v) => {
return {
@@ -174,8 +178,12 @@ export class Kwai extends PlatformBase {
return {
list,
- count: res.data.data.totalCount,
- pcursor: res.data.data.pcursor,
+ pageInfo: {
+ pageType: PageType.cursor,
+ hasMore: !!res.data.data.pcursor,
+ count: res.data.data.totalCount,
+ pcursor: res.data.data.pcursor + '',
+ },
};
}
@@ -190,11 +198,43 @@ export class Kwai extends PlatformBase {
};
}
- async getCommentList(account: AccountModel, dataId: string) {
+ async getCommentList(
+ account: AccountModel,
+ dataId: string,
+ pageInfo: {
+ pcursor?: string;
+ },
+ ) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await kwaiPub.getCommentList(
+ cookie,
+ dataId,
+ // Number(pageInfo.pcursor),
+ );
+
+ console.log('------ res ----', res);
+
+ const list: CommentData[] = res.data.data.list.map((v) => {
+ return {
+ dataId: v.photoId + '',
+ commentId: v.commentId + '',
+ parentCommentId: undefined,
+ content: v.content,
+ likeCount: undefined,
+ nikeName: v.headurl,
+ headUrl: v.headurl,
+ data: v,
+ };
+ });
+
return {
- list: [],
- count: 0,
+ list: list,
+ pageInfo: {
+ pageType: PageType.cursor,
+ count: 0,
+ pcursor: '',
+ hasMore: true,
+ },
};
}
@@ -203,6 +243,10 @@ export class Kwai extends PlatformBase {
dataId: string, // 作品ID
content: string,
) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await kwaiPub.commentAdd(cookie, dataId, content, {});
+ console.log('------ kaishou createComment res ----', res);
+
return false;
}
@@ -215,6 +259,14 @@ export class Kwai extends PlatformBase {
comment: any; // 辅助数据,原数据
},
) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+
+ const res = await kwaiPub.commentAdd(cookie, option.dataId!, content, {
+ replyToCommentId: Number.parseInt(commentId),
+ replyTo: Number.parseInt(option.dataId!),
+ });
+ console.log('------ kaishou createComment res ----', res);
+
return false;
}
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 77340dba..7c634029 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -19,6 +19,7 @@ import {
IVideoPublishParams,
VideoCallbackType,
WorkData,
+ PageType,
} from '../../plat.type';
import { PublishVideoResult } from '../../module';
import { douyinService } from '../../../../plat/douyin';
@@ -136,25 +137,44 @@ export class Douyin extends PlatformBase {
*/
async getWorkList(
account: AccountModel,
- pageInfo: { pageNo?: number; pageSize?: number; pcursor?: string },
+ pageInfo: {
+ pcursor?: string;
+ },
) {
const res = await douyinService.getCreatorItems(
JSON.parse(account.loginCookie),
pageInfo.pcursor,
);
- const list: WorkData[] = res.data.item_info_list.map((v) => {
- return {
- dataId: v.item_id,
- cover: v.cover_image_url,
- title: v.title,
- createTime: v.create_time,
- commentCount: v.comment_count,
- };
- });
+
+ let pcursor = '';
+ const list: WorkData[] = [];
+ for (const element of res.data.item_info_list) {
+ list.push({
+ dataId: element.item_id,
+ readCount: undefined,
+ likeCount: undefined,
+ collectCount: undefined,
+ forwardCount: undefined,
+ commentCount: element.comment_count,
+ income: undefined,
+ title: element.title,
+ desc: undefined,
+ coverUrl: element.cover_image_url,
+ videoUrl: undefined,
+ createTime: element.create_time,
+ });
+
+ pcursor = element.cursor;
+ }
return {
list: list,
- count: res.data.total_count,
+ pageInfo: {
+ pageType: PageType.cursor,
+ count: res.data.total_count,
+ hasMore: res.data.has_more,
+ pcursor: pcursor,
+ },
};
}
@@ -172,10 +192,9 @@ export class Douyin extends PlatformBase {
async getCommentList(
account: AccountModel,
dataId: string,
- pageInfo?: {
- pageNo?: number;
+ pageInfo: {
pageSize?: number;
- pcursor?: number;
+ pcursor?: string;
},
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
@@ -184,8 +203,6 @@ export class Douyin extends PlatformBase {
cursor: pageInfo?.pcursor || undefined,
});
- console.log('===== res ===', res.data.comment_info_list[0]);
-
const list: CommentData[] = res.data.comment_info_list.map((v: any) => {
return {
dataId: dataId,
@@ -200,7 +217,12 @@ export class Douyin extends PlatformBase {
return {
list,
- count: res.data.total_count,
+ pageInfo: {
+ pageType: PageType.cursor,
+ count: res.data.total_count,
+ pcursor: res.data.cursor + '',
+ hasMore: res.data.has_more,
+ },
};
}
diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.ts
index 1604e5c2..b2e4f3c7 100644
--- a/electron/main/plat/platforms/wxSph/index.ts
+++ b/electron/main/plat/platforms/wxSph/index.ts
@@ -16,6 +16,7 @@ import {
IGetTopicsResponse,
IGetUsersParams,
IVideoPublishParams,
+ PageType,
VideoCallbackType,
WorkData,
} from '../../plat.type';
@@ -127,10 +128,17 @@ export class WxSph extends PlatformBase {
*/
async getWorkList(
account: AccountModel,
- pageInfo: { pageNo: number; pageSize: number },
+ pageInfo: {
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ },
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- const res = await shipinhaoService.getPostList(cookie, pageInfo);
+ const res = await shipinhaoService.getPostList(cookie, {
+ pageNo: pageInfo.pageNo || 1,
+ pageSize: pageInfo.pageSize || 20,
+ });
const listData: WorkData[] = res.list.map((item) => {
return {
@@ -145,7 +153,10 @@ export class WxSph extends PlatformBase {
return {
list: listData,
- count: res.totalCount,
+ pageInfo: {
+ pageType: PageType.paging,
+ count: res.totalCount,
+ },
};
}
@@ -160,7 +171,15 @@ export class WxSph extends PlatformBase {
};
}
- async getCommentList(account: AccountModel, dataId: string) {
+ async getCommentList(
+ account: AccountModel,
+ dataId: string,
+ pageInfo: {
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ },
+ ) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await shipinhaoService.getCommentList(cookie, dataId);
@@ -177,7 +196,10 @@ export class WxSph extends PlatformBase {
return {
list: dataList,
- count: res.commentCount,
+ pageInfo: {
+ pageType: PageType.paging,
+ count: res.commentCount,
+ },
};
}
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index 382b1366..3f2f8922 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -17,6 +17,7 @@ import {
IGetTopicsResponse,
IGetUsersParams,
IVideoPublishParams,
+ PageType,
VideoCallbackType,
WorkData,
} from '../../plat.type';
@@ -137,7 +138,11 @@ export class Xhs extends PlatformBase {
*/
async getWorkList(
account: AccountModel,
- pageInfo: { pageNo: number; pageSize: number; pcursor?: string },
+ pageInfo: {
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ },
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await xiaohongshuService.getWorks(cookie);
@@ -154,7 +159,10 @@ export class Xhs extends PlatformBase {
return {
list,
- count: 0,
+ pageInfo: {
+ pageType: PageType.cursor,
+ count: res.data.data.tags[0].notes_count,
+ },
};
}
@@ -169,7 +177,15 @@ export class Xhs extends PlatformBase {
};
}
- async getCommentList(account: AccountModel, dataId: string) {
+ async getCommentList(
+ account: AccountModel,
+ dataId: string,
+ pageInfo: {
+ pageNo?: number;
+ pageSize?: number;
+ pcursor?: string;
+ },
+ ) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await xiaohongshuService.getCommentList(cookie, dataId);
@@ -186,8 +202,11 @@ export class Xhs extends PlatformBase {
return {
list: list,
- hasMore: res.data.data.has_more,
- pcursor: res.data.data.cursor,
+ pageInfo: {
+ pageType: PageType.cursor,
+ hasMore: res.data.data.has_more,
+ pcursor: res.data.data.cursor,
+ },
};
}
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index fab95309..d0f47453 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -2287,7 +2287,7 @@ export class DouyinService {
cookie: Electron.Cookie[],
item_id: string, // 作品ID
pageInfo: {
- cursor?: number;
+ cursor?: string;
count?: number;
},
) {