Compare commits

..
3 Commits
Author SHA1 Message Date
hz4th_coder 5e3e9e7335 fix: 修复处理流程和后台任务问题
- 步骤简要数值显示在每个步骤圆圈下方
- 处理流程抓取网页后保存到内容库
- 修复后台任务结果解析错误
2026-07-14 15:13:31 +08:00
hz4th_coder 1712fb0756 feat: 处理监控页面显示步骤简要数值
- 显示内容库搜索结果数
- 显示互联网搜索结果数
- 显示抓取成功数
- 显示数据提取/填充状态
- 显示审核ID
2026-07-14 12:42:59 +08:00
hz4th_coder d18e80016b fix: 修复首页产品处理启动问题
- 首页点击处理现在使用新的处理监控流程
- 处理启动后自动跳转到处理监控页面
- 首页添加'处理监控'入口按钮
- 修复错误消息显示 undefined 的问题
2026-07-14 12:33:40 +08:00
6 changed files with 99 additions and 13 deletions
+23 -2
View File
@@ -110,11 +110,32 @@ class ProcessMonitor:
fetch_result = search_service.fetch_url_content(url)
if fetch_result.get('success'):
title = fetch_result.get('title', '')
content = fetch_result.get('content', '')
fetched.append({
'url': url,
'title': fetch_result.get('title', ''),
'content': fetch_result.get('content', '')[:500]
'title': title,
'content': content[:500]
})
# 保存到内容库
try:
existing = db.search_articles(url)
if not any(a.get('url') == url for a in existing):
db.add_article(
product_names=[],
category=category or '',
keywords=[],
summary=content[:200] if content else '',
content=content,
source=url,
url=url,
search_title=title
)
logger.info(f"[{session_id}] 已保存到内容库: {title[:30]}")
except Exception as save_error:
logger.warning(f"[{session_id}] 保存内容库失败: {save_error}")
time.sleep(0.3)
all_data['fetched_contents'] = fetched
+25
View File
@@ -175,6 +175,31 @@
max-width: 80px;
}
.step-value {
font-size: 12px;
font-weight: 600;
color: #10b981;
margin-top: 3px;
padding: 2px 6px;
background: #d1fae5;
border-radius: 3px;
}
.step-node.running .step-value {
color: #667eea;
background: #e0e7ff;
}
.step-node.failed .step-value {
color: #ef4444;
background: #fee2e2;
}
.step-node.skipped .step-value {
color: #6b7280;
background: #f3f4f6;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.1); }
+13 -8
View File
@@ -396,30 +396,35 @@ async function processProduct(productName, category, subcategory) {
return;
}
showToast('正在启动处理...', '');
try {
const response = await fetch(`${API_BASE}/api/products/process`, {
const response = await fetch(`${API_BASE}/api/process/start`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
product_name: productName,
category: category,
subcategory: subcategory
category: category || '',
subcategory: subcategory || ''
})
});
const data = await response.json();
if (data.success) {
showToast(data.message, 'success');
if (data.new_products && data.new_products.length > 0) {
showToast(`发现 ${data.new_products.length} 个新产品`, 'success');
}
showToast('处理流程已启动', 'success');
// 跳转到处理监控页面
setTimeout(() => {
window.location.href = '/process';
}, 1000);
} else {
showToast('处理失败: ' + data.error || data.message, 'error');
const errorMsg = data.error || data.message || '未知错误';
showToast('处理失败: ' + errorMsg, 'error');
}
refreshData();
} catch (error) {
console.error('处理产品失败:', error);
showToast('处理产品失败', 'error');
}
}
+29 -2
View File
@@ -133,17 +133,42 @@ function displayActiveProcesses(sessions) {
function renderStepsProgress(steps, currentStep) {
const totalSteps = 6;
const stepStatuses = {};
const stepDataMap = {};
// 构建步骤状态映射
// 构建步骤状态和数据映射
steps.forEach(s => {
stepStatuses[s.step_number] = s.step_status;
if (s.step_data) {
try {
stepDataMap[s.step_number] = typeof s.step_data === 'string' ? JSON.parse(s.step_data) : s.step_data;
} catch (e) {
stepDataMap[s.step_number] = s.step_data;
}
}
});
const stepNames = ['搜索内容库', '搜索互联网', '抓取网页', '提取数据', '填充字段', '提交审核'];
let html = '';
// 获取每个步骤的简要数值
function getStepValue(stepNum) {
const data = stepDataMap[stepNum];
if (!data) return '';
switch (stepNum) {
case 1: return data.count !== undefined ? `${data.count}` : '';
case 2: return data.count !== undefined ? `${data.count}` : '';
case 3: return data.count !== undefined ? `${data.count}` : '';
case 4: return data.has_data !== undefined ? (data.has_data ? '✓' : '✗') : (data.extracted ? '✓' : '');
case 5: return data.filled !== undefined ? (data.filled ? '✓' : '✗') : '';
case 6: return data.review_id ? '✓' : '';
default: return '';
}
}
let html = '<div class="steps-progress">';
for (let i = 1; i <= totalSteps; i++) {
const status = stepStatuses[i] || (i > currentStep ? 'pending' : '');
const stepValue = getStepValue(i);
let className = '';
if (status === 'completed') className = 'completed';
@@ -155,9 +180,11 @@ function renderStepsProgress(steps, currentStep) {
<div class="step-node ${className}">
<div class="step-circle">${i}</div>
<div class="step-label">${stepNames[i-1]}</div>
${stepValue ? `<div class="step-value">${stepValue}</div>` : ''}
</div>
`;
}
html += '</div>';
return html;
}
+6 -1
View File
@@ -773,7 +773,12 @@ async function loadBackgroundTasks() {
const progressPercent = task.total > 0 ?
Math.round((task.progress / task.total) * 100) : 0;
const result = task.result ? JSON.parse(task.result) : {};
let result = {};
try {
result = task.result ? JSON.parse(task.result) : {};
} catch (e) {
result = {};
}
return `
<div class="background-task-item ${statusClass}">
+3
View File
@@ -13,6 +13,9 @@
<header class="header">
<h1><i class="ri-robot-line"></i> 参数数据自动化管理系统</h1>
<div class="header-actions">
<a href="/process" class="btn btn-primary">
<i class="ri-cpu-line"></i> 处理监控
</a>
<button onclick="refreshData()" class="btn btn-secondary">
<i class="ri-refresh-line"></i> 刷新数据
</button>