diff --git a/src/composables/usePlayState.js b/src/composables/usePlayState.js index 580b3d5..46e0576 100644 --- a/src/composables/usePlayState.js +++ b/src/composables/usePlayState.js @@ -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 }) diff --git a/src/config/links.js b/src/config/links.js index 098fc6e..df9e260 100644 --- a/src/config/links.js +++ b/src/config/links.js @@ -13,7 +13,11 @@ export const LINK_CONFIG = { // 链接地址模板 getLinkUrl: (codeNo) => { - return `${LINK_CONFIG.BASE_URL}${LINK_CONFIG.GAME_PATH}?${LINK_CONFIG.CODE_PARAM}=${codeNo}` + // 生成随机参数:时间戳 + 随机字符串 + const timestamp = Date.now() + const random = Math.random().toString(36).substring(2, 8) + const randomParam = `${timestamp}${random}` + return `${LINK_CONFIG.BASE_URL}${LINK_CONFIG.GAME_PATH}/${codeNo}?t=${randomParam}` } } diff --git a/src/router/index.js b/src/router/index.js index 48b6f97..d6e5ce0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,7 +15,8 @@ const NotFound = () => import('@/views/NotFound.vue') export const routes = [ { path: '/login', name: 'Login', component: Login, meta: { public: true, title: '登录' } }, - { path: '/play', name: 'Play', component: Play, meta: { public: true, title: '上号任务' } }, + { path: '/play/:code', name: 'Play', component: Play, meta: { public: true, title: '上号任务' } }, + { path: '/play', name: 'PlayLegacy', component: Play, meta: { public: true, title: '上号任务' } }, { path: '/', component: AdminLayout, diff --git a/src/views/Play.vue b/src/views/Play.vue index 4fd7236..c856f29 100644 --- a/src/views/Play.vue +++ b/src/views/Play.vue @@ -32,7 +32,7 @@ - -
+ +
已打完
@@ -141,7 +141,8 @@ export default { } = useQrCode() onMounted(() => { - const code = route.query.code + // 兼容两种方式:路径参数和查询参数 + const code = route.params.code || route.query.code if (!code) { state.error = 'INVALID_CODE' state.loading = false diff --git a/vite.config.js b/vite.config.js index 7da7c15..58a5a18 100644 --- a/vite.config.js +++ b/vite.config.js @@ -27,7 +27,8 @@ export default defineConfig({ server: { proxy: { '/api': { - target: 'http://127.0.0.1:18080', + // target: 'https://uzi1.cn/api', + target: 'http://localhost:18080', changeOrigin: true, rewrite: (p) => p.replace(/^\/api/, ''), },