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:
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user