mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-17 13:13:35 +08:00
fix: official preset add button — write settings.json first, handle errors
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d3d3e0ce2a
commit
1b190524e5
@ -255,13 +255,7 @@ function ProviderFormModal({ open, onClose, mode, provider }: ProviderFormProps)
|
||||
if (!canSubmit) return
|
||||
setIsSubmitting(true)
|
||||
try {
|
||||
if (isOfficial) {
|
||||
await useProviderStore.getState().activateOfficial()
|
||||
await fetchSettings()
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
// Write the edited settings.json directly
|
||||
// Write the edited settings.json first (for all presets including official)
|
||||
if (settingsJson.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(settingsJson)
|
||||
@ -272,6 +266,17 @@ function ProviderFormModal({ open, onClose, mode, provider }: ProviderFormProps)
|
||||
}
|
||||
}
|
||||
|
||||
if (isOfficial) {
|
||||
try {
|
||||
await useProviderStore.getState().activateOfficial()
|
||||
await fetchSettings()
|
||||
} catch (err) {
|
||||
console.error('Failed to activate official:', err)
|
||||
}
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
|
||||
if (mode === 'create') {
|
||||
await createProvider({
|
||||
presetId: selectedPreset.id,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user