fix: show clear error message when MarkBase needs restart (PostgreSQL→SQLite migration)

- Detects 'missing field postgresql' error from MarkBase config endpoint
- Shows user-friendly message: 'MarkBase needs restart (PostgreSQL→SQLite migration)'
- Helps users understand the error is due to outdated MarkBase instance
This commit is contained in:
2026-10-27 01:41:07 +08:00
parent 052178b084
commit cb2b6a0292

View File

@@ -1038,9 +1038,13 @@ async function loadSettings() {
try {
const resp = await fetch(`${markbaseUrl.value}/api/v2/config`)
if (!resp.ok) {
// MarkBase config may return 500 if config file is incomplete
const errData = await resp.json().catch(() => null)
throw new Error(`HTTP ${resp.status}: ${errData?.error || resp.statusText}`)
const errMsg = errData?.error || resp.statusText || ''
// MarkBase config may return 500 if still running old version requiring postgresql
if (errMsg.includes('postgresql')) {
throw new Error('MarkBase needs restart (PostgreSQL→SQLite migration)')
}
throw new Error(`HTTP ${resp.status}: ${errMsg}`)
}
const cfg = await resp.json()
uploadPath.value = cfg.server?.upload_path || ''