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:
2026-07-13 08:08:42 +08:00
parent 9c19bc250d
commit 7ced67b2d3
3 changed files with 65 additions and 5 deletions
@@ -130,7 +130,10 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
$success = AKSRT_AI::get_instance()->update_config($config);
if ($success) {
return $this->success(['message' => __('AI 设置已保存', 'aksrt')]);
return $this->success([
'message' => __('AI 设置已保存', 'aksrt'),
'data' => AKSRT_AI::get_instance()->get_status(),
]);
}
return $this->error(__('保存失败', 'aksrt'));
}