fix: allow saving admin config when config file doesn't exist

- saveConfig no longer throws error when current config returns 404
- Creates new config file with current values if none exists
- User can save config for the first time without errors
This commit is contained in:
2026-10-27 02:40:45 +08:00
parent 776cf197c8
commit 1f885406dd

View File

@@ -1327,9 +1327,13 @@ async function saveConfig() {
configSaving.value = true
configSaveMsg.value = ''
try {
// Try to load current config, but don't fail if it doesn't exist
let currentConfig: any = {}
const res = await fetch('/api/v1/admin/config')
if (!res.ok) throw new Error(`Failed to load current config: HTTP ${res.status}`)
const currentConfig = await res.json()
if (res.ok) {
currentConfig = await res.json()
}
// If 404, just use empty currentConfig - we'll create a new file
const payload = {
version: '1.0.0',