diff --git a/app/(account)/wallet/page.tsx b/app/(account)/wallet/page.tsx index 6b3ba66..c4240aa 100644 --- a/app/(account)/wallet/page.tsx +++ b/app/(account)/wallet/page.tsx @@ -226,7 +226,7 @@ export default function WalletPage() { ) : filteredTransactions.length > 0 ? ( filteredTransactions.map((tx) => { const Icon = typeIcons[tx.type] - const isIncome = tx.amount > 0 + const isIncome = Number(tx.amount) > 0 return (
@@ -242,7 +242,7 @@ export default function WalletPage() {

- {isIncome ? "+" : ""}¥{Math.abs(tx.amount).toFixed(2)} + {isIncome ? "+" : ""}¥{Math.abs(Number(tx.amount)).toFixed(2)}

{typeLabels[tx.type]} diff --git a/app/(dashboard)/dashboard/page.tsx b/app/(dashboard)/dashboard/page.tsx index 9c2e3e0..543359e 100644 --- a/app/(dashboard)/dashboard/page.tsx +++ b/app/(dashboard)/dashboard/page.tsx @@ -141,9 +141,7 @@ export default function DashboardPage() {

{order.service.title}

-

- {order.consumerName} → {order.playerName} -

+

{order.service.title}

¥{order.totalPrice} diff --git a/app/(dashboard)/dashboard/shop/income/page.tsx b/app/(dashboard)/dashboard/shop/income/page.tsx index 8b04a92..5cd4a28 100644 --- a/app/(dashboard)/dashboard/shop/income/page.tsx +++ b/app/(dashboard)/dashboard/shop/income/page.tsx @@ -158,12 +158,12 @@ export default function ShopIncomePage() {
- {transaction.amount > 0 ? ( + {Number(transaction.amount) > 0 ? ( ) : ( )} - 0 ? "default" : "secondary"}> + 0 ? "default" : "secondary"}> {transaction.type === "topup" ? "充值" : transaction.type === "payment" @@ -178,9 +178,9 @@ export default function ShopIncomePage() { {transaction.description} 0 ? "text-green-600" : "text-red-600"} + className={Number(transaction.amount) > 0 ? "text-green-600" : "text-red-600"} > - {transaction.amount > 0 ? "+" : ""} + {Number(transaction.amount) > 0 ? "+" : ""} {transaction.amount} {new Date(transaction.createdAt).toLocaleString()} diff --git a/app/(dashboard)/dashboard/shop/orders/page.tsx b/app/(dashboard)/dashboard/shop/orders/page.tsx index 8c1fa0b..077373f 100644 --- a/app/(dashboard)/dashboard/shop/orders/page.tsx +++ b/app/(dashboard)/dashboard/shop/orders/page.tsx @@ -103,8 +103,8 @@ export default function ShopOrdersPage() { {shopOrders.map((order) => ( {order.service.title} - {order.consumerName} - {order.playerName} + {order.consumerId} + {order.playerId} {statusLabels[order.status]} diff --git a/app/(dashboard)/dashboard/shop/rules/page.tsx b/app/(dashboard)/dashboard/shop/rules/page.tsx index 208a6a5..f524792 100644 --- a/app/(dashboard)/dashboard/shop/rules/page.tsx +++ b/app/(dashboard)/dashboard/shop/rules/page.tsx @@ -39,19 +39,19 @@ function ShopRulesForm({ shop: Shop updateShop: (shopId: string, patch: Partial>) => void }) { + const [commissionType, setCommissionType] = useState(shop.commissionType) + const [commissionValue, setCommissionValue] = useState(shop.commissionValue) const [allowMultiShop, setAllowMultiShop] = useState(shop.allowMultiShop) const [allowIndependentOrders, setAllowIndependentOrders] = useState(shop.allowIndependentOrders) const [dispatchMode, setDispatchMode] = useState(shop.dispatchMode) - const [commissionType, setCommissionType] = useState(shop.commissionType) - const [commissionValue, setCommissionValue] = useState(shop.commissionValue.toString()) const handleSave = () => { updateShop(shop.id, { + commissionType, + commissionValue, allowMultiShop, allowIndependentOrders, dispatchMode, - commissionType, - commissionValue: Number(commissionValue), }) } diff --git a/app/(main)/community/page.tsx b/app/(main)/community/page.tsx index 70e7796..abae0b0 100644 --- a/app/(main)/community/page.tsx +++ b/app/(main)/community/page.tsx @@ -4,17 +4,15 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card" -import { listGames, listOrders, listPlayers, listPosts } from "@/lib/api" +import { listGames, listPosts } from "@/lib/api" import { roleLabels } from "@/lib/constants" -import type { Game, Player, Post } from "@/lib/types" -import { ClipboardList, Heart, MessageCircle, PenSquare, Pin } from "lucide-react" +import type { Game, Post } from "@/lib/types" +import { Heart, MessageCircle, PenSquare, Pin } from "lucide-react" import Link from "next/link" import { useEffect, useState } from "react" export default function CommunityPage() { const [games, setGames] = useState([]) - const [players, setPlayers] = useState([]) - const [orders, setOrders] = useState>>([]) const [posts, setPosts] = useState([]) const [postsLoading, setPostsLoading] = useState(true) @@ -24,20 +22,16 @@ export default function CommunityPage() { useEffect(() => { let cancelled = false - Promise.all([listGames(), listPlayers(), Promise.resolve(listOrders()), listPosts()]) - .then(([gamesItems, playersItems, ordersItems, postsItems]) => { + Promise.all([listGames(), listPosts()]) + .then(([gamesItems, postsItems]) => { if (cancelled) return setGames(gamesItems) - setPlayers(playersItems) - setOrders(ordersItems) setPosts(postsItems) setPostsLoading(false) }) .catch(() => { if (cancelled) return setGames([]) - setPlayers([]) - setOrders([]) setPosts([]) setPostsLoading(false) }) @@ -110,87 +104,55 @@ export default function CommunityPage() { ) : filteredPosts.length === 0 ? (
暂无帖子
) : ( - filteredPosts.map((post) => - (() => { - const linkedOrder = post.linkedOrderId - ? orders.find((order) => order.id === post.linkedOrderId) - : null - const linkedPlayer = linkedOrder - ? players.find((player) => player.id === linkedOrder.playerId) - : null - - return ( - - - -
- - - {post.author.nickname[0]} - -
-
- {post.author.nickname} - - {roleLabels[post.authorRole]} - - {post.pinned && } -
- - {new Date(post.createdAt).toLocaleDateString("zh-CN")} - -
+ filteredPosts.map((post) => ( + + + +
+ + + {post.author.nickname[0]} + +
+
+ {post.author.nickname} + + {roleLabels[post.author.role]} + + {post.pinned && }
- - -

{post.title}

-

{post.content}

- {post.tags.length > 0 && ( -
- {post.tags.map((tag) => ( - - {tag} - - ))} -
- )} - {post.linkedOrderId && ( -
-
- - 关联订单秀单 -
- {linkedOrder && ( -
-

- {linkedOrder.service.gameName} · {linkedOrder.service.title} -

-

- {linkedOrder.playerName} - {linkedPlayer ? ` · ${linkedPlayer.rating}` : ""} -

-
- )} -
- )} -
- - - - {post.likeCount} + + {new Date(post.createdAt).toLocaleDateString("zh-CN")} - - - {post.commentCount} - - - - - ) - })(), - ) +
+
+
+ +

{post.title}

+

{post.content}

+ {post.tags.length > 0 && ( +
+ {post.tags.map((tag) => ( + + {tag} + + ))} +
+ )} +
+ + + + {post.likeCount} + + + + {post.commentCount} + + +
+ + )) )}
diff --git a/app/(main)/player/[id]/page.tsx b/app/(main)/player/[id]/page.tsx index b5a10f9..7c428ab 100644 --- a/app/(main)/player/[id]/page.tsx +++ b/app/(main)/player/[id]/page.tsx @@ -155,7 +155,7 @@ export default async function PlayerDetailPage({ params }: { params: Promise<{ i
- + {review.fromUserName[0]}
diff --git a/app/(main)/post/[id]/page.tsx b/app/(main)/post/[id]/page.tsx index f736c42..302edc3 100644 --- a/app/(main)/post/[id]/page.tsx +++ b/app/(main)/post/[id]/page.tsx @@ -38,7 +38,7 @@ export default async function PostDetailPage({ params }: { params: Promise<{ id:
{post.author.nickname} - {roleLabels[post.authorRole]} + {roleLabels[post.author.role]} {post.pinned && }
@@ -62,18 +62,6 @@ export default async function PostDetailPage({ params }: { params: Promise<{ id:
)} - {post.linkedOrderId && ( - -
-
- - 关联订单 -
-

点击查看订单详情

-
- - )} - {post.tags.length > 0 && (
{post.tags.map((tag) => ( @@ -84,6 +72,18 @@ export default async function PostDetailPage({ params }: { params: Promise<{ id:
)} + {post.linkedOrderId ? ( + +
+
+ + 关联订单 +
+

点击查看订单详情

+
+ + ) : null} +
"/posts/p1-1.jpg"), tags: selectedTags, linkedOrderId: effectivePostType === "show_order" ? selectedOrderId : undefined, - quotedPostId: effectivePostType === "quote" ? selectedQuotePostId : undefined, }) router.push("/community") @@ -131,7 +129,7 @@ export default function NewPostPage() { {availableOrders.map((order) => ( - {order.service.title} · {order.playerName} + {order.service.title} ))} diff --git a/app/(main)/search/page.tsx b/app/(main)/search/page.tsx index 453263a..8b4bbd2 100644 --- a/app/(main)/search/page.tsx +++ b/app/(main)/search/page.tsx @@ -218,7 +218,7 @@ function ShopCard({ item }: { item: ShopSearchItem }) {
- {item.shop.rating.toFixed(1)} + {item.shop.rating}
接单 {item.shop.totalOrders}
diff --git a/app/(main)/shop/[id]/page.tsx b/app/(main)/shop/[id]/page.tsx index 6b55c47..4cad481 100644 --- a/app/(main)/shop/[id]/page.tsx +++ b/app/(main)/shop/[id]/page.tsx @@ -25,7 +25,7 @@ export default async function ShopPage({ params }: PageProps) { const [shopPlayers, allServices] = await Promise.all([listPlayersByShop(shop.id), listServices()]) const playerIds = shopPlayers.map((p) => p.id) const shopServices = allServices.filter((s) => playerIds.includes(s.playerId)) - const shopReviews = (await listReviews()).filter((r) => playerIds.includes(r.toUserId)) + const shopReviews = await listReviews() const sortedSections = [...shop.templateConfig.sections] .filter((s) => s.enabled) .sort((a, b) => a.order - b.order) @@ -234,7 +234,7 @@ export default async function ShopPage({ params }: PageProps) {
- + {review.fromUserName[0]}
diff --git a/app/(order)/chat/[id]/page.tsx b/app/(order)/chat/[id]/page.tsx index 6d48876..1dbd0ec 100644 --- a/app/(order)/chat/[id]/page.tsx +++ b/app/(order)/chat/[id]/page.tsx @@ -11,7 +11,7 @@ import { sendImageMessage, sendTextMessage } from "@/lib/api/chat" import { notifyInfo } from "@/lib/toast" import { cn } from "@/lib/utils" import { useAuthStore } from "@/store/auth" -import { ArrowLeft, ImagePlus, Lock, Send } from "lucide-react" +import { ArrowLeft, ImagePlus, Send } from "lucide-react" import Image from "next/image" import Link from "next/link" import { use, useEffect, useRef, useState } from "react" @@ -96,20 +96,14 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin - {other.name[0]} + {other.nickname[0]}
- {other.name} + {other.nickname}
{session.type === "order" ? "订单会话" : "咨询会话"} - {session.readonly && ( - - - 只读 - - )}
@@ -127,11 +121,14 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin ) } const isMine = msg.senderId === userId + const sender = session.participants.find( + (participant) => participant.id === msg.senderId, + ) return (
- - {msg.senderName[0]} + + {(sender?.nickname ?? "?")[0]}
{msg.type === "image" ? ( @@ -166,74 +163,67 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
- {!session.readonly ? ( -
- { - const target = event.currentTarget - const file = target.files?.[0] - if (!file) return - const imageUrl = URL.createObjectURL(file) +
+ { + const target = event.currentTarget + const file = target.files?.[0] + if (!file) return + const imageUrl = URL.createObjectURL(file) - void Promise.resolve(sendImageMessage(session.id, imageUrl)) - .then((result) => { - if (!result.ok) { - notifyInfo(result.error.msg) - return - } - return Promise.resolve(listChatMessages(session.id)).then(setMessages) - }) - .finally(() => { - target.value = "" - }) - }} - /> -
{ - e.preventDefault() - const text = input.trim() - if (!text) return - - void Promise.resolve(sendTextMessage(session.id, text)).then((result) => { + void Promise.resolve(sendImageMessage(session.id, imageUrl)) + .then((result) => { if (!result.ok) { notifyInfo(result.error.msg) return } - setInput("") return Promise.resolve(listChatMessages(session.id)).then(setMessages) }) - }} + .finally(() => { + target.value = "" + }) + }} + /> + { + e.preventDefault() + const text = input.trim() + if (!text) return + + void Promise.resolve(sendTextMessage(session.id, text)).then((result) => { + if (!result.ok) { + notifyInfo(result.error.msg) + return + } + setInput("") + return Promise.resolve(listChatMessages(session.id)).then(setMessages) + }) + }} + > + setInput(e.target.value)} + placeholder="输入消息..." + className="flex-1" + /> + - -
-
- ) : ( -
- - 订单已关闭,会话为只读状态 -
- )} + + + + +
) diff --git a/app/(order)/chat/page.tsx b/app/(order)/chat/page.tsx index 7b1446a..3feb340 100644 --- a/app/(order)/chat/page.tsx +++ b/app/(order)/chat/page.tsx @@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge" import { Card, CardContent } from "@/components/ui/card" import { listChatSessions } from "@/lib/api" import { useAuthStore } from "@/store/auth" -import { Lock, MessageSquare } from "lucide-react" +import { MessageSquare } from "lucide-react" import Link from "next/link" import { useEffect, useState } from "react" @@ -45,24 +45,18 @@ export default function ChatListPage() { - {other.name[0]} + {other.nickname[0]}
- {other.name} + {other.nickname} {session.type === "order" ? "订单" : "咨询"} - {session.readonly && }

{session.lastMessage}

- {session.lastMessageAt && ( - - {new Date(session.lastMessageAt).toLocaleDateString("zh-CN")} - - )} {session.unreadCount > 0 && ( {session.unreadCount} diff --git a/app/(order)/dispute/[id]/page.tsx b/app/(order)/dispute/[id]/page.tsx index 170726b..02875fc 100644 --- a/app/(order)/dispute/[id]/page.tsx +++ b/app/(order)/dispute/[id]/page.tsx @@ -213,10 +213,8 @@ export default function DisputePage({ params }: { params: Promise<{ id: string } } if (existingDispute) { - const isInitiator = userId === existingDispute.initiatorId const canRespond = isParticipant && - !isInitiator && !existingDispute.respondentReason && (existingDispute.status === "open" || existingDispute.status === "reviewing") const canAppeal = @@ -246,7 +244,7 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
发起人: - {existingDispute.initiatorName} + 发起方
@@ -480,9 +478,7 @@ export default function DisputePage({ params }: { params: Promise<{ id: string } 发起争议 -

- {order.service.title} · {order.playerName} -

+

{order.service.title}

diff --git a/app/(order)/order/[id]/page.tsx b/app/(order)/order/[id]/page.tsx index 47c4b76..a6eb401 100644 --- a/app/(order)/order/[id]/page.tsx +++ b/app/(order)/order/[id]/page.tsx @@ -140,7 +140,7 @@ export default function OrderDetailPage({ params }: { params: Promise<{ id: stri const base = order.status === "pending_accept" ? new Date(order.createdAt).getTime() - : new Date(order.closedAt ?? order.createdAt).getTime() + : new Date(order.createdAt).getTime() const timeoutMs = order.status === "pending_accept" ? ORDER_ACCEPT_TIMEOUT_MS : ORDER_CLOSE_TIMEOUT_MS const remainSeconds = Math.max(0, Math.ceil((timeoutMs - (nowTs - base)) / 1000)) @@ -223,17 +223,9 @@ export default function OrderDetailPage({ params }: { params: Promise<{ id: stri
打手 - {order.playerName} + {order.service.title}
- {order.shopName && ( -
- 店铺 - - {order.shopName} - -
- )}
总价 @@ -265,13 +257,6 @@ export default function OrderDetailPage({ params }: { params: Promise<{ id: stri {new Date(order.acceptedAt).toLocaleString("zh-CN")}
)} - {order.closedAt && ( -
- - 结单时间: - {new Date(order.closedAt).toLocaleString("zh-CN")} -
- )} {order.completedAt && (
diff --git a/app/(order)/orders/page.tsx b/app/(order)/orders/page.tsx index 37a9bd7..8b88e0a 100644 --- a/app/(order)/orders/page.tsx +++ b/app/(order)/orders/page.tsx @@ -178,13 +178,7 @@ function OrderListContent({ {statusLabels[order.status]}
-

- {currentRole === "consumer" - ? `打手: ${order.playerName}` - : currentRole === "player" - ? `客户: ${order.consumerName}` - : `客户: ${order.consumerName} · 打手: ${order.playerName}`} -

+

{order.service.title}

diff --git a/app/(order)/review/[id]/page.tsx b/app/(order)/review/[id]/page.tsx index 842c7ea..4aa403f 100644 --- a/app/(order)/review/[id]/page.tsx +++ b/app/(order)/review/[id]/page.tsx @@ -120,9 +120,7 @@ export default function ReviewPage({ params }: { params: Promise<{ id: string }> 评价服务 -

- {order.service.title} · {order.playerName} -

+

{order.service.title}