refactor: extract shared constants to lib/constants.ts

This commit is contained in:
zetaloop
2026-02-20 20:39:14 +08:00
parent ed3858cff3
commit 9267df9ea1
3 changed files with 23 additions and 32 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import { z } from "zod"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { currentUser } from "@/lib/mock-data"
import { useAuthStore } from "@/store/auth"
const loginSchema = z.object({
@@ -29,7 +30,7 @@ export default function LoginPage() {
const onSubmit = async (_data: z.infer<typeof loginSchema>) => {
await new Promise((r) => setTimeout(r, 500))
login()
login(currentUser, ["consumer", "player", "owner"])
router.push("/")
}
+1 -11
View File
@@ -7,22 +7,12 @@ import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { statusLabels } from "@/lib/constants"
import { mockChatSessions, mockOrders } from "@/lib/mock-data"
import type { OrderStatus } from "@/lib/types"
import { cn } from "@/lib/utils"
import { useAuthStore } from "@/store/auth"
const statusLabels: Record<OrderStatus, string> = {
pending_payment: "待支付",
pending_accept: "待接单",
in_progress: "进行中",
pending_close: "待结单",
pending_review: "待评价",
disputed: "争议中",
completed: "已完成",
cancelled: "已取消",
}
const statusColors: Record<OrderStatus, string> = {
pending_payment: "bg-yellow-100 text-yellow-800",
pending_accept: "bg-blue-100 text-blue-800",
+20 -20
View File
@@ -24,7 +24,7 @@ export const mockUsers: User[] = [
avatar: "/avatars/u1.jpg",
role: "consumer",
phone: "138****1234",
bio: "下班打两把,周末经常熬夜",
bio: "工作日打两把,周末偶尔通宵",
createdAt: "2025-01-15",
},
{
@@ -34,7 +34,7 @@ export const mockUsers: User[] = [
avatar: "/avatars/u2.jpg",
role: "player",
phone: "139****5678",
bio: "主打峡谷双排,逆风也会认真打",
bio: "晚上在线多,逆风不摆,能语音更快",
createdAt: "2024-11-20",
},
{
@@ -44,7 +44,7 @@ export const mockUsers: User[] = [
avatar: "/avatars/u3.jpg",
role: "owner",
phone: "137****9012",
bio: "白天管店,晚上回消息慢点",
bio: "店里就三个人,忙的时候回消息慢点",
createdAt: "2024-08-10",
},
{
@@ -53,7 +53,7 @@ export const mockUsers: User[] = [
nickname: "阿辰",
avatar: "/avatars/u4.jpg",
role: "player",
bio: "练枪党,报点快,话不多",
bio: "主狙和突破都打,报点直给",
createdAt: "2025-02-01",
},
{
@@ -62,7 +62,7 @@ export const mockUsers: User[] = [
nickname: "甜甜酱",
avatar: "/avatars/u5.jpg",
role: "player",
bio: "主辅原神日常,社恐但不摆烂",
bio: "主辅+原神日常,社恐,但会认真打",
createdAt: "2025-01-05",
},
]
@@ -84,8 +84,8 @@ export const mockServices: PlayerService[] = [
playerId: "u2",
gameId: "g1",
gameName: "英雄联盟",
title: "LOL双排分",
description: "打野和中路都行,逆风不甩锅,打完会说两句思路",
title: "LOL双排稳一点上分",
description: "打野/中,前两把先磨合。逆风会讲思路,不闷着。",
price: 33,
unit: "局",
rankRange: "铂金-大师",
@@ -96,9 +96,9 @@ export const mockServices: PlayerService[] = [
playerId: "u2",
gameId: "g2",
gameName: "王者荣耀",
title: "王者补位星",
description: "单排连跪就来组队,能补位,想冲几星先聊清楚",
price: 29,
title: "王者补位星",
description: "连跪想止损就来,射手辅助都能补。冲几星先说,我按你节奏来。",
price: 27,
unit: "星",
rankRange: "星耀-王者80星",
availability: ["每天 18:30-00:30"],
@@ -109,8 +109,8 @@ export const mockServices: PlayerService[] = [
gameId: "g3",
gameName: "CS2",
title: "CS2车队位",
description: "不整花活,先报点再打,节奏比较快",
price: 58,
description: "语音里先报点,残局我来喊。不开喷,失误就下一把拉回来。",
price: 57,
unit: "局",
rankRange: "白银-超凡",
availability: ["每天 15:00-01:00"],
@@ -121,8 +121,8 @@ export const mockServices: PlayerService[] = [
gameId: "g1",
gameName: "英雄联盟",
title: "LOL轻松双排",
description: "主辅位,能聊也能安静打,连跪会及时换玩法",
price: 23,
description: "主辅位,偏保人打法。想聊天就聊,不想说话也行。",
price: 22,
unit: "局",
availability: ["周末 11:00-23:30"],
},
@@ -132,8 +132,8 @@ export const mockServices: PlayerService[] = [
gameId: "g5",
gameName: "原神",
title: "原神日常清体力",
description: "委托、树脂、活动都能代,做完发截图",
price: 17,
description: "每日委托、树脂、活动都能清。做完发截图,不乱动你号。",
price: 19,
unit: "次",
availability: ["工作日 21:00-24:00", "周末白天可"],
},
@@ -185,16 +185,16 @@ export const mockShops: Shop[] = [
owner: mockUsers[2],
name: "王者电竞工作室",
banner: "/banners/shop1.jpg",
description: "店里人不算多,主打晚间在线,接单会先确认你的需求",
rating: 4.3,
totalOrders: 210,
description: "晚上在线的人多一点,接单会先问清楚你想怎么打。",
rating: 4.4,
totalOrders: 68,
playerCount: 7,
commissionType: "percentage",
commissionValue: 15,
allowMultiShop: false,
allowIndependentOrders: true,
dispatchMode: "manual",
announcements: ["晚高峰单子多,排队会慢一点", "这周加了原神代肝档位"],
announcements: ["晚上9点后单子多,等位可能会慢", "这周加了原神日常代清,截图回传"],
templateConfig: {
sections: [
{ type: "banner", enabled: true, order: 0 },