1
This commit is contained in:
@@ -252,9 +252,12 @@ const SSEManager = {
|
||||
const src = new EventSource(`${sseUrl}?clientId=${clientId}&token=${token}`)
|
||||
this.connection = src
|
||||
|
||||
const username = getUsernameFromToken(token)
|
||||
console.log('SSE连接详情:', {
|
||||
url: sseUrl,
|
||||
username,
|
||||
clientId,
|
||||
sessionKey: `${username}:${clientId}`,
|
||||
token: token.substring(0, 20) + '...',
|
||||
fullUrl: `${sseUrl}?clientId=${clientId}&token=${token.substring(0, 20)}...`
|
||||
})
|
||||
@@ -318,6 +321,23 @@ const SSEManager = {
|
||||
try { this.connection.close() } catch {}
|
||||
this.connection = null
|
||||
}
|
||||
},
|
||||
|
||||
// 检查连接状态
|
||||
checkStatus() {
|
||||
if (!this.connection) {
|
||||
console.log('❌ SSE未连接')
|
||||
return false
|
||||
}
|
||||
console.log('SSE连接状态:', this.connection.readyState, this.connection.url)
|
||||
return this.connection.readyState === 1 // 1 = OPEN
|
||||
},
|
||||
|
||||
// 强制重连
|
||||
reconnect() {
|
||||
console.log('🔄 强制重连SSE')
|
||||
this.disconnect()
|
||||
setTimeout(() => this.connect(), 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,8 +377,8 @@ async function confirmRemoveDevice(row: DeviceItem & { isCurrent?: boolean }) {
|
||||
await ElMessageBox.confirm('确定要移除该设备吗?', '你确定要移除设备吗?', { confirmButtonText: '确定移除', cancelButtonText: '取消', type: 'warning' })
|
||||
|
||||
console.log('正在移除设备:', row.deviceId)
|
||||
const result = await deviceApi.remove({ deviceId: row.deviceId })
|
||||
console.log('移除设备API响应:', result)
|
||||
await deviceApi.remove({ deviceId: row.deviceId })
|
||||
console.log('✅ 移除设备API调用成功')
|
||||
|
||||
devices.value = devices.value.filter(d => d.deviceId !== row.deviceId)
|
||||
deviceQuota.value.used = Math.max(0, (deviceQuota.value.used || 0) - 1)
|
||||
@@ -381,6 +401,16 @@ async function confirmRemoveDevice(row: DeviceItem & { isCurrent?: boolean }) {
|
||||
onMounted(async () => {
|
||||
showContent()
|
||||
await checkAuth()
|
||||
|
||||
// 添加全局调试函数
|
||||
window.debugSSE = {
|
||||
status: () => SSEManager.checkStatus(),
|
||||
reconnect: () => SSEManager.reconnect(),
|
||||
disconnect: () => SSEManager.disconnect(),
|
||||
getCurrentClientId: () => getClientIdFromToken(),
|
||||
testLogout: () => logout()
|
||||
}
|
||||
console.log('🔧 调试工具已注册到 window.debugSSE')
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user