1
This commit is contained in:
@@ -6,7 +6,7 @@ import http from '@/plugins/http'
|
||||
|
||||
// 获取链接状态
|
||||
export function getLinkStatus(code) {
|
||||
return http.get('/api/link/status', {
|
||||
return http.get(`/api/link/status?t=${Date.now()}`, {
|
||||
params: { code }
|
||||
})
|
||||
}
|
||||
@@ -34,12 +34,12 @@ export function pollLoginStatus(code) {
|
||||
|
||||
// 获取游戏界面数据
|
||||
export function getGameInterface(code) {
|
||||
return http.get(`/api/link/${code}/game-interface`)
|
||||
return http.get(`/api/link/${code}/game-interface?t=${Date.now()}`)
|
||||
}
|
||||
|
||||
// 获取二维码图片(可选,用于代理二维码避免混合内容问题)
|
||||
export function getQRCode(code) {
|
||||
return http.get('/api/link/qr.png', {
|
||||
return http.get(`/api/link/qr.png?t=${Date.now()}`, {
|
||||
params: { code },
|
||||
responseType: 'blob'
|
||||
})
|
||||
|
||||
@@ -110,23 +110,10 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isWaitingQr(newVal) {
|
||||
if (newVal && this.mecmachineId) {
|
||||
this.startQrProbe()
|
||||
} else {
|
||||
this.stopQrProbe()
|
||||
}
|
||||
},
|
||||
mecmachineId(newVal) {
|
||||
if (this.isWaitingQr && newVal) {
|
||||
this.startQrProbe()
|
||||
}
|
||||
}
|
||||
// 移除二维码探测逻辑,确保必须等待指定时间
|
||||
},
|
||||
mounted() {
|
||||
if (this.isWaitingQr && this.mecmachineId) {
|
||||
this.startQrProbe()
|
||||
}
|
||||
// 移除二维码探测逻辑,确保必须等待指定时间
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.stopQrProbe()
|
||||
@@ -137,21 +124,7 @@ export default {
|
||||
const secs = seconds % 60
|
||||
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
|
||||
},
|
||||
startQrProbe() {
|
||||
this.stopQrProbe()
|
||||
const attemptLoad = () => {
|
||||
if (!this.mecmachineId) return
|
||||
const testImg = new Image()
|
||||
testImg.onload = () => {
|
||||
this.$emit('qrImageLoad')
|
||||
this.stopQrProbe()
|
||||
}
|
||||
testImg.onerror = () => {}
|
||||
testImg.src = `https://uzi1.cn/image/${this.mecmachineId}/二维码.png?t=${Date.now()}`
|
||||
}
|
||||
attemptLoad()
|
||||
this.probeTimer = setInterval(attemptLoad, 1000)
|
||||
},
|
||||
// 移除二维码探测方法,确保必须等待指定时间后才显示二维码
|
||||
stopQrProbe() {
|
||||
if (this.probeTimer) {
|
||||
clearInterval(this.probeTimer)
|
||||
|
||||
@@ -197,38 +197,8 @@ export default {
|
||||
}
|
||||
|
||||
const handleQrReadyEarly = async () => {
|
||||
try {
|
||||
if (!state.isWaitingQr) return
|
||||
if (!state.mecmachineId) return
|
||||
if (state.qrInfo && state.qrInfo.url) return
|
||||
// 结束等待并清理相关定时器
|
||||
state.isWaitingQr = false
|
||||
clearQrDelayCountdown()
|
||||
if (typeof clearQrDelayTimeout === 'function') {
|
||||
clearQrDelayTimeout(state)
|
||||
}
|
||||
// 立即拉取二维码并开始倒计时与登录轮询
|
||||
await fetchQrCodeAfterDelay(
|
||||
state,
|
||||
countdown,
|
||||
state.mecmachineId,
|
||||
state.qrCreatedAt,
|
||||
state.qrExpireAt
|
||||
)
|
||||
if (state.status === 'USING') {
|
||||
startCountdown()
|
||||
startLoginPolling(state.code, handleLoggedInStatus, handleCompletedStatus)
|
||||
startProgressPolling(state.code, (progressData) => {
|
||||
state.currentPoints = progressData.currentPoints || state.currentPoints
|
||||
state.totalPoints = progressData.totalPoints || state.totalPoints
|
||||
if (progressData.completedPoints !== undefined) {
|
||||
state.completedPoints = progressData.completedPoints
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提前获取二维码失败:', error)
|
||||
}
|
||||
// 移除提前显示二维码的逻辑,确保必须等待指定时间后才显示
|
||||
console.log('二维码提前就绪事件被忽略,必须等待指定时间后才显示')
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user