feat: fix MBE health check and add model selection dropdown

- Fixed testMbe() to always use /health instead of /v1/health
- Added model selection dropdown for MarkBaseEngine
- Modified startService('mbe') to pass model and port parameters
- Added loadMbeModels() to fetch available models on mount
- Added getApiBase import
This commit is contained in:
2026-10-22 21:40:47 +08:00
parent 38260a4c61
commit 2cff332d55

View File

@@ -497,6 +497,11 @@
<input class="settings-input" v-model="mbeUrl" placeholder="http://localhost:8080" />
<button class="settings-test-btn" @click="testMbe" :disabled="testingMbe">{{ testingMbe ? 'Testing...' : 'Test' }}</button>
</div>
<div class="service-row" style="margin-top: 8px;">
<select v-model="mbeSelectedModel" class="settings-input" :disabled="mbeActionLoading || mbeModels.length === 0">
<option v-for="m in mbeModels" :key="m.dir" :value="m.dir">{{ m.name }}</option>
</select>
</div>
<div class="service-actions">
<button class="service-stop-btn" @click="stopService('mbe')" :disabled="mbeActionLoading">Stop</button>
<button class="service-start-btn" @click="startService('mbe')" :disabled="mbeActionLoading">Start</button>
@@ -560,6 +565,7 @@
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
import { apiCall } from '../api'
import { loadSystemStats, systemStatsCache, SystemStats } from '../store'
import { getApiBase } from '@/api/config'
const activeTab = ref('dashboard')
const stats = ref({ cpu: 0, memory: 0, disk: 0 })
@@ -686,6 +692,10 @@ const markbaseUrl = ref('http://localhost:11438')
const mbeUrl = ref('http://localhost:8080')
const proxyUrl = ref('http://localhost:8888')
const workerUrl = ref('http://localhost:11438')
// MBE Models
const mbeModels = ref<Array<{id: string, dir: string, name: string}>>([])
const mbeSelectedModel = ref('E4B-MarkBase')
const coreStatus = ref('unknown')
const mbStatus = ref('unknown')
const mbeStatus = ref('unknown')
@@ -742,7 +752,12 @@ async function startService(name: string) {
s.loading.value = true
s.result.value = ''
try {
const result = await apiCall('start_service', { name })
const args: any = { name }
if (name === 'mbe') {
args.model = mbeSelectedModel.value
args.port = 8080
}
const result = await apiCall('start_service', args)
const started = typeof result === 'string' ? result === 'started' : result?.result === 'started'
s.result.value = started ? (name === 'mbe' ? 'Loading model...' : 'Service started') : JSON.stringify(result)
s.ok.value = started
@@ -864,8 +879,9 @@ async function testMbe() {
testingMbe.value = true
mbeInfo.value = null
try {
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
const healthUrl = isLocalhost ? `${mbeUrl.value}/health` : `${mbeUrl.value}/v1/health`
// MarkBaseServer only exposes /health (returns plain text "OK")
// Always use /health regardless of hostname
const healthUrl = `${mbeUrl.value.replace(/\/$/, '')}/health`
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
@@ -884,7 +900,7 @@ async function testMbe() {
} else {
// 纯文本格式响应
const text = await resp.text()
isHealthy = text === 'OK' || text.includes('"status":"ok"')
isHealthy = text.trim() === 'OK' || text.includes('"status":"ok"')
mbeInfo.value = { version: 'MarkBaseEngine', uptime: 0 }
}
@@ -1193,8 +1209,26 @@ async function saveConfig() {
}
}
async function loadMbeModels() {
try {
const base = getApiBase()
const res = await fetch(`${base}/api/v2/mbe/models`, { signal: AbortSignal.timeout(5000) })
if (res.ok) {
const data = await res.json()
if (data.models && data.models.length > 0) {
mbeModels.value = data.models
mbeSelectedModel.value = data.default || data.models[0].dir
}
}
} catch (e) {
// Silently fail - models list is optional
console.error('Failed to load MBE models:', e)
}
}
onMounted(async () => {
loadServiceUrls()
await loadMbeModels()
await Promise.all([loadDashboard(), loadUsers(), loadShares(), loadSettings()])
await Promise.all([testCoreApi(), testMarkbase(), testMbe(), testProxy(), testWorker()])
})