Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
style: 1
牛文政6d141bae7829
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.tsindex 3d4d5ff6..6f4321a1 100644--- a/electron/main/plat/platforms/xhs/index.ts+++ b/electron/main/plat/platforms/xhs/index.ts@@ -189,13 +189,28 @@ export class Xhs extends PlatformBase {) {const cookie: CookiesType = JSON.parse(account.loginCookie);- const res = await xiaohongshuService.getCommentList(cookie, dataId);+ const res = await xiaohongshuService.getCommentList(+ cookie,+ dataId,+ pcursor ? Number.parseInt(pcursor) : undefined,+ );- const list: CommentData[] = [];+ // 错误处理+ if (res.status !== 200 || res.data.code) {+ console.log('----- getCommentList xhs error---', res);+ return {+ list: [],+ pageInfo: {+ count: 0,+ hasMore: false,+ pcursor: '',+ },+ };+ }+ const list: CommentData[] = [];for (const v of res.data.data.comments) {const subList: CommentData[] = [];-for (const sub of v.sub_comments) {subList.push({userId: sub.user_info.user_id,@@ -291,14 +306,21 @@ export class Xhs extends PlatformBase {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 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,diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.tsindex bd5275aa..7e21974b 100644--- a/electron/plat/xiaohongshu/index.ts+++ b/electron/plat/xiaohongshu/index.ts@@ -1415,12 +1415,19 @@ export class XiaohongshuService {});}- // 获取评论列表+ /**+ * 获取评论列表+ * @param cookie+ * @param noteId+ * @param cursor+ * @returns+ */async getCommentList(cookie: Electron.Cookie[],noteId: string,cursor?: number,) {+ // TODO: xsec_token 每个作品评论列表的xsec_token都不一样,需要重新获取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,@@ -1446,39 +1453,37 @@ 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),+ });- // 获取二级评论列表- 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;- }+ 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;+ }/*** 点赞作品diff --git a/src/views/reply/autoRun.tsx b/src/views/reply/autoRun.tsxindex a2d3b4f5..57cca366 100644--- a/src/views/reply/autoRun.tsx+++ b/src/views/reply/autoRun.tsx@@ -45,8 +45,9 @@ const Page: React.FC = () => {});}- function changeAutoRunStatus(id: number, status: AutoRunStatus) {- ipcUpdateAutoRunStatus(id, status);+ async function changeAutoRunStatus(id: number, status: AutoRunStatus) {+ await ipcUpdateAutoRunStatus(id, status);+ getAutoRunList();}// 打开Ref_AutoRunRecord@@ -102,7 +103,6 @@ const Page: React.FC = () => {}}><Column title="ID" dataIndex="id" key="id" />- <Column title="用户DI" dataIndex="userId" key="userId" /><Column title="账户ID" dataIndex="accountId" key="accountId" /><Column title="运行次数" dataIndex="runCount" key="runCount" /><Column@@ -150,7 +150,7 @@ const Page: React.FC = () => {</Popconfirm><Popconfirm- title="确认停止该任务"+ title="确认删除该任务"onConfirm={(e?: React.MouseEvent<HTMLElement>) => {changeAutoRunStatus(record.id, AutoRunStatus.DELETE);}}