diff --git a/app/(main)/player/[id]/page.tsx b/app/(main)/player/[id]/page.tsx
index 041ed00..19b4178 100644
--- a/app/(main)/player/[id]/page.tsx
+++ b/app/(main)/player/[id]/page.tsx
@@ -1,6 +1,7 @@
import { CheckCircle, Clock, MapPin, MessageSquare, ShoppingBag, Star } from "lucide-react"
import Link from "next/link"
import { notFound } from "next/navigation"
+import { FavoriteButton } from "@/components/favorite-button"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
@@ -14,7 +15,7 @@ import {
} from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
-import { mockPlayers, mockReviews, mockServices } from "@/lib/mock-data"
+import { mockFavorites, mockPlayers, mockReviews, mockServices } from "@/lib/mock-data"
export default async function PlayerDetailPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
@@ -29,6 +30,9 @@ export default async function PlayerDetailPage({ params }: { params: Promise<{ i
player.services && player.services.length > 0
? player.services
: mockServices.filter((s) => s.playerId === player.id)
+ const isFavorited = mockFavorites.some(
+ (f) => f.userId === "u1" && f.targetType === "player" && f.targetId === player.id,
+ )
return (
@@ -72,6 +76,7 @@ export default async function PlayerDetailPage({ params }: { params: Promise<{ i
)}
+
diff --git a/app/(main)/shop/[id]/page.tsx b/app/(main)/shop/[id]/page.tsx
index 1d3db30..90fc1f8 100644
--- a/app/(main)/shop/[id]/page.tsx
+++ b/app/(main)/shop/[id]/page.tsx
@@ -2,11 +2,12 @@ import { Gamepad2, Megaphone, ShoppingBag, Star, Users } from "lucide-react"
import Image from "next/image"
import Link from "next/link"
import { notFound } from "next/navigation"
+import { FavoriteButton } from "@/components/favorite-button"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
-import { mockPlayers, mockReviews, mockServices, mockShops } from "@/lib/mock-data"
+import { mockFavorites, mockPlayers, mockReviews, mockServices, mockShops } from "@/lib/mock-data"
interface PageProps {
params: Promise<{ id: string }>
@@ -24,6 +25,9 @@ export default async function ShopPage({ params }: PageProps) {
const playerIds = shopPlayers.map((p) => p.id)
const shopServices = mockServices.filter((s) => playerIds.includes(s.playerId))
const shopReviews = mockReviews.filter((r) => playerIds.includes(r.toUserId))
+ const isFavorited = mockFavorites.some(
+ (f) => f.userId === "u1" && f.targetType === "shop" && f.targetId === shop.id,
+ )
const sortedSections = [...shop.templateConfig.sections]
.filter((s) => s.enabled)
@@ -98,6 +102,7 @@ export default async function ShopPage({ params }: PageProps) {
{shop.owner.bio || "暂无介绍"}
+
diff --git a/components/favorite-button.tsx b/components/favorite-button.tsx
new file mode 100644
index 0000000..0cf7775
--- /dev/null
+++ b/components/favorite-button.tsx
@@ -0,0 +1,25 @@
+"use client"
+
+import { Heart } from "lucide-react"
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+
+interface FavoriteButtonProps {
+ initialFavorited: boolean
+}
+
+export function FavoriteButton({ initialFavorited }: FavoriteButtonProps) {
+ const [favorited, setFavorited] = useState(initialFavorited)
+
+ return (
+
+ )
+}
diff --git a/lib/mock-data.ts b/lib/mock-data.ts
index 0815926..a510e08 100644
--- a/lib/mock-data.ts
+++ b/lib/mock-data.ts
@@ -3,6 +3,7 @@ import type {
ChatSession,
Comment,
Dispute,
+ Favorite,
Game,
Notification,
Order,
@@ -567,3 +568,20 @@ export const mockTransactions: WalletTransaction[] = [
export const currentUser = mockUsers[0]
export const walletBalance = 430
+
+export const mockFavorites: Favorite[] = [
+ {
+ id: "fav1",
+ userId: "u1",
+ targetType: "player",
+ targetId: "u2",
+ createdAt: "2025-02-16T10:00:00",
+ },
+ {
+ id: "fav2",
+ userId: "u1",
+ targetType: "shop",
+ targetId: "shop1",
+ createdAt: "2025-02-17T14:00:00",
+ },
+]
diff --git a/lib/types.ts b/lib/types.ts
index a7c99e1..4e76434 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -192,3 +192,11 @@ export interface WalletTransaction {
description: string
createdAt: string
}
+
+export interface Favorite {
+ id: string
+ userId: string
+ targetType: "player" | "shop"
+ targetId: string
+ createdAt: string
+}