diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsx index f6296c8..fbb50ac 100644 --- a/src/app/profile/page.tsx +++ b/src/app/profile/page.tsx @@ -20,7 +20,10 @@ import { Eye, EyeOff, Zap, + ClipboardList, + Heart, } from "lucide-react"; +import EmptyState from "@/components/EmptyState"; import { getUserId, getCachedProfile, setCachedProfile, setCachedPreferences, logout } from "@/lib/userId"; import { getAvatarBg, AVATARS } from "@/lib/avatars"; import type { UserProfile, UserPreferences, DecisionRecord, FavoriteRecord, Restaurant } from "@/types"; @@ -534,9 +537,14 @@ export default function ProfilePage() { ) : history.length === 0 ? ( -

- 还没有决策记录 -

+ router.push("/blindbox")} + color="purple" + /> ) : (
{history.map((d) => ( @@ -612,9 +620,14 @@ export default function ProfilePage() {
) : favorites.length === 0 ? ( -

- 还没有收藏的餐厅 -

+ router.push("/blindbox")} + color="amber" + /> ) : (
{favorites.map((f) => { diff --git a/src/components/EmptyState.tsx b/src/components/EmptyState.tsx new file mode 100644 index 0000000..8593294 --- /dev/null +++ b/src/components/EmptyState.tsx @@ -0,0 +1,58 @@ +"use client"; + +import { motion } from "framer-motion"; +import type { LucideIcon } from "lucide-react"; + +interface EmptyStateProps { + icon: LucideIcon; + title: string; + subtitle?: string; + ctaLabel?: string; + onCta?: () => void; + color?: string; +} + +export default function EmptyState({ + icon: Icon, + title, + subtitle, + ctaLabel, + onCta, + color = "purple", +}: EmptyStateProps) { + const colorMap: Record = { + purple: { glow: "bg-purple-600/15", icon: "text-purple-400/60", btn: "bg-purple-600 hover:bg-purple-500", btnHover: "" }, + amber: { glow: "bg-amber-500/15", icon: "text-amber-400/60", btn: "bg-amber-600 hover:bg-amber-500", btnHover: "" }, + rose: { glow: "bg-rose-500/15", icon: "text-rose-400/60", btn: "bg-rose-600 hover:bg-rose-500", btnHover: "" }, + sky: { glow: "bg-sky-500/15", icon: "text-sky-400/60", btn: "bg-sky-600 hover:bg-sky-500", btnHover: "" }, + }; + const c = colorMap[color] ?? colorMap.purple; + + return ( +
+ +
+ + + +

{title}

+ {subtitle && ( +

{subtitle}

+ )} + + {ctaLabel && onCta && ( + + {ctaLabel} + + )} +
+ ); +}