feat: 实现大厅到房间页面的导航跳转
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
||||||
import TableCard from './TableCard.vue'
|
import TableCard from './TableCard.vue'
|
||||||
import CreateRoomDialog from './CreateRoomDialog.vue'
|
import CreateRoomDialog from './CreateRoomDialog.vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import type { RoomItem } from '@/api/modules/game'
|
import type { RoomItem } from '@/api/modules/game'
|
||||||
import { useBaseLayoutStore } from '@/stores'
|
import { useBaseLayoutStore } from '@/stores'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
@@ -61,6 +62,7 @@ const statusFilters = [
|
|||||||
]
|
]
|
||||||
const activeFilter = ref('all')
|
const activeFilter = ref('all')
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const baseLayoutStore = useBaseLayoutStore()
|
const baseLayoutStore = useBaseLayoutStore()
|
||||||
const { activeGameId } = storeToRefs(baseLayoutStore)
|
const { activeGameId } = storeToRefs(baseLayoutStore)
|
||||||
|
|
||||||
@@ -129,20 +131,17 @@ const filteredRooms = computed(() => {
|
|||||||
|
|
||||||
/** 加入房间 */
|
/** 加入房间 */
|
||||||
function handleJoin(roomId: string) {
|
function handleJoin(roomId: string) {
|
||||||
// eslint-disable-next-line no-console
|
router.push(`/room/${roomId}`)
|
||||||
console.log('加入房间:', roomId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加入指定座位 */
|
/** 加入指定座位 */
|
||||||
function handleJoinSeat(roomId: string, seatIndex: number) {
|
function handleJoinSeat(roomId: string, seatIndex: number) {
|
||||||
// eslint-disable-next-line no-console
|
router.push({ path: `/room/${roomId}`, query: { seat: String(seatIndex) } })
|
||||||
console.log('加入房间:', roomId, '座位:', seatIndex)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 观战 */
|
/** 观战 */
|
||||||
function handleSpectate(roomId: string) {
|
function handleSpectate(roomId: string) {
|
||||||
// eslint-disable-next-line no-console
|
router.push(`/room/${roomId}`)
|
||||||
console.log('观战房间:', roomId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建房间对话框可见性 */
|
/** 创建房间对话框可见性 */
|
||||||
|
|||||||
Reference in New Issue
Block a user