修复包装分类匹配
This commit is contained in:
parent
36527d033f
commit
926c12c787
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue