diff --git a/src/views/AdminView.vue b/src/views/AdminView.vue index 22c9b3e..af837dc 100644 --- a/src/views/AdminView.vue +++ b/src/views/AdminView.vue @@ -868,12 +868,30 @@ async function testMbe() { const healthUrl = isLocalhost ? `${mbeUrl.value}/health` : `${mbeUrl.value}/v1/health` const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) }) if (!resp.ok) throw new Error(`HTTP ${resp.status}`) - const text = await resp.text() - if (text === 'OK') { - mbeStatus.value = 'online' - mbeInfo.value = { version: 'MarkBaseEngine', uptime: 0 } + + // 兼容 JSON 和文本格式的响应 + let isHealthy = false + const contentType = resp.headers.get('content-type') || '' + + if (contentType.includes('application/json')) { + // JSON 格式响应 + const json = await resp.json() + isHealthy = json.status === 'ok' || json.status === 'OK' + mbeInfo.value = { + version: json.version || 'MarkBaseEngine', + uptime: json.uptime || 0 + } } else { - throw new Error('Unexpected response: ' + text) + // 纯文本格式响应 + const text = await resp.text() + isHealthy = text === 'OK' || text.includes('"status":"ok"') + mbeInfo.value = { version: 'MarkBaseEngine', uptime: 0 } + } + + if (isHealthy) { + mbeStatus.value = 'online' + } else { + throw new Error('Unexpected response format') } } catch (e: any) { mbeStatus.value = 'offline'