Commit 5c787d05 by Ivan

fix: 修复Observer

parent 28692f2c
import { Link } from "@inertiajs/react"; import { Link } from "@inertiajs/react";
import ComImageStatusTag from "./ComImageStatusTag"; import ComImageStatusTag from "./ComImageStatusTag";
import { forwardRef } from 'react';
export function ComImageCard({ image, path, showUserName = false}) { // Convert to forwardRef to allow the IntersectionObserver to work
export const ComImageCard = forwardRef(({ image, path, showUserName = false}, ref) => {
return ( return (
<div <div
ref={ref}
className="bg-white overflow-hidden shadow rounded-lg flex flex-col" className="bg-white overflow-hidden shadow rounded-lg flex flex-col"
> >
<div className="relative pb-[75%]"> <div className="relative pb-[75%]">
...@@ -49,5 +52,5 @@ export function ComImageCard({ image, path, showUserName = false}) { ...@@ -49,5 +52,5 @@ export function ComImageCard({ image, path, showUserName = false}) {
</div> </div>
</div> </div>
</div> </div>
) );
} });
\ No newline at end of file \ No newline at end of file
...@@ -46,16 +46,6 @@ export default function ComImageIndex({ title, description, path, images, pagina ...@@ -46,16 +46,6 @@ export default function ComImageIndex({ title, description, path, images, pagina
setLoadedPageMap({}) setLoadedPageMap({})
setMaxVisiblePage(0) setMaxVisiblePage(0)
setAllImages([]) setAllImages([])
// 打印搜索参数以便调试
console.log('搜索参数:', {
title_cont: searchParams.title_cont,
tags_name_cont: searchParams.tags_name_cont,
tags_id_in: searchParams.tags_id_in,
created_at_gteq: searchParams.created_at_gteq,
created_at_lteq: searchParams.created_at_lteq,
status_eq: searchParams.status_eq
})
loadPage(1) loadPage(1)
} }
...@@ -68,19 +58,6 @@ export default function ComImageIndex({ title, description, path, images, pagina ...@@ -68,19 +58,6 @@ export default function ComImageIndex({ title, description, path, images, pagina
try { try {
setLoading(true) setLoading(true)
// 打印请求参数以便调试
console.log('发送请求参数:', {
page: currentPage,
q: {
title_cont: searchParams.title_cont,
tags_name_cont: searchParams.tags_name_cont,
tags_id_in: searchParams.tags_id_in,
created_at_gteq: searchParams.created_at_gteq,
created_at_lteq: searchParams.created_at_lteq,
status_eq: searchParams.status_eq
}
})
await router.visit( await router.visit(
path, path,
{ {
...@@ -101,7 +78,6 @@ export default function ComImageIndex({ title, description, path, images, pagina ...@@ -101,7 +78,6 @@ export default function ComImageIndex({ title, description, path, images, pagina
replace: true, replace: true,
only: ['images', 'pagination'], only: ['images', 'pagination'],
onSuccess: (response) => { onSuccess: (response) => {
// Prepend new images to existing ones
setPage(response.props.pagination.current_page) setPage(response.props.pagination.current_page)
setHasMore(maxVisiblePage < response.props.pagination.total_pages) setHasMore(maxVisiblePage < response.props.pagination.total_pages)
setFilterCount(Object.values(searchParams).filter(i => Array.isArray(i) ? i.length : !!i).length) setFilterCount(Object.values(searchParams).filter(i => Array.isArray(i) ? i.length : !!i).length)
...@@ -401,6 +377,9 @@ export default function ComImageIndex({ title, description, path, images, pagina ...@@ -401,6 +377,9 @@ export default function ComImageIndex({ title, description, path, images, pagina
</svg> </svg>
</div> </div>
)} )}
{
!loading && allImages.length > 0 && !hasMore && (<div className="flex justify-center mt-6 pb-6">没有更多了</div>)
}
</div> </div>
</> </>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment