Commit 5c787d05 by Ivan

fix: 修复Observer

parent 28692f2c
import { Link } from "@inertiajs/react";
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 (
<div
ref={ref}
className="bg-white overflow-hidden shadow rounded-lg flex flex-col"
>
<div className="relative pb-[75%]">
......@@ -49,5 +52,5 @@ export function ComImageCard({ image, path, showUserName = false}) {
</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
setLoadedPageMap({})
setMaxVisiblePage(0)
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)
}
......@@ -68,19 +58,6 @@ export default function ComImageIndex({ title, description, path, images, pagina
try {
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(
path,
{
......@@ -101,7 +78,6 @@ export default function ComImageIndex({ title, description, path, images, pagina
replace: true,
only: ['images', 'pagination'],
onSuccess: (response) => {
// Prepend new images to existing ones
setPage(response.props.pagination.current_page)
setHasMore(maxVisiblePage < response.props.pagination.total_pages)
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
</svg>
</div>
)}
{
!loading && allImages.length > 0 && !hasMore && (<div className="flex justify-center mt-6 pb-6">没有更多了</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