fix: 修复首页产品处理启动问题

- 首页点击处理现在使用新的处理监控流程
- 处理启动后自动跳转到处理监控页面
- 首页添加'处理监控'入口按钮
- 修复错误消息显示 undefined 的问题
This commit is contained in:
2026-07-14 12:33:40 +08:00
parent 8f0efe28b6
commit d18e80016b
2 changed files with 16 additions and 8 deletions
+13 -8
View File
@@ -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');
} }
} }
+3
View File
@@ -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>