优化相册页面的点击处理逻辑,更新相册详情页面以支持从相册页面传递名称参数,提升用户体验和页面信息的准确性。

This commit is contained in:
神秘人
2025-04-25 19:14:58 +08:00
parent a1e4f61ed2
commit d3545815fc
2 changed files with 16 additions and 9 deletions

View File

@@ -5,7 +5,6 @@ import { motion, AnimatePresence } from 'framer-motion'
import { IoChevronBack, IoChevronForward } from 'react-icons/io5'
import { BsCalendar } from 'react-icons/bs'
import { Photo } from '@/types/app/album'
import { useParams } from 'next/navigation'
import { getImagesByAlbumIdAPI } from '@/api/album'
import Masonry from "react-masonry-css"
import Empty from '@/components/Empty'
@@ -18,8 +17,16 @@ const breakpointColumnsObj = {
700: 2
};
export default function AlbumPage() {
const { id } = useParams()
interface Props {
params: Promise<{ id: number }>;
searchParams: Promise<{ page: number; name: string }>;
};
export default async (props: Props) => {
const searchParams = await props.searchParams;
const params = await props.params;
const id = params.id;
const name = searchParams.name;
const [list, setList] = useState<Photo[]>([])
const [currentPhotoIndex, setCurrentPhotoIndex] = useState<number | null>(null)
@@ -108,13 +115,13 @@ export default function AlbumPage() {
return (
<>
<title>📷 </title>
<meta name="description" content="📷 照片墙" />
<title>{`📷 ${name} - 照片墙`}</title>
<meta name="description" content={`📷 ${name} - 照片墙`} />
<div className="container mx-auto px-4 py-8 pt-[90px]">
{/* 移除最大高度限制 */}
<div className="w-full">
{list.length === 0 ? (
{list?.length === 0 ? (
<Empty info="暂无照片" />
) : (
<>

View File

@@ -28,8 +28,8 @@ export default function AlbumPage() {
getAlbumCatePaging()
}, [])
const handleClick = (id: number) => {
router.push(`/album/${id}`)
const handleClick = (data: Cate) => {
router.push(`/album/${data.id}?name=${data.name}`)
}
return (
@@ -53,7 +53,7 @@ export default function AlbumPage() {
>
<div
className="relative group overflow-hidden rounded-lg shadow-lg cursor-pointer"
onClick={() => handleClick(cate.id!)}
onClick={() => handleClick(cate)}
>
{/* 图片容器 */}
<div className="aspect-w-1 aspect-h-1 w-full">