@@ -253,8 +253,6 @@ const onSearch = async (value) => {
253253 searchState .currentPage = 1 ;
254254
255255 try {
256- console .log (" 开始搜索:" , keyword, " 当前源:" , form .now_site );
257-
258256 if (! form .now_site || ! form .now_site .key ) {
259257 throw new Error (" 请先选择数据源" );
260258 }
@@ -270,8 +268,6 @@ const onSearch = async (value) => {
270268 searchState .searchResults = searchData .videos || [];
271269 searchState .totalPages = searchData .pagination ? .totalPages || 1 ;
272270 searchState .hasMore = searchData .pagination ? .hasNext || false ;
273-
274- console .log (" 搜索结果:" , searchState .searchResults );
275271 } catch (error) {
276272 console .error (" 搜索失败:" , error);
277273 searchState .searchError = error .message || " 搜索失败,请重试" ;
@@ -296,12 +292,30 @@ const onSearchLoadMore = async () => {
296292 apiUrl: form .now_site .api
297293 });
298294
295+
296+
299297 // 追加新的搜索结果到现有结果中
300298 const newVideos = searchData .videos || [];
301- searchState .searchResults = [... searchState .searchResults , ... newVideos];
299+
300+ // 检查是否有重复数据或no_data标识
301+ const existingIds = new Set (searchState .searchResults .map (v => v .vod_id ));
302+ const uniqueNewVideos = newVideos .filter (video => {
303+ // 过滤掉重复的视频和no_data标识
304+ return ! existingIds .has (video .vod_id ) &&
305+ video .vod_id !== ' no_data' &&
306+ video .vod_name !== ' no_data' ;
307+ });
308+
309+ // 如果新数据为空或全部重复,表示没有更多数据
310+ if (uniqueNewVideos .length === 0 ) {
311+ searchState .hasMore = false ;
312+ } else {
313+ searchState .searchResults = [... searchState .searchResults , ... uniqueNewVideos];
314+ searchState .hasMore = searchData .pagination ? .hasNext !== false ; // 只有明确返回false才停止
315+ }
316+
302317 searchState .currentPage = nextPage;
303- searchState .totalPages = searchData .pagination ? .totalPages || 1 ;
304- searchState .hasMore = searchData .pagination ? .hasNext || false ;
318+ searchState .totalPages = searchData .pagination ? .totalPages || searchState .totalPages ;
305319 } catch (error) {
306320 console .error (" 搜索加载更多失败:" , error);
307321 searchState .searchError = error .message || " 加载失败,请重试" ;
@@ -319,6 +333,11 @@ const exitSearch = () => {
319333 searchState .currentPage = 1 ;
320334};
321335
336+ // 处理视频点击事件
337+ const handleVideoClick = (video ) => {
338+ // 这里可以添加视频点击后的处理逻辑,比如跳转到播放页面
339+ };
340+
322341
323342
324343const handleOpenForm = () => {
0 commit comments