mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-26 15:03:34 +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
|
if (!canSubmit) return
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
try {
|
try {
|
||||||
if (isOfficial) {
|
// Write the edited settings.json first (for all presets including official)
|
||||||
await useProviderStore.getState().activateOfficial()
|
|
||||||
await fetchSettings()
|
|
||||||
onClose()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Write the edited settings.json directly
|
|
||||||
if (settingsJson.trim()) {
|
if (settingsJson.trim()) {
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(settingsJson)
|
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') {
|
if (mode === 'create') {
|
||||||
await createProvider({
|
await createProvider({
|
||||||
presetId: selectedPreset.id,
|
presetId: selectedPreset.id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user