refactor(types): align core types with backend contract
This commit is contained in:
@@ -42,14 +42,14 @@ export default function VerifyPage() {
|
||||
)
|
||||
|
||||
const buildMaterials = () => {
|
||||
const materials: Record<string, string> = {
|
||||
const materials = {
|
||||
realName,
|
||||
idNumber,
|
||||
gameProfile,
|
||||
idCardFront: "mock://idCardFront",
|
||||
idCardBack: "mock://idCardBack",
|
||||
gameScreenshot: "mock://gameScreenshot",
|
||||
}
|
||||
} satisfies Record<string, string>
|
||||
|
||||
return materials
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ import { useState } from "react"
|
||||
|
||||
import { canAccessDashboard } from "@/components/role-guard"
|
||||
|
||||
const roleLabels: Record<UserRole, string> = {
|
||||
const roleLabels = {
|
||||
consumer: "客户",
|
||||
player: "打手",
|
||||
owner: "店主",
|
||||
admin: "管理员",
|
||||
}
|
||||
} satisfies Record<UserRole, string>
|
||||
|
||||
export function Header() {
|
||||
const [mobileOpen, setMobileOpen] = useState(false)
|
||||
|
||||
+37
-35
@@ -1,11 +1,13 @@
|
||||
// All `id` fields come from backend snowflake int64.
|
||||
// Frontend stores them as strings to avoid JS number precision issues.
|
||||
|
||||
export type SnowflakeId = string
|
||||
|
||||
export type UserRole = "consumer" | "player" | "owner" | "admin"
|
||||
export type VerificationStatus = "pending" | "approved" | "rejected"
|
||||
|
||||
export interface User {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
username: string
|
||||
email?: string
|
||||
nickname: string
|
||||
@@ -19,16 +21,16 @@ export interface User {
|
||||
}
|
||||
|
||||
export interface Game {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
name: string
|
||||
icon: string
|
||||
category: "MOBA" | "FPS" | "动作" | "RPG"
|
||||
}
|
||||
|
||||
export interface PlayerService {
|
||||
id: string
|
||||
playerId: string
|
||||
gameId: string
|
||||
id: SnowflakeId
|
||||
playerId: SnowflakeId
|
||||
gameId: SnowflakeId
|
||||
gameName: string
|
||||
title: string
|
||||
description: string
|
||||
@@ -39,7 +41,7 @@ export interface PlayerService {
|
||||
}
|
||||
|
||||
export interface Player {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
user: User
|
||||
rating: number
|
||||
totalOrders: number
|
||||
@@ -47,13 +49,13 @@ export interface Player {
|
||||
status: "available" | "busy" | "offline"
|
||||
games: string[]
|
||||
services: PlayerService[]
|
||||
shopId?: string
|
||||
shopId?: SnowflakeId
|
||||
shopName?: string
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
export interface Shop {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
owner: User
|
||||
name: string
|
||||
banner?: string
|
||||
@@ -91,12 +93,12 @@ export type OrderStatus =
|
||||
| "cancelled"
|
||||
|
||||
export interface Order {
|
||||
id: string
|
||||
consumerId: string
|
||||
id: SnowflakeId
|
||||
consumerId: SnowflakeId
|
||||
consumerName: string
|
||||
playerId: string
|
||||
playerId: SnowflakeId
|
||||
playerName: string
|
||||
shopId?: string
|
||||
shopId?: SnowflakeId
|
||||
shopName?: string
|
||||
service: PlayerService
|
||||
status: OrderStatus
|
||||
@@ -109,12 +111,12 @@ export interface Order {
|
||||
}
|
||||
|
||||
export interface Review {
|
||||
id: string
|
||||
orderId: string
|
||||
fromUserId: string
|
||||
id: SnowflakeId
|
||||
orderId: SnowflakeId
|
||||
fromUserId: SnowflakeId
|
||||
fromUserName: string
|
||||
fromUserAvatar: string
|
||||
toUserId: string
|
||||
toUserId: SnowflakeId
|
||||
rating: number
|
||||
content?: string
|
||||
sealed: boolean
|
||||
@@ -122,9 +124,9 @@ export interface Review {
|
||||
}
|
||||
|
||||
export interface Dispute {
|
||||
id: string
|
||||
orderId: string
|
||||
initiatorId: string
|
||||
id: SnowflakeId
|
||||
orderId: SnowflakeId
|
||||
initiatorId: SnowflakeId
|
||||
initiatorName: string
|
||||
reason: string
|
||||
evidence: string[]
|
||||
@@ -134,8 +136,8 @@ export interface Dispute {
|
||||
}
|
||||
|
||||
interface BaseChatSession {
|
||||
id: string
|
||||
participants: { id: string; name: string; avatar: string }[]
|
||||
id: SnowflakeId
|
||||
participants: { id: SnowflakeId; name: string; avatar: string }[]
|
||||
lastMessage?: string
|
||||
lastMessageAt?: string
|
||||
unreadCount: number
|
||||
@@ -144,7 +146,7 @@ interface BaseChatSession {
|
||||
|
||||
export interface OrderChatSession extends BaseChatSession {
|
||||
type: "order"
|
||||
orderId: string
|
||||
orderId: SnowflakeId
|
||||
}
|
||||
|
||||
export interface ConsultationChatSession extends BaseChatSession {
|
||||
@@ -155,9 +157,9 @@ export interface ConsultationChatSession extends BaseChatSession {
|
||||
export type ChatSession = OrderChatSession | ConsultationChatSession
|
||||
|
||||
export interface ChatMessage {
|
||||
id: string
|
||||
sessionId: string
|
||||
senderId: string
|
||||
id: SnowflakeId
|
||||
sessionId: SnowflakeId
|
||||
senderId: SnowflakeId
|
||||
senderName: string
|
||||
senderAvatar: string
|
||||
type: "text" | "image" | "system"
|
||||
@@ -166,15 +168,15 @@ export interface ChatMessage {
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
author: User
|
||||
authorRole: UserRole
|
||||
title: string
|
||||
content: string
|
||||
images: string[]
|
||||
tags: string[]
|
||||
linkedOrderId?: string
|
||||
quotedPostId?: string
|
||||
linkedOrderId?: SnowflakeId
|
||||
quotedPostId?: SnowflakeId
|
||||
likeCount: number
|
||||
commentCount: number
|
||||
liked: boolean
|
||||
@@ -183,8 +185,8 @@ export interface Post {
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
id: string
|
||||
postId: string
|
||||
id: SnowflakeId
|
||||
postId: SnowflakeId
|
||||
author: User
|
||||
content: string
|
||||
likeCount: number
|
||||
@@ -193,7 +195,7 @@ export interface Comment {
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
type: "order" | "community" | "system"
|
||||
title: string
|
||||
content: string
|
||||
@@ -203,7 +205,7 @@ export interface Notification {
|
||||
}
|
||||
|
||||
export interface WalletTransaction {
|
||||
id: string
|
||||
id: SnowflakeId
|
||||
type: "topup" | "payment" | "income" | "withdrawal" | "refund"
|
||||
amount: number
|
||||
description: string
|
||||
@@ -211,9 +213,9 @@ export interface WalletTransaction {
|
||||
}
|
||||
|
||||
export interface Favorite {
|
||||
id: string
|
||||
userId: string
|
||||
id: SnowflakeId
|
||||
userId: SnowflakeId
|
||||
targetType: "player" | "shop"
|
||||
targetId: string
|
||||
targetId: SnowflakeId
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user