fix: 修复小米 Mimo API 端点问题并添加调试日志

- 移除无效的默认端点 api.mimo.xiaomi.com(DNS 无法解析)
- 小米 Mimo 现在要求用户在 API 端点字段中填写平台提供的自定义端点
- 添加针对小米 Mimo 的友好错误提示,引导用户访问 platform.xiaomimimo.com
- 在 JavaScript 中添加 console.log 调试输出,便于排查问题
- 改进错误处理,显示完整的 xhr 响应信息
This commit is contained in:
2026-01-26 14:20:10 +08:00
parent 4b0c5c159a
commit 8ba2cae1a1
2 changed files with 9 additions and 3 deletions

View File

@@ -8804,7 +8804,7 @@ function argon_ajax_test_unified_api() {
'openai' => 'https://api.openai.com/v1/chat/completions', 'openai' => 'https://api.openai.com/v1/chat/completions',
'anthropic' => 'https://api.anthropic.com/v1/messages', 'anthropic' => 'https://api.anthropic.com/v1/messages',
'deepseek' => 'https://api.deepseek.com/v1/chat/completions', 'deepseek' => 'https://api.deepseek.com/v1/chat/completions',
'xiaomi' => 'https://api.mimo.xiaomi.com/v1/chat/completions', 'xiaomi' => '', // 小米 Mimo 需要在平台获取自定义端点
'qianwen' => 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions', 'qianwen' => 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions',
'wenxin' => 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions', 'wenxin' => 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions',
'doubao' => 'https://ark.cn-beijing.volces.com/api/v3/chat/completions', 'doubao' => 'https://ark.cn-beijing.volces.com/api/v3/chat/completions',
@@ -8816,7 +8816,11 @@ function argon_ajax_test_unified_api() {
$api_endpoint = !empty($api['api_endpoint']) ? $api['api_endpoint'] : (isset($default_endpoints[$api['provider']]) ? $default_endpoints[$api['provider']] : ''); $api_endpoint = !empty($api['api_endpoint']) ? $api['api_endpoint'] : (isset($default_endpoints[$api['provider']]) ? $default_endpoints[$api['provider']] : '');
if (empty($api_endpoint)) { if (empty($api_endpoint)) {
if ($api['provider'] === 'xiaomi') {
wp_send_json_error('小米 Mimo 需要配置自定义 API 端点。请访问 https://platform.xiaomimimo.com 获取您的专属端点地址');
} else {
wp_send_json_error('未配置 API 端点'); wp_send_json_error('未配置 API 端点');
}
return; return;
} }

View File

@@ -2451,6 +2451,7 @@ function themeoptions_page(){
nonce: '<?php echo wp_create_nonce('argon_test_unified_api'); ?>', nonce: '<?php echo wp_create_nonce('argon_test_unified_api'); ?>',
api_id: apiId api_id: apiId
}, function(response) { }, function(response) {
console.log('Response:', response);
if (response.success) { if (response.success) {
alert('✓ ' + response.data.message); alert('✓ ' + response.data.message);
} else { } else {
@@ -2461,7 +2462,8 @@ function themeoptions_page(){
$btn.prop('disabled', false).html(originalHtml); $btn.prop('disabled', false).html(originalHtml);
}).fail(function(xhr, status, error) { }).fail(function(xhr, status, error) {
// AJAX 请求本身失败 // AJAX 请求本身失败
console.error('AJAX Error:', status, error); console.error('AJAX Error:', xhr, status, error);
console.error('Response Text:', xhr.responseText);
alert('<?php _e('请求失败,请重试', 'argon'); ?>'); alert('<?php _e('请求失败,请重试', 'argon'); ?>');
$btn.prop('disabled', false).html(originalHtml); $btn.prop('disabled', false).html(originalHtml);
}); });