// 在 index.html 的 script 部分更新调试功能
// 测试连接函数 - 改进版本
async function testConnection() {
updateDebugInfo('开始测试连接...');
try {
const response = await fetch('/test-env');
// 检查响应类型
const contentType = response.headers.get('content-type');
updateDebugInfo(`响应类型: ${contentType}`);
updateDebugInfo(`状态码: ${response.status}`);
const responseText = await response.text();
updateDebugInfo(`响应文本: ${responseText.substring(0, 200)}...`);
// 尝试解析为 JSON
try {
const result = JSON.parse(responseText);
updateDebugInfo(`解析成功: ${JSON.stringify(result)}`);
} catch (e) {
updateDebugInfo(`JSON解析失败: ${e.message}`);
// 如果不是 JSON,可能是 HTML 错误页面
if (responseText.includes('