fix(ai): treat unchanged AI settings as successful save
update_option returns false when values are identical, which made POST /ai/settings respond 400 with "保存失败" on no-op saves and masked-key re-saves. Normalize config, accept no-op as success, and only send a new API key from the admin form when entered.
This commit is contained in:
@@ -216,9 +216,17 @@ export default {
|
||||
async function saveSettings() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = { ...form };
|
||||
if (!payload.api_key && status.value.configured) {
|
||||
payload.api_key = '***';
|
||||
const payload = {
|
||||
enabled: form.enabled,
|
||||
provider: form.provider,
|
||||
api_base: form.api_base,
|
||||
model: form.model,
|
||||
max_tokens: form.max_tokens,
|
||||
rate_limit: form.rate_limit,
|
||||
};
|
||||
// Only send api_key when the user entered a new one.
|
||||
if (form.api_key && form.api_key !== '***') {
|
||||
payload.api_key = form.api_key;
|
||||
}
|
||||
const json = await api.updateAiSettings(payload);
|
||||
alert(json.message || '设置已保存');
|
||||
|
||||
Reference in New Issue
Block a user