fix: normalize Khanegi UI config on save for userTheme schema
Prevent re-saving invalid navigation.type/header.variant/products routes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import api from '@/api/http'
|
||||
import {
|
||||
cloneKhanegiAppSnapshot,
|
||||
createDefaultKhanegiUiConfig,
|
||||
normalizeKhanegiUiConfigForClient,
|
||||
} from '@/config/defaultKhanegiUiConfig'
|
||||
import {
|
||||
applyKhanegiPreset,
|
||||
@@ -201,10 +202,15 @@ function buildSavePayload() {
|
||||
if (selectedPreset.value === 'custom') {
|
||||
markCustomAndSyncSchemes(config)
|
||||
}
|
||||
const payload = JSON.parse(JSON.stringify(config)) as typeof config
|
||||
const payload = normalizeKhanegiUiConfigForClient(
|
||||
JSON.parse(JSON.stringify(config)) as typeof config,
|
||||
)
|
||||
// Never drop or rewrite an existing factory snapshot on normal save
|
||||
if (config.defaultSnapshot) {
|
||||
payload.defaultSnapshot = JSON.parse(JSON.stringify(config.defaultSnapshot))
|
||||
payload.defaultSnapshot = normalizeKhanegiUiConfigForClient({
|
||||
app: JSON.parse(JSON.stringify(config.defaultSnapshot.app)),
|
||||
pages: JSON.parse(JSON.stringify(config.defaultSnapshot.pages || {})),
|
||||
}) as typeof payload.defaultSnapshot
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user