feat: 优化日志组件并简化后端日志处理

为日志组件添加折叠功能并显示空状态提示
移除参数表单中冗余的后端日志调试信息
This commit is contained in:
dmy
2026-03-02 21:13:26 +08:00
parent 89e4cd4973
commit 9a5e8e0076
2 changed files with 13 additions and 14 deletions

View File

@@ -384,23 +384,14 @@ const calculate = async () => {
try {
// 调用 pywebview 的 Python 函数
if (window.pywebview) {
logRef.value?.addLog('info', '开始调用后端计算...')
const response = await window.pywebview.api.calculate(params)
logRef.value?.addLog('info', `后端返回 keys: ${Object.keys(response).join(', ')}`)
logRef.value?.addLog('info', `DEBUG_VERSION: ${response.DEBUG_VERSION || '无'}`)
logRef.value?.addLog('info', `后端返回: ${JSON.stringify(response).substring(0, 150)}`)
// 显示日志
console.log('[DEBUG] response:', response)
// 显示后端日志
const logs = response.logs
if (Array.isArray(logs) && logs.length > 0) {
logRef.value?.addLog('info', `收到 ${logs.length} 条日志`)
for (const log of logs) {
logRef.value?.addLog(log.level as any, log.message)
}
} else {
logRef.value?.addLog('warning', '后端未返回日志')
logRef.value?.addLog('warning', `response.logs = ${JSON.stringify(logs)}`)
}
result.value = JSON.stringify(response, null, 2)