Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e3e9e7335 | ||
|
|
1712fb0756 | ||
|
|
d18e80016b |
@@ -110,11 +110,32 @@ class ProcessMonitor:
|
|||||||
|
|
||||||
fetch_result = search_service.fetch_url_content(url)
|
fetch_result = search_service.fetch_url_content(url)
|
||||||
if fetch_result.get('success'):
|
if fetch_result.get('success'):
|
||||||
|
title = fetch_result.get('title', '')
|
||||||
|
content = fetch_result.get('content', '')
|
||||||
fetched.append({
|
fetched.append({
|
||||||
'url': url,
|
'url': url,
|
||||||
'title': fetch_result.get('title', ''),
|
'title': title,
|
||||||
'content': fetch_result.get('content', '')[:500]
|
'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)
|
time.sleep(0.3)
|
||||||
|
|
||||||
all_data['fetched_contents'] = fetched
|
all_data['fetched_contents'] = fetched
|
||||||
|
|||||||
@@ -175,6 +175,31 @@
|
|||||||
max-width: 80px;
|
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 {
|
@keyframes pulse {
|
||||||
0%, 100% { transform: scale(1); }
|
0%, 100% { transform: scale(1); }
|
||||||
50% { transform: scale(1.1); }
|
50% { transform: scale(1.1); }
|
||||||
|
|||||||
+13
-8
@@ -396,30 +396,35 @@ async function processProduct(productName, category, subcategory) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showToast('正在启动处理...', '');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE}/api/products/process`, {
|
const response = await fetch(`${API_BASE}/api/process/start`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
product_name: productName,
|
product_name: productName,
|
||||||
category: category,
|
category: category || '',
|
||||||
subcategory: subcategory
|
subcategory: subcategory || ''
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
showToast(data.message, 'success');
|
showToast('处理流程已启动', 'success');
|
||||||
if (data.new_products && data.new_products.length > 0) {
|
// 跳转到处理监控页面
|
||||||
showToast(`发现 ${data.new_products.length} 个新产品`, 'success');
|
setTimeout(() => {
|
||||||
}
|
window.location.href = '/process';
|
||||||
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
showToast('处理失败: ' + data.error || data.message, 'error');
|
const errorMsg = data.error || data.message || '未知错误';
|
||||||
|
showToast('处理失败: ' + errorMsg, 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshData();
|
refreshData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('处理产品失败:', error);
|
||||||
showToast('处理产品失败', 'error');
|
showToast('处理产品失败', 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-2
@@ -133,17 +133,42 @@ function displayActiveProcesses(sessions) {
|
|||||||
function renderStepsProgress(steps, currentStep) {
|
function renderStepsProgress(steps, currentStep) {
|
||||||
const totalSteps = 6;
|
const totalSteps = 6;
|
||||||
const stepStatuses = {};
|
const stepStatuses = {};
|
||||||
|
const stepDataMap = {};
|
||||||
|
|
||||||
// 构建步骤状态映射
|
// 构建步骤状态和数据映射
|
||||||
steps.forEach(s => {
|
steps.forEach(s => {
|
||||||
stepStatuses[s.step_number] = s.step_status;
|
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 = ['搜索内容库', '搜索互联网', '抓取网页', '提取数据', '填充字段', '提交审核'];
|
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++) {
|
for (let i = 1; i <= totalSteps; i++) {
|
||||||
const status = stepStatuses[i] || (i > currentStep ? 'pending' : '');
|
const status = stepStatuses[i] || (i > currentStep ? 'pending' : '');
|
||||||
|
const stepValue = getStepValue(i);
|
||||||
let className = '';
|
let className = '';
|
||||||
|
|
||||||
if (status === 'completed') className = 'completed';
|
if (status === 'completed') className = 'completed';
|
||||||
@@ -155,9 +180,11 @@ function renderStepsProgress(steps, currentStep) {
|
|||||||
<div class="step-node ${className}">
|
<div class="step-node ${className}">
|
||||||
<div class="step-circle">${i}</div>
|
<div class="step-circle">${i}</div>
|
||||||
<div class="step-label">${stepNames[i-1]}</div>
|
<div class="step-label">${stepNames[i-1]}</div>
|
||||||
|
${stepValue ? `<div class="step-value">${stepValue}</div>` : ''}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -773,7 +773,12 @@ async function loadBackgroundTasks() {
|
|||||||
const progressPercent = task.total > 0 ?
|
const progressPercent = task.total > 0 ?
|
||||||
Math.round((task.progress / task.total) * 100) : 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 `
|
return `
|
||||||
<div class="background-task-item ${statusClass}">
|
<div class="background-task-item ${statusClass}">
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
<header class="header">
|
<header class="header">
|
||||||
<h1><i class="ri-robot-line"></i> 参数数据自动化管理系统</h1>
|
<h1><i class="ri-robot-line"></i> 参数数据自动化管理系统</h1>
|
||||||
<div class="header-actions">
|
<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">
|
<button onclick="refreshData()" class="btn btn-secondary">
|
||||||
<i class="ri-refresh-line"></i> 刷新数据
|
<i class="ri-refresh-line"></i> 刷新数据
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user