feat: 添加房间路由和获取房间详情 API
This commit is contained in:
@@ -3,7 +3,8 @@ import type {
|
||||
CreateRoomRequest,
|
||||
CreateRoomResponse,
|
||||
GetRoomListRequest,
|
||||
GetRoomListResponse
|
||||
GetRoomListResponse,
|
||||
RoomDetailResponse
|
||||
} from './types'
|
||||
|
||||
/**
|
||||
@@ -35,3 +36,16 @@ export function getRoomList(params: GetRoomListRequest) {
|
||||
export function createRoom(data: CreateRoomRequest) {
|
||||
return requestClient.post<CreateRoomResponse>('/game/room/create', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取房间详情
|
||||
*
|
||||
* 用于进入房间页时获取初始快照(棋盘状态、玩家信息等)。
|
||||
* 无需登录即可调用(观战者也需访问)。
|
||||
*
|
||||
* @param roomId 房间 ID
|
||||
* @returns 房间详情
|
||||
*/
|
||||
export function getRoomDetail(roomId: string) {
|
||||
return requestClient.get<RoomDetailResponse>(`/game/room/${roomId}`)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/layouts/BaseLayout.vue'),
|
||||
children: []
|
||||
},
|
||||
{
|
||||
path: '/room/:roomId',
|
||||
name: 'Room',
|
||||
component: () => import('@/views/game/RoomPage.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/auth',
|
||||
name: 'Authentication',
|
||||
|
||||
Reference in New Issue
Block a user