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;
}
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');
}
}
+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>