fix: improve input validation and error handling in ModelSetting and SettingGeminiModel components

This commit is contained in:
CaIon
2025-05-24 15:26:55 +08:00
parent d95c2436d7
commit fbdad581b5
2 changed files with 47 additions and 28 deletions

View File

@@ -39,7 +39,9 @@ const ModelSetting = () => {
item.key === 'claude.default_max_tokens' ||
item.key === 'gemini.supported_imagine_models'
) {
item.value = JSON.stringify(JSON.parse(item.value), null, 2);
if (item.value !== '') {
item.value = JSON.stringify(JSON.parse(item.value), null, 2);
}
}
if (item.key.endsWith('Enabled') || item.key.endsWith('enabled')) {
newInputs[item.key] = item.value === 'true' ? true : false;
@@ -60,6 +62,7 @@ const ModelSetting = () => {
// showSuccess('刷新成功');
} catch (error) {
showError('刷新失败');
console.error(error);
} finally {
setLoading(false);
}