feat(jd): 整合自定义分类并保护商品数据

This commit is contained in:
2026-11-16 16:12:04 +08:00
parent 79eb7a7f16
commit 8c81546aa7
23 changed files with 708 additions and 1643 deletions
@@ -24,8 +24,8 @@ import {
toJdProductListParams,
} from '../src/pages/jd/jd-product-filter.ts'
import {
jdCategoryNavChildren,
jdCategoryNavRoots,
jdCategoryChildren,
jdCategoryRoots,
} from '../src/pages/jd/jd-category-tree.ts'
import {
jdPriceRange,
@@ -36,15 +36,14 @@ import {
test('类目级联静态导航树——服饰内衣二级与京麦面板样本逐字同源,一级集非空且无重名', () => {
// 京麦面板真机样本(2026-11-16 客户截图):服饰内衣下就是这五个二级,改名即红。
assert.deepEqual(jdCategoryNavChildren('服饰内衣'), ['服饰配件', '内衣', '女装', '男装', '定制服装/工装'])
assert.deepEqual(jdCategoryNavChildren('不存在的类目'), [], '未知一级回落空子级(面板不出第二栏)')
assert.deepEqual(jdCategoryChildren(['服饰内衣']).map(node => node.name), ['服饰配件', '内衣', '女装', '男装', '定制服装/工装'])
assert.deepEqual(jdCategoryChildren(['不存在的类目']), [], '未知一级回落空子级(面板不出第二栏)')
const roots = jdCategoryNavRoots()
assert.ok(roots.length >= 20, `一级导航 ${roots.length} 个,常用集不应被清空`)
const roots = jdCategoryRoots().map(node => node.name)
assert.deepEqual(roots, ['服饰内衣', '母婴', '运动户外'], '一级导航与京麦授权类目一致')
assert.equal(new Set(roots).size, roots.length, '一级类目名不得重复')
assert.equal(roots[0], '服饰内衣', '服饰内衣置首(客户商品全在服饰类目)')
for (const root of roots) {
const children = jdCategoryNavChildren(root)
const children = jdCategoryChildren([root]).map(node => node.name)
assert.equal(new Set(children).size, children.length, `${root} 的二级不得重复`)
}
})