From fba18fc32c238e0d52b2a0328c7e98b61a6ee4ef Mon Sep 17 00:00:00 2001 From: yahaozhang Date: Mon, 3 Nov 2025 20:58:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Vite=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8=20localhost=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=B8=B8=E6=88=8F=E5=AE=8C=E6=88=90=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E5=92=8C=E8=BF=87=E6=9C=9F=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=93=BE=E6=8E=A5=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E8=B0=83=E6=95=B4=E8=B7=AF=E7=94=B1=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=B8=B8=E6=88=8F=E7=95=8C=E9=9D=A2=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/usePlayState.js | 25 ++++++++++++++++++++++++- src/config/links.js | 6 +++++- src/router/index.js | 3 ++- src/views/Play.vue | 9 +++++---- vite.config.js | 3 ++- 5 files changed, 38 insertions(+), 8 deletions(-) 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/, ''), },