refactor: 拆分 MatchResult、ProfilePage、BlindboxRoomPage 大组件
- MatchResult: 提取 NoMatchResult、RunnerUpCard(635 → 513 行) - ProfilePage: 提取 ProfileHistoryCard、ProfileFavoritesCard(692 → 526 行) - BlindboxRoomPage: 提取 BlindboxMyIdeas、BlindboxDrawnHistory(855 → 668 行)
This commit is contained in:
@@ -12,8 +12,6 @@ import {
|
||||
Clock,
|
||||
Trophy,
|
||||
RotateCcw,
|
||||
SearchX,
|
||||
Home,
|
||||
ChevronDown,
|
||||
Swords,
|
||||
RefreshCw,
|
||||
@@ -35,6 +33,8 @@ import ShareCardModal from "@/components/ShareCardModal";
|
||||
import RestaurantImage from "@/components/RestaurantImage";
|
||||
import AuthModal from "@/components/AuthModal";
|
||||
import Button from "@/components/Button";
|
||||
import NoMatchResult from "@/components/NoMatchResult";
|
||||
import RunnerUpCard from "@/components/RunnerUpCard";
|
||||
import { buildNavUrl } from "@/lib/navigation";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
|
||||
@@ -53,127 +53,6 @@ interface MatchResultProps {
|
||||
scene?: SceneType;
|
||||
}
|
||||
|
||||
function NoMatchResult({
|
||||
onReset,
|
||||
resetting,
|
||||
}: {
|
||||
onReset: () => Promise<void>;
|
||||
resetting: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className="fixed inset-0 z-50 flex flex-col items-center justify-center overflow-y-auto bg-background px-6 py-10"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ scale: 0, rotate: -20 }}
|
||||
animate={{ scale: 1, rotate: 0 }}
|
||||
transition={{ type: "spring", stiffness: 200, damping: 12, delay: 0.2 }}
|
||||
>
|
||||
<SearchX size={56} className="text-muted" />
|
||||
</motion.div>
|
||||
|
||||
<motion.h1
|
||||
className="mt-4 text-3xl font-black text-heading"
|
||||
initial={{ y: 30, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 0.35 }}
|
||||
>
|
||||
都不太满意
|
||||
</motion.h1>
|
||||
|
||||
<motion.p
|
||||
className="mt-2 max-w-[16rem] text-center text-sm leading-relaxed text-muted"
|
||||
initial={{ y: 20, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 0.45 }}
|
||||
>
|
||||
这一轮没有店被选中,换个范围或类型再试试?
|
||||
</motion.p>
|
||||
|
||||
<motion.div
|
||||
className="mt-8 flex w-full max-w-xs flex-col gap-3"
|
||||
initial={{ y: 30, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 0.55 }}
|
||||
>
|
||||
<Button
|
||||
onClick={onReset}
|
||||
shape="pill"
|
||||
loading={resetting}
|
||||
loadingText="重置中..."
|
||||
icon={<RotateCcw size={15} />}
|
||||
className="px-8 py-3"
|
||||
>
|
||||
再来一轮
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => router.push("/")}
|
||||
variant="secondary"
|
||||
shape="pill"
|
||||
icon={<Home size={15} />}
|
||||
className="px-8 py-3"
|
||||
>
|
||||
换个条件重新搜
|
||||
</Button>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
function RunnerUpCard({
|
||||
restaurant,
|
||||
likes,
|
||||
userCount,
|
||||
}: {
|
||||
restaurant: Restaurant;
|
||||
likes: number;
|
||||
userCount: number;
|
||||
}) {
|
||||
return (
|
||||
<a
|
||||
href={buildNavUrl(restaurant)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex gap-3 rounded-xl bg-surface/80 p-2.5 ring-1 ring-border/50 backdrop-blur-sm transition-colors hover:bg-elevated/80"
|
||||
>
|
||||
{restaurant.images?.[0] && (
|
||||
<RestaurantImage
|
||||
src={restaurant.images[0]}
|
||||
alt={restaurant.name}
|
||||
className="h-16 w-16 shrink-0 rounded-lg object-cover"
|
||||
/>
|
||||
)}
|
||||
<div className="flex min-w-0 flex-1 flex-col justify-center">
|
||||
<p className="truncate text-sm font-bold text-heading">
|
||||
{restaurant.name}
|
||||
</p>
|
||||
<div className="mt-1 flex items-center gap-2 text-xs text-tertiary">
|
||||
<span className="flex items-center gap-0.5">
|
||||
<Star size={11} className="fill-yellow-300 text-yellow-300" />
|
||||
{restaurant.rating}
|
||||
</span>
|
||||
<span>{restaurant.price}</span>
|
||||
{restaurant.distance && (
|
||||
<span className="flex items-center gap-0.5">
|
||||
<MapPin size={11} />
|
||||
{restaurant.distance}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-0.5 text-[11px] font-medium text-amber-400">
|
||||
{likes}/{userCount} 人想去
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export default function MatchResult({
|
||||
restaurant,
|
||||
matchType,
|
||||
|
||||
Reference in New Issue
Block a user