From 2a0cc8657219089a6a5ef94c839faf288482291c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Tue, 17 Nov 2026 20:58:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(jd/account):=20=E7=94=A8=E6=88=B7=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=80=89=E4=BA=AC=E4=B8=9C=E6=A1=8C=E9=9D=A2=E7=AB=AF?= =?UTF-8?q?=E5=88=86=E5=8C=BA=E6=95=B4=E7=BB=84=E6=B6=88=E5=A4=B1=E2=80=94?= =?UTF-8?q?=E2=80=94V209=20=E5=89=8D=E5=8F=B0=E4=BA=AC=E4=B8=9C=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=EF=BC=88jd=5Ftools/jd-collect/jd-publish=EF=BC=89?= =?UTF-8?q?=E8=A1=A5=E8=BF=9B=E5=B9=B3=E5=8F=B0=E5=88=A4=E5=AE=9A=EF=BC=88?= =?UTF-8?q?2026-11-17=20=E7=94=A8=E6=88=B7=E6=88=AA=E5=9B=BE=E3=80=8C?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E7=9A=84=E4=BA=AC=E4=B8=9C=E5=B0=91=E4=BA=86?= =?UTF-8?q?=E3=80=8D=EF=BC=89=E3=80=82=E6=96=B0=E5=A2=9E=20JD=5FAPP=5FMENU?= =?UTF-8?q?=5FKEYS=20=E4=B8=8E=20JD=5FMENU=5FKEYS=20=E5=88=86=E5=88=97?= =?UTF-8?q?=EF=BC=9Aapp=20=E8=8F=9C=E5=8D=95=E6=B2=A1=E6=9C=89=20admin=20?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=EF=BC=8C=E4=B8=8D=E5=BE=97=E6=B7=B7=E8=BF=9B?= =?UTF-8?q?=E3=80=8C=E4=B8=8E=20routes.ts=20=E5=AF=B9=E6=92=9E=E3=80=8D?= =?UTF-8?q?=E7=9A=84=E5=90=8E=E5=8F=B0=E6=B8=85=E5=8D=95=EF=BC=9Bplatforms?= =?UTF-8?q?OfMenuKey=20=E4=B8=A4=E4=BB=BD=E5=90=8C=E8=AE=A4=EF=BC=8C?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=AE=97=E6=B3=95=E4=B8=8E=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E6=A0=91/=E4=BE=A7=E8=BE=B9=E6=A0=8F=E4=B8=A4=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E6=96=B9=E9=9B=B6=E6=94=B9=E5=8A=A8=E3=80=82=E5=88=A4?= =?UTF-8?q?=E6=8D=AE=EF=BC=9Auser-menu-tree-platform-filter=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=A1=8C=E9=9D=A2=E7=AB=AF=E5=88=86=E5=8C=BA=E6=AD=A3?= =?UTF-8?q?=E5=8F=8D=E4=B8=A4=E4=BE=8B=EF=BC=88jd=20=E7=95=99=E4=BA=AC?= =?UTF-8?q?=E4=B8=9C=E5=B7=A5=E5=85=B7=E5=8F=B0=E6=95=B4=E7=BB=84/amazon?= =?UTF-8?q?=20=E7=95=99=E4=BA=9A=E9=A9=AC=E9=80=8A=20app=EF=BC=89=EF=BC=8B?= =?UTF-8?q?=E4=B8=89=20key=20=E5=88=A4=E5=AE=9A=E9=92=89=EF=BC=9Bplatform-?= =?UTF-8?q?menu-filter=20=E6=B8=85=E5=8D=95=E9=92=89=E6=AD=BB=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=90=8C=E6=AD=A5=20JD=5FAPP=5FMENU=5FKEYS=20?= =?UTF-8?q?=E5=BD=A2=E7=8A=B6=E3=80=82node=20--test=2029=20=E4=BE=8B?= =?UTF-8?q?=E5=85=A8=E7=BB=BF=EF=BC=8Bvue-tsc=20rc=3D0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/config/platform-scope.ts | 21 ++++++++++++--- .../src/pages/account/UserMenuAuthTree.vue | 2 +- .../tests/platform-menu-filter.test.ts | 6 ++++- .../user-menu-tree-platform-filter.test.ts | 26 ++++++++++++++++++- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/admin-frontend-vue/src/config/platform-scope.ts b/admin-frontend-vue/src/config/platform-scope.ts index 232d7e867..b8963d06f 100644 --- a/admin-frontend-vue/src/config/platform-scope.ts +++ b/admin-frontend-vue/src/config/platform-scope.ts @@ -19,11 +19,24 @@ export const PLATFORM_TABS: readonly PlatformTabDef[] = [ * 2026-11-17 晚:分类管理子菜单(admin_jd_category_manage,V204)随「京东分类管理并到 * 京东数据库分类编辑里」用户口径整体下线(页/路由/菜单行 V208 删),key 从清单摘除。 * 后续京东新页面上线把 key 加进这里即可,清单外的 key(含店铺管理/生成记录等 - * 存量页)一律归亚马逊或双侧清单。 */ + * 存量页)一律归亚马逊或双侧清单。 + * ⚠ 本清单只收后台(admin)侧 key——护栏用例要求每条都在 routes.ts 登记 menuKey; + * 桌面端(app)京东菜单走 {@link JD_APP_MENU_KEYS}(无 admin 路由,不进侧边栏)。 */ export const JD_MENU_KEYS: readonly string[] = [ 'admin_jd_database', ] +/** 桌面端(app)京东菜单的 column_key 清单(V209,2026-11-17 用户口径「前台的京东少了」): + * 组行 jd_tools(京东工具台)+两工具子行 jd-collect(京东店铺数据采集)/jd-publish(京东商品上架), + * 与用户端 permissionKeys 逐字一致。app 菜单不进后管侧边栏与 routes.ts 路由表,故与 + * {@link JD_MENU_KEYS} 分列——判定出口 {@link platformsOfMenuKey} 两份同认。 + * 后续用户端京东新工具上线把 column_key 加进这里即可。 */ +export const JD_APP_MENU_KEYS: readonly string[] = [ + 'jd_tools', + 'jd-collect', + 'jd-publish', +] + /** 双侧共用菜单(2026-11-17 用户口径「这些亚马逊这边也要有」):三个账号域页面在两个 * 平台 tab 下都显示——同一套组件、按当前 tab 给接口传 platform,各自只看/管各自平台的 * 账号、分组、公司(后端 V206 三表加列,存量默认亚马逊,京东侧数据在编辑弹窗里翻档)。 */ @@ -33,10 +46,10 @@ export const BOTH_PLATFORM_MENU_KEYS: readonly string[] = [ 'admin_companies', ] -/** menuKey → 平台归属清单(唯一判定出口):京东独占 → ['jd'];双侧清单 → ['amazon','jd']; - * 其余(未知 key 在内)默认亚马逊。 */ +/** menuKey → 平台归属清单(唯一判定出口):京东独占(后台或桌面端清单)→ ['jd']; + * 双侧清单 → ['amazon','jd'];其余(未知 key 在内)默认亚马逊。 */ export function platformsOfMenuKey(key: string): PlatformTabId[] { - if (JD_MENU_KEYS.includes(key)) return ['jd'] + if (JD_MENU_KEYS.includes(key) || JD_APP_MENU_KEYS.includes(key)) return ['jd'] if (BOTH_PLATFORM_MENU_KEYS.includes(key)) return ['amazon', 'jd'] return ['amazon'] } diff --git a/admin-frontend-vue/src/pages/account/UserMenuAuthTree.vue b/admin-frontend-vue/src/pages/account/UserMenuAuthTree.vue index f20051a4a..c3cb87457 100644 --- a/admin-frontend-vue/src/pages/account/UserMenuAuthTree.vue +++ b/admin-frontend-vue/src/pages/account/UserMenuAuthTree.vue @@ -22,7 +22,7 @@ const loaded = ref(false) /** * 按平台过滤后的可见树(2026-11-17 用户口径「授权树也按平台收,选京东就去掉亚马逊的」): * 平台缺省按亚马逊(历史调用形状)。过滤算法与侧边栏同源(platform-scope 唯一出口), - * 叶子按 menuKey 判定——京东侧只剩「京东数据库+双侧账号域三件」。 + * 叶子按 menuKey 判定——京东侧=「京东数据库+双侧账号域三件+桌面端京东工具台三件」。 */ const visibleData = computed(() => filterMenuTreeNodesByPlatform(data.value, props.platform ?? 'amazon')) diff --git a/admin-frontend-vue/tests/platform-menu-filter.test.ts b/admin-frontend-vue/tests/platform-menu-filter.test.ts index f83ce6901..15f84e69e 100644 --- a/admin-frontend-vue/tests/platform-menu-filter.test.ts +++ b/admin-frontend-vue/tests/platform-menu-filter.test.ts @@ -3,6 +3,7 @@ import assert from 'node:assert/strict' import type { AdminMenuNode } from '../src/types/admin.ts' import { BOTH_PLATFORM_MENU_KEYS, + JD_APP_MENU_KEYS, JD_MENU_KEYS, PLATFORM_TABS, platformsOfMenuKey, @@ -115,7 +116,7 @@ test('tab 显示依据:两侧都有可见页才画 tab 条,仅一侧授权 assert.deepEqual(visiblePlatformsFor(null), []) }) -test('平台 tab 定义与两份菜单清单钉死(防清单漂移):京东独占仅数据库一页、双侧共用账号域三页', () => { +test('平台 tab 定义与菜单清单钉死(防清单漂移):京东独占后台仅数据库一页、双侧共用账号域三页、桌面端京东工具台三件(V209)', () => { assert.deepEqual(PLATFORM_TABS, [ { id: 'amazon', label: '亚马逊' }, { id: 'jd', label: '京东' }, @@ -124,6 +125,9 @@ test('平台 tab 定义与两份菜单清单钉死(防清单漂移):京东 assert.deepEqual([...JD_MENU_KEYS], ['admin_jd_database']) assert.deepEqual([...BOTH_PLATFORM_MENU_KEYS].sort(), ['admin_companies', 'admin_group_manage', 'admin_users']) + // 桌面端(app)清单与 JD_MENU_KEYS 分列:app 菜单没有 admin 路由,不得混进 + // 「与 routes.ts 对撞」的那份(下方护栏用例只扫 JD_MENU_KEYS/BOTH 两份是刻意的)。 + assert.deepEqual([...JD_APP_MENU_KEYS].sort(), ['jd-collect', 'jd-publish', 'jd_tools']) }) test('两份清单的每一条都必须在路由注册表登记(同 company-menu-route 护栏形状:少登记=看得见点进去404)', () => { diff --git a/admin-frontend-vue/tests/user-menu-tree-platform-filter.test.ts b/admin-frontend-vue/tests/user-menu-tree-platform-filter.test.ts index 7d315f89a..e0ff051b2 100644 --- a/admin-frontend-vue/tests/user-menu-tree-platform-filter.test.ts +++ b/admin-frontend-vue/tests/user-menu-tree-platform-filter.test.ts @@ -1,6 +1,10 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { filterMenuTreeNodesByPlatform, platformsOfMenuKey } from '../src/config/platform-scope.ts' +import { + filterMenuTreeNodesByPlatform, + JD_APP_MENU_KEYS, + platformsOfMenuKey, +} from '../src/config/platform-scope.ts' import { filterMenuTreeByPlatform } from '../src/layout/platform-menu-filter.ts' import type { MenuOptionNode } from '../src/pages/account/user-menu-auth.ts' import { pruneCheckedIdsToTree } from '../src/pages/account/user-menu-auth.ts' @@ -70,6 +74,26 @@ test('判定出口不变:京东独占/双侧/默认亚马逊三个档位原样 assert.deepEqual(platformsOfMenuKey('admin_shop_keys'), ['amazon']) }) +/** 桌面端(app)分区缩影:V209 京东工具台组+两工具子行,旁置亚马逊侧 app 菜单。 */ +const APP_TREE: MenuOptionNode[] = [ + node(51, 'jd_tools', [node(511, 'jd-collect'), node(512, 'jd-publish')]), + node(52, 'app_variant_collection'), +] + +test('桌面端京东侧不再整组消失:jd_tools 组+两工具保留,亚马逊 app 菜单剪掉(2026-11-17「前台的京东少了」回归钉)', () => { + for (const key of JD_APP_MENU_KEYS) { + assert.deepEqual(platformsOfMenuKey(key), ['jd'], `V209 app 菜单 ${key} 必须判京东侧`) + } + const jd = filterMenuTreeNodesByPlatform(APP_TREE, 'jd') + assert.deepEqual(keysOf(jd), ['jd_tools(jd-collect,jd-publish)'], + '选京东时桌面端分区必须保留京东工具台整组(叶子 key 认京东,组按存活子项去留)') +}) + +test('桌面端亚马逊侧:京东工具台消失,亚马逊 app 菜单原样', () => { + const amazon = filterMenuTreeNodesByPlatform(APP_TREE, 'amazon') + assert.deepEqual(keysOf(amazon), ['app_variant_collection']) +}) + test('pruneCheckedIdsToTree:勾选集收敛进可见树,隐藏侧 id 被剔除且原数组不动', () => { const jd = filterMenuTreeNodesByPlatform(TREE, 'jd') const checked = [11, 12, 2, 31, 99]