更新 Vite 配置以使用 localhost,新增游戏完成时间戳和过期判断,优化链接生成逻辑,调整路由以支持路径参数,改进游戏界面状态显示

This commit is contained in:
yahaozhang
2025-11-03 20:58:22 +08:00
parent 23e2a4512b
commit fba18fc32c
5 changed files with 38 additions and 8 deletions

View File

@@ -37,7 +37,9 @@ export function usePlayState() {
machineId: null,
qrCreatedAt: null,
qrExpireAt: null,
qrDelayTimeoutId: null
qrDelayTimeoutId: null,
completedAt: null,
isCompletedExpired: false
})
const initializePage = async () => {
@@ -148,6 +150,25 @@ export function usePlayState() {
state.status = 'COMPLETED'
// 保存完成时间戳
if (gameData.completedAt) {
state.completedAt = gameData.completedAt
// 判断是否超过24小时
const now = Math.floor(Date.now() / 1000) // 当前时间戳(秒)
const completedTime = gameData.completedAt
const hoursPassed = (now - completedTime) / 3600 // 转换为小时
state.isCompletedExpired = hoursPassed > 24
console.log('完成时间判断:', {
completedAt: completedTime,
now: now,
hoursPassed: hoursPassed.toFixed(2),
isExpired: state.isCompletedExpired
})
}
// 更新区域和机器信息
if (gameData.region) {
state.region = gameData.region
@@ -181,6 +202,8 @@ export function usePlayState() {
totalPoints: state.totalPoints,
completedPoints: state.completedPoints,
currentPoints: state.currentPoints,
completedAt: state.completedAt,
isCompletedExpired: state.isCompletedExpired,
assets: !!state.assets
})