fix: 修复 AI 测试链接返回连接失败的问题

- 修复 AJAX 函数中缺少 api_id 参数检查导致的错误
- 统一错误消息格式,使用数组包装错误信息
- 修复 JavaScript 中错误消息解析逻辑
- 改进错误提示的可读性和调试信息
This commit is contained in:
2026-01-26 14:31:47 +08:00
parent 3794f37618
commit 540fe7b543
2 changed files with 16 additions and 10 deletions

View File

@@ -2455,8 +2455,8 @@ function themeoptions_page(){
if (response.success) {
alert('✓ ' + response.data.message);
} else {
// wp_send_json_error 的错误消息在 response.data 中
let errorMsg = response.data || '<?php _e('未知错误', 'argon'); ?>';
// wp_send_json_error 的错误消息在 response.data.message
let errorMsg = (response.data && response.data.message) ? response.data.message : '<?php _e('未知错误', 'argon'); ?>';
alert('✗ <?php _e('测试失败:', 'argon'); ?> ' + errorMsg);
}
$btn.prop('disabled', false).html(originalHtml);
@@ -2464,7 +2464,7 @@ function themeoptions_page(){
// AJAX 请求本身失败
console.error('AJAX Error:', xhr, status, error);
console.error('Response Text:', xhr.responseText);
alert('<?php _e('请求失败,请重试', 'argon'); ?>');
alert('<?php _e('请求失败:', 'argon'); ?> ' + (xhr.responseText || error || '<?php _e('网络错误', 'argon'); ?>'));
$btn.prop('disabled', false).html(originalHtml);
});
});