Enhance ProxyManager and ProxyValidator to display detailed response information, including status codes, response data, and headers. Implement response data truncation for better readability. Update validation logic to capture and return response details in case of errors.
This commit is contained in:
@@ -333,6 +333,42 @@ class ProxyManager {
|
||||
document.getElementById('validationStatus').textContent = '验证完成';
|
||||
|
||||
// 显示结果
|
||||
let responseResultHtml = '';
|
||||
|
||||
if (result.data.responseStatus !== null && result.data.responseStatus !== undefined) {
|
||||
responseResultHtml = `
|
||||
<hr>
|
||||
<h6>响应结果:</h6>
|
||||
<p><strong>状态码:</strong> <span class="badge ${result.data.responseStatus >= 200 && result.data.responseStatus < 300 ? 'bg-success' : 'bg-warning'}">${result.data.responseStatus}</span></p>
|
||||
`;
|
||||
|
||||
if (result.data.responseData) {
|
||||
// 限制显示长度,避免内容过长
|
||||
let displayData = result.data.responseData;
|
||||
const maxLength = 300;
|
||||
if (displayData.length > maxLength) {
|
||||
displayData = displayData.substring(0, maxLength) + '... (内容已截断,完整内容请查看日志)';
|
||||
}
|
||||
|
||||
responseResultHtml += `
|
||||
<p><strong>响应内容:</strong></p>
|
||||
<pre class="bg-light p-2 border rounded" style="max-height: 200px; overflow-y: auto; font-size: 12px; white-space: pre-wrap; word-wrap: break-word;">${this.escapeHtml(displayData)}</pre>
|
||||
`;
|
||||
}
|
||||
|
||||
if (result.data.testUrl) {
|
||||
responseResultHtml += `
|
||||
<p class="text-muted small"><strong>测试URL:</strong> ${result.data.testUrl}</p>
|
||||
`;
|
||||
}
|
||||
} else if (result.data.error) {
|
||||
responseResultHtml = `
|
||||
<hr>
|
||||
<h6>响应结果:</h6>
|
||||
<p class="text-danger"><strong>错误:</strong> ${result.data.error}</p>
|
||||
`;
|
||||
}
|
||||
|
||||
document.getElementById('validationResults').innerHTML = `
|
||||
<div class="alert ${result.data.isValid ? 'alert-success' : 'alert-danger'}">
|
||||
<h6>验证结果: ${result.data.isValid ? '成功' : '失败'}</h6>
|
||||
@@ -340,6 +376,7 @@ class ProxyManager {
|
||||
<p><strong>响应时间:</strong> ${result.data.responseTime}ms</p>
|
||||
${result.data.error ? `<p><strong>错误信息:</strong> ${result.data.error}</p>` : ''}
|
||||
</div>
|
||||
${responseResultHtml}
|
||||
`;
|
||||
|
||||
// 延迟刷新列表
|
||||
@@ -581,6 +618,13 @@ class ProxyManager {
|
||||
return icons[type] || 'info-circle-fill';
|
||||
}
|
||||
|
||||
escapeHtml(text) {
|
||||
if (!text) return '';
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
convertToCSV(data) {
|
||||
if (!data || data.length === 0) return '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user