|
|
@ -14,6 +14,7 @@ |
|
|
|
--success-color: #10b981; |
|
|
|
--error-color: #ef4444; |
|
|
|
--warning-color: #f59e0b; |
|
|
|
--info-color: #3b82f6; |
|
|
|
} |
|
|
|
|
|
|
|
* { |
|
|
@ -191,6 +192,29 @@ |
|
|
|
line-height: 1.6; |
|
|
|
} |
|
|
|
|
|
|
|
/* 进度日志样式 */ |
|
|
|
.progress-log { |
|
|
|
background-color: #1e1e1e; |
|
|
|
color: #d4d4d4; |
|
|
|
border-radius: 6px; |
|
|
|
padding: 16px; |
|
|
|
font-family: 'Courier New', monospace; |
|
|
|
font-size: 14px; |
|
|
|
margin: 16px 0; |
|
|
|
max-height: 300px; |
|
|
|
overflow-y: auto; |
|
|
|
display: none; |
|
|
|
} |
|
|
|
|
|
|
|
.progress-log.visible { |
|
|
|
display: block; |
|
|
|
} |
|
|
|
|
|
|
|
.progress-log-entry { |
|
|
|
margin: 4px 0; |
|
|
|
line-height: 1.4; |
|
|
|
} |
|
|
|
|
|
|
|
footer { |
|
|
|
text-align: center; |
|
|
|
margin-top: 30px; |
|
|
@ -266,6 +290,10 @@ |
|
|
|
</div> |
|
|
|
<button id="queryBtn">执行查询</button> |
|
|
|
<div id="queryStatus" class="status"></div> |
|
|
|
|
|
|
|
<!-- 进度日志显示区域 --> |
|
|
|
<div id="progressLog" class="progress-log"></div> |
|
|
|
|
|
|
|
<div id="queryResult" class="result-container"> |
|
|
|
<h3>查询结果:</h3> |
|
|
|
<div class="query-result" id="resultText"></div> |
|
|
@ -319,6 +347,37 @@ |
|
|
|
resultElement.classList.remove('visible'); |
|
|
|
} |
|
|
|
|
|
|
|
// 工具函数:显示进度日志 |
|
|
|
function showProgressLog(messages) { |
|
|
|
const logElement = document.getElementById('progressLog'); |
|
|
|
if (messages && messages.length > 0) { |
|
|
|
logElement.innerHTML = messages.map(msg => |
|
|
|
`<div class="progress-log-entry">${escapeHtml(msg)}</div>` |
|
|
|
).join(''); |
|
|
|
logElement.classList.add('visible'); |
|
|
|
} else { |
|
|
|
logElement.classList.remove('visible'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 工具函数:隐藏进度日志 |
|
|
|
function hideProgressLog() { |
|
|
|
const logElement = document.getElementById('progressLog'); |
|
|
|
logElement.classList.remove('visible'); |
|
|
|
} |
|
|
|
|
|
|
|
// 工具函数:转义HTML特殊字符 |
|
|
|
function escapeHtml(text) { |
|
|
|
const map = { |
|
|
|
'&': '&', |
|
|
|
'<': '<', |
|
|
|
'>': '>', |
|
|
|
'"': '"', |
|
|
|
"'": ''' |
|
|
|
}; |
|
|
|
return text.replace(/[&<>"']/g, function(m) { return map[m]; }); |
|
|
|
} |
|
|
|
|
|
|
|
// 工具函数:设置按钮加载状态 |
|
|
|
function setButtonLoading(button, loading) { |
|
|
|
if (loading) { |
|
|
@ -347,6 +406,7 @@ |
|
|
|
setButtonLoading(button, true); |
|
|
|
showStatus('loadStatus', '正在加载文件...', 'loading'); |
|
|
|
hideResult(); |
|
|
|
hideProgressLog(); |
|
|
|
|
|
|
|
try { |
|
|
|
const response = await fetch('/load-files/', { |
|
|
@ -392,6 +452,7 @@ |
|
|
|
setButtonLoading(button, true); |
|
|
|
showStatus('webLoadStatus', '正在加载网站内容...', 'loading'); |
|
|
|
hideResult(); |
|
|
|
hideProgressLog(); |
|
|
|
|
|
|
|
try { |
|
|
|
const response = await fetch('/load-website/', { |
|
|
@ -439,6 +500,7 @@ |
|
|
|
setButtonLoading(button, true); |
|
|
|
showStatus('queryStatus', '正在处理查询...', 'loading'); |
|
|
|
hideResult(); |
|
|
|
hideProgressLog(); |
|
|
|
|
|
|
|
try { |
|
|
|
const response = await fetch(`/query/?original_query=${encodeURIComponent(queryText)}&max_iter=${maxIter}`, { |
|
|
@ -455,6 +517,9 @@ |
|
|
|
document.getElementById('resultText').textContent = data.result; |
|
|
|
document.getElementById('tokenInfo').textContent = `消耗Token数: ${data.consume_token}`; |
|
|
|
showResult(); |
|
|
|
|
|
|
|
// 显示进度日志 |
|
|
|
showProgressLog(data.progress_messages); |
|
|
|
} else { |
|
|
|
showStatus('queryStatus', `查询失败: ${data.detail}`, 'error'); |
|
|
|
} |
|
|
|