Commit 848c80fd authored by 董政锦's avatar 董政锦

fix: game5 PC端打印日志;

parent ee01ab34
...@@ -32,6 +32,13 @@ const imageUrls = { ...@@ -32,6 +32,13 @@ const imageUrls = {
const isStartPressed = ref(false); const isStartPressed = ref(false);
const renderAvatar = (item: any | null) => {
if (item && item.avatar) {
return `background: url("${String(item.avatar).replace(/"/g, '\\"')}") center / cover no-repeat;`
}
return `background: ${imageUrls.avatar} center / cover no-repeat;`
}
const pressStartButton = () => { const pressStartButton = () => {
isStartPressed.value = true; isStartPressed.value = true;
emit("start"); emit("start");
...@@ -66,7 +73,7 @@ const releaseStartButton = () => { ...@@ -66,7 +73,7 @@ const releaseStartButton = () => {
> >
<div> <div>
<div class="img-avatar-container"> <div class="img-avatar-container">
<div class="img-avatar" :style="`background:url('${item.avatar}') center / cover no-repeat;`"></div> <div class="img-avatar" :style="`${renderAvatar(item)}`"></div>
</div> </div>
<div class="txt-nickname"> <div class="txt-nickname">
{{ $format_str(item.nickname, 12) }} {{ $format_str(item.nickname, 12) }}
...@@ -235,7 +242,6 @@ const releaseStartButton = () => { ...@@ -235,7 +242,6 @@ const releaseStartButton = () => {
width: 60px; width: 60px;
height: 60px; height: 60px;
border-radius: 30px; border-radius: 30px;
background: v-bind("imageUrls.avatar");
} }
.txt-nickname { .txt-nickname {
......
...@@ -46,7 +46,9 @@ const confirmRefresh = (event: BeforeUnloadEvent) => { ...@@ -46,7 +46,9 @@ const confirmRefresh = (event: BeforeUnloadEvent) => {
const renderPlayers = (data: any) => { const renderPlayers = (data: any) => {
const players = Array.isArray(data?.list) ? data.list : [] const players = Array.isArray(data?.list) ? data.list : []
playerCount.value = Number(data?.count ?? players.length) const count = Number(data?.count ?? players.length)
console.log('[WebSocket] 玩家列表更新 - 在线人数:', count, '玩家数:', players.length, '数据:', JSON.stringify(players.map((p: any) => ({ nickname: p.nickname, userid: p.userid ?? p.wechat_id }))))
playerCount.value = count
loadingPlayers.value = Array.from( loadingPlayers.value = Array.from(
{ length: PLAYER_LIMIT }, { length: PLAYER_LIMIT },
(_, index) => players[index] ?? emptyLoadingPlayer(), (_, index) => players[index] ?? emptyLoadingPlayer(),
...@@ -114,6 +116,7 @@ const gotoRank1WithIntro = async () => { ...@@ -114,6 +116,7 @@ const gotoRank1WithIntro = async () => {
} }
function handleRoomState(data: any) { function handleRoomState(data: any) {
console.log('[WebSocket] 房间状态更新 - status:', data?.status, '数据:', JSON.stringify(data))
if (Array.isArray(data?.list)) { if (Array.isArray(data?.list)) {
renderPlayers(data) renderPlayers(data)
} }
...@@ -140,11 +143,18 @@ const { startGame, createRoom, backRoom } = useAdminGameSocket({ ...@@ -140,11 +143,18 @@ const { startGame, createRoom, backRoom } = useAdminGameSocket({
gameId: 'game5', gameId: 'game5',
onRoomState: handleRoomState, onRoomState: handleRoomState,
onRoomJoin: (data) => { onRoomJoin: (data) => {
console.log('[WebSocket] 玩家加入房间 - 数据:', JSON.stringify(data))
renderPlayers(data) renderPlayers(data)
gotoLoading() gotoLoading()
}, },
onGameStart: gotoRank1WithIntro, onGameStart: () => {
onRoomRank: updateRankPlayers, console.log('[WebSocket] 游戏开始!')
gotoRank1WithIntro()
},
onRoomRank: (data) => {
console.log('[WebSocket] 排名更新 - 数据:', JSON.stringify(data))
updateRankPlayers(data)
},
onRelogin: async () => { onRelogin: async () => {
$remove_socket_storage(); $remove_socket_storage();
await router.replace('/') await router.replace('/')
......
...@@ -107,6 +107,7 @@ watch( ...@@ -107,6 +107,7 @@ watch(
() => props.rankList, () => props.rankList,
(rankList) => { (rankList) => {
if (rankList && rankList.length > 0) { if (rankList && rankList.length > 0) {
console.log('[Rank1View] 排名列表更新 - 数据:', JSON.stringify(rankList.map(p => ({ nickname: p.nickname, score: p.score }))))
updateRankList(rankList); updateRankList(rankList);
} }
}, },
...@@ -121,11 +122,13 @@ const startIntro = async () => { ...@@ -121,11 +122,13 @@ const startIntro = async () => {
horses.value = []; horses.value = [];
horseIdCounter = 0; horseIdCounter = 0;
console.log('[Rank1View] 游戏流程启动 - 开始 3s 倒计时 + 60s 游戏')
// 启动完整倒计时:3s 开场 + 60s 游戏 // 启动完整倒计时:3s 开场 + 60s 游戏
const countdownPromise = designStage.value?.startCountdown(3, 60); const countdownPromise = designStage.value?.startCountdown(3, 60);
// 等待 3-2-1 开场倒计时结束(~3.5s 后安全触发) // 等待 3-2-1 开场倒计时结束(~3.5s 后安全触发)
await new Promise((r) => setTimeout(r, 3500)); await new Promise((r) => setTimeout(r, 3500));
console.log('[Rank1View] 倒计时结束,马匹开始奔跑')
// Phase 2: 倒计时结束 → 游戏正式开始,背景动画+马匹启动 // Phase 2: 倒计时结束 → 游戏正式开始,背景动画+马匹启动
gameStarted.value = true; gameStarted.value = true;
...@@ -139,6 +142,7 @@ const startIntro = async () => { ...@@ -139,6 +142,7 @@ const startIntro = async () => {
}; };
const stopGame = () => { const stopGame = () => {
console.log('[Rank1View] 游戏结束 - 60s 倒计时到')
isGameRunning.value = false; isGameRunning.value = false;
showResult.value = true; showResult.value = true;
stopHorseLoop(); stopHorseLoop();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment