diff --git a/src/views/AdminView.vue b/src/views/AdminView.vue index af837dc..9bdbfe0 100644 --- a/src/views/AdminView.vue +++ b/src/views/AdminView.vue @@ -497,6 +497,11 @@ +
+ +
@@ -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>([]) +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()]) })