Skip to content

Let's use AI to Earn!

加载更多数据问题

DESKTOP-ZTS2NQJNAf9f76c51a7ea
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 4d7f5a17..d51e5e78 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -230,7 +230,8 @@ export class Douyin extends PlatformBase {
data: v,
});
}
-
+
+ console.log('------douyin getsearchNodeList !!res.data.has_more^^: ', !!res.data.has_more);
return {
list,
pageInfo: {
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index 8abe4bc0..ad8c406d 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -2221,12 +2221,13 @@ export class DouyinService {
},
) {
let pcursor = (pageInfo.pcursor && Number(pageInfo.pcursor) < 16) ? 0 : pageInfo.pcursor;
+ let count = (Number(pcursor) > 10) ? 10 : 16;
const thisUri = `https://www.douyin.com/aweme/v1/web/search/item/?${jsonToQueryString(
{
aid: '6383',
keyword: qe,
offset: pcursor,
- count: 16
+ count: count
}
)}`;
@@ -2238,7 +2239,7 @@ export class DouyinService {
},
method: 'GET',
});
- console.log('------douyin getsearchNodeList res: ', res.data);
+ // console.log('------douyin getsearchNodeList res: ', res.data);
return res;
}
diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsx
index e2242393..ad6070e1 100644
--- a/src/views/replyother/index.tsx
+++ b/src/views/replyother/index.tsx
@@ -86,7 +86,7 @@ export default function Page() {
pcursor?: any;
}>({
count: 0,
- hasMore: false,
+ hasMore: true,
pcursor: 1,
});
@@ -160,7 +160,7 @@ export default function Page() {
// 加载更多帖子
const loadMorePosts = async () => {
if (!pageInfo.hasMore || isLoadingMore) return;
-
+
setIsLoadingMore(true);
try {
await getSearchListFunc(activeAccountId, undefined);
@@ -227,11 +227,16 @@ export default function Page() {
// 搜索列表 - 平台自己搜索
async function getSearchListFunc(thisid: any, qe?: any) {
+ if (!pageInfo.hasMore && pageInfo.pcursor !== 1) {
+ console.log('没有更多数据了,不再发送请求');
+ return;
+ }
+
const res = await getCommentSearchNotes(thisid, qe, pageInfo);
-
+ console.log('------ getSearchListFunc -- @@:', res);
if (res.list?.length) {
// 如果是加载更多,则追加到现有列表
- setPostList((prev) => (pageInfo ? [...prev, ...res.list] : res.list));
+ setPostList((prev) => (pageInfo.pcursor !== 1 ? [...prev, ...res.list] : res.list));
// 更新分页信息
setPageInfo({
@@ -239,6 +244,12 @@ export default function Page() {
hasMore: res.pageInfo.hasMore || false,
pcursor: res.pageInfo.pcursor || '',
});
+ } else {
+ // 如果没有返回数据,设置hasMore为false
+ setPageInfo(prev => ({
+ ...prev,
+ hasMore: false
+ }));
}
}
@@ -526,7 +537,9 @@ export default function Page() {
post.url?.includes('douyin.com')
) {
// 抖音链接格式
- url = post.url || `https://www.douyin.com/video/${post.dataId}`;
+ console.log('------ post.dataId', post.dataId);
+ url = `https://www.douyin.com/video/${post.dataId}`;
+ console.log('------ url 2:', url);
} else {
// 默认使用已有的url或者根据noteId构建通用链接
url = post.url || `https://www.xiaohongshu.com/explore/${post.dataId}`;
@@ -557,30 +570,22 @@ export default function Page() {
onAccountChange={useCallback(
(info) => {
console.log('------ onAccountChange', info);
+ setPageInfo({
+ count: 0,
+ hasMore: false,
+ pcursor: 1,
+ });
setActiveAccount(info);
setActiveAccountType(info.type);
setPostList([]);
- setPageInfo({
- count: 0,
- hasMore: false,
- pcursor: 1,
- });
- if (info.type == 'xhs') {
setActiveAccountId(info.id);
setTimeout(() => {
getSearchListFunc(info.id);
}, 0);
- } else if (info.type == 'KWAI') {
- setActiveAccountId(info.id);
- getSearchListFunc(info.id);
- } else if (info.type == 'douyin') {
- console.log('------ douyin 开始搜索 ');
- setActiveAccountId(info.id);
- getSearchListFunc(info.id, '英雄杀');
- }
+
},
[getCreatorList],
)}
@@ -682,7 +687,7 @@ export default function Page() {
<Card.Meta
avatar={
<Avatar
- src={`https://api.dicebear.com/7.x/miniavs/svg?seed=${item.author?.name}`}
+ src={`${item.author?.avatar}`}
/>
}
title={item.author?.name}
@@ -702,18 +707,21 @@ export default function Page() {
))}
</Masonry>
- {/* 替换原来的加载更多按钮为自动加载区域 */}
- <div ref={loadMoreRef} className={styles.loadMoreArea}>
+ {/* 加载更多区域 */}
+ <div
+ ref={loadMoreRef}
+ className={styles.loadMoreArea}
+ >
{isLoadingMore && (
<div className={styles.loadingMore}>
<Spin size="small" />
<span style={{ marginLeft: 8 }}>加载中...</span>
</div>
)}
-
+
{!pageInfo.hasMore && postList.length > 0 && (
<div className={styles.noMoreData}>
- <Divider plain>没有更多内容了</Divider>
+ <Divider plain>没有更多数据了</Divider>
</div>
)}
</div>