Browse Source

默认每页 10 条,初次加载预取第 2 页

PAGE_SIZE 由 40 改为 10,翻页粒度更细;
初次/搜索完成后立即追加请求下一页,降低首屏滚动等待感。
刘立冬 2 hours ago
parent
commit
232080a6ba

+ 5 - 1
src/views/publishContent/weCom/components/videoSelectModal/index.tsx

@@ -42,7 +42,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 	const { videoCategoryOptions } = useVideoCategoryOptions();
 	const [category, setCategory] = useState<string>();
 	const sort = VideoSortType.推荐指数;
-	const PAGE_SIZE = 40;
+	const PAGE_SIZE = 10;
 	const [searchTerm, setSearchTerm] = useState<string>('');
 	const [currentPage, setCurrentPage] = useState(1);
 	const [total, setTotal] = useState(0);
@@ -115,6 +115,10 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 			setVideoListAll(old => [...old, ...mapped.filter(v => !old.find(o => o.videoId === v.videoId))]);
 			setTotal(res.data.totalSize);
 			setHasMore(pageNum * PAGE_SIZE < res.data.totalSize);
+			// 初次/搜索后预取下一页,减少滚动等待
+			if (mode === 'replace' && pageNum * PAGE_SIZE < res.data.totalSize) {
+				getVideoList(pageNum + 1, 'append');
+			}
 		}
 	}
 

+ 5 - 1
src/views/publishContent/weGZH/components/videoSelectModal/index.tsx

@@ -38,7 +38,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
 	const { videoCategoryOptions } = useVideoCategoryOptions();
 	const [category, setCategory] = useState<string>();
 	const sort = VideoSortType.推荐指数;
-	const PAGE_SIZE = 40;
+	const PAGE_SIZE = 10;
 	const [searchTerm, setSearchTerm] = useState<string>('');
 	const [currentPage, setCurrentPage] = useState(1);
 	const [total, setTotal] = useState(0);
@@ -124,6 +124,10 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
 			setVideoListAll(old => [...old, ...items.filter(v => !old.find(ov => ov.videoId === v.videoId))]);
 			setTotal(res.data.totalSize);
 			setHasMore(pageNum * PAGE_SIZE < res.data.totalSize);
+			// 初次/搜索后预取下一页,减少滚动等待
+			if (mode === 'replace' && pageNum * PAGE_SIZE < res.data.totalSize) {
+				getVideoList(pageNum + 1, 'append');
+			}
 		}
 	}