1
This commit is contained in:
@@ -247,8 +247,16 @@ const SSEManager = {
|
||||
const src = new EventSource(`${sseUrl}?clientId=${clientId}&token=${token}`)
|
||||
this.connection = src
|
||||
|
||||
src.onmessage = (e) => this.handleMessage(e)
|
||||
src.onerror = () => this.handleError()
|
||||
console.log('SSE连接已建立:', sseUrl)
|
||||
src.onopen = () => console.log('SSE连接打开')
|
||||
src.onmessage = (e) => {
|
||||
console.log('SSE收到消息:', e.data)
|
||||
this.handleMessage(e)
|
||||
}
|
||||
src.onerror = (e) => {
|
||||
console.log('SSE连接错误:', e)
|
||||
this.handleError()
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('SSE连接失败:', e.message)
|
||||
}
|
||||
@@ -317,19 +325,26 @@ async function fetchDeviceData() {
|
||||
async function confirmRemoveDevice(row: DeviceItem & { isCurrent?: boolean }) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要移除该设备吗?', '你确定要移除设备吗?', { confirmButtonText: '确定移除', cancelButtonText: '取消', type: 'warning' })
|
||||
await deviceApi.remove({ deviceId: row.deviceId })
|
||||
|
||||
console.log('正在移除设备:', row.deviceId)
|
||||
const result = await deviceApi.remove({ deviceId: row.deviceId })
|
||||
console.log('移除设备API响应:', result)
|
||||
|
||||
devices.value = devices.value.filter(d => d.deviceId !== row.deviceId)
|
||||
deviceQuota.value.used = Math.max(0, (deviceQuota.value.used || 0) - 1)
|
||||
|
||||
// 如果是本机设备被移除,执行logout - 复刻HTML版本逻辑
|
||||
// 如果是本机设备被移除,执行logout
|
||||
const clientId = getClientIdFromToken()
|
||||
console.log('检查设备ID:', { removed: row.deviceId, current: clientId })
|
||||
if (row.deviceId === clientId) {
|
||||
console.log('移除的是本机设备,执行logout')
|
||||
await logout()
|
||||
}
|
||||
|
||||
ElMessage.success('已移除设备')
|
||||
} catch (e) {
|
||||
/* 用户取消或失败 */
|
||||
console.error('移除设备失败:', e)
|
||||
ElMessage.error('移除设备失败: ' + (e?.message || '未知错误'))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user