From 926c12c78720c41a10aad32526c0925e8ac63299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Sat, 11 Apr 2026 21:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8C=85=E8=A3=85=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/News.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index 667ae43..0138969 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -502,8 +502,9 @@ export default function News() { const calcAvg = (pkg, cat) => { const items = filteredData.filter(item => { const content = item.content || '' - const p = content.match(/包装:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || item.packaging || '' - const c = content.match(/分类:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || item.category || '' + // 简化正则匹配 + const p = content.includes('包装:') ? content.split('包装:')[1].split('\n')[0].trim() : (item.packaging || '') + const c = content.includes('分类:') ? content.split('分类:')[1].split('\n')[0].trim() : (item.category || '') return p === pkg && c === cat }) if (items.length === 0) return null