feat(admin-jd): 商品目录左栏改读服务端按店铺授权树(无上报时回落内置快照)
承接后端 85425771:左栏树不再只有硬编码快照这一档。 - jd-shop-category-api.ts:GET /api/jd-shop-category-tree 取并集森林(复用 jd-category-tree.ts 的 parseJdCategoryNodeTree 做脏值/超深/超量护栏,与客户端上报侧同口径) - JdDatabasePage:onMounted 增一路 loadShopCategoryTree(失败静默回落快照,不占首屏 失败提示);activeCategoryTree=服务端真树优先、否则内置快照,并作为父级点选展开 集合的唯一口径源(filter.categoryNames 在选中那一刻按同一棵树算好) - JdCategorySidebar:prop categoryTree 可注入,计数树按它算;tier1 的 treeForeign 消歧档照旧(整树零命中且树外有行时才收树点名) - jd-product-filter:state.categoryNames 优先于按快照展开的 jdCategoryNamesUnder 判据:jd-category-tree.test.ts +2(parse 形状/脏值/超深;自定义树计数对照内置快照)、 mount +1(服务端树渲染「收纳用品 260」且不出现服饰内衣/无 treeForeign、不重复出树外组); source-pin 基线 jd-category-tree.test.ts 15→17。admin 三连绿:node --test 1979、 vitest 251、vue-tsc rc=0。
This commit is contained in:
@@ -10,8 +10,10 @@
|
||||
* (点兜底行=单名等值旧形状,path 空数组交给页面回落)。 */
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import {
|
||||
JD_CATEGORY_TREE,
|
||||
jdCategoryCountTree,
|
||||
type JdCategoryCountedNode,
|
||||
type JdCategoryNode,
|
||||
} from './jd-category-tree.ts'
|
||||
import type { JdProductCategoryOption, JdProductGroup } from './jd-product-api.ts'
|
||||
|
||||
@@ -31,6 +33,10 @@ const props = defineProps<{
|
||||
selectedGroupId?: number | null
|
||||
/** 当前店铺筛选(v1.7 店铺名单点选;空/缺省=未按店铺过滤)。 */
|
||||
selectedShopName?: string | null
|
||||
/** 授权类目树(2026-11-23):页面从服务端取「已上报店铺并集」的真树传入;
|
||||
* 缺省/空数组=回落内置快照(`JD_CATEGORY_TREE`,一家店的历史取证,
|
||||
* 另由 treeForeign 判据收树点名,不冒充本店类目)。 */
|
||||
categoryTree?: JdCategoryNode[] | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -64,7 +70,11 @@ const activeTab = ref<'catalog' | 'custom'>('catalog')
|
||||
|
||||
// ---------------- 计数聚合(Phase 1 纯函数) ----------------
|
||||
|
||||
const counted = computed(() => jdCategoryCountTree(props.categoryOptions ?? []))
|
||||
/** 生效的授权类目树:服务端真树优先,没有则回落到内置快照(一家店的历史取证)。 */
|
||||
const activeTree = computed<JdCategoryNode[]>(() =>
|
||||
(props.categoryTree && props.categoryTree.length ? props.categoryTree : JD_CATEGORY_TREE))
|
||||
|
||||
const counted = computed(() => jdCategoryCountTree(props.categoryOptions ?? [], activeTree.value))
|
||||
|
||||
/** 内置授权树与本店类目体系不同源:整棵树零命中、且兜底组确有行。内置 `JD_CATEGORY_TREE`
|
||||
* 是 2026-11-16 从**一家店铺**(花屿巷旗舰店)京麦授权接口抓的固定快照,换一家店(如家居
|
||||
|
||||
Reference in New Issue
Block a user