feat(platform): 后管菜单平台隔离收窄+列表密度收口(2026-11-18 用户截图口径「密钥管理与密钥用量统计仅亚马逊侧;菜单配置展示树按当前平台先裁剪再展平分页」)——①双侧共用清单四件收窄:AdminMenuPlatformScope.BOTH_MENU_KEYS(后端唯一出处)与 admin platform-scope.ts BOTH_PLATFORM_MENU_KEYS 同源去掉 admin_user_secrets/admin_user_secret_usage,密钥两页京东侧不再下发也不可配;②菜单管理页:全树字典保留(授权数据不动),展示树与父级候选走 filterMenuTreeNodesByPlatform 先裁剪再展平分页,切平台清筛选回页1并关弹窗;③列表密度收口:顶栏 76→56、内容区留白 30/32→12/16、筛选行 flex 换行紧凑、表格行距 6px、按钮/输入 34px 同高,三档响应式断点(1440/820/560,窄屏菜单项不再整体隐藏);task-243 顶栏 56px 断言随行、task-244 新钉六条紧凑断言与「窄屏不许 display:none 菜单项」反向钉。判据:AdminMenuPlatformScopeTest 11+AdminConsoleCurrentUserMenusPlatformTest 3(后端点名绿)+vue-tsc rc0+node --test 35+npx vitest run 全量 188/188 rc0(新增 menu-manage-platform.mount 3 支:京东侧菜单配置页无亚马逊项、保留账号域四件与京东工具、密钥页归亚马逊)+快检 overall=pass 四面绿(2026-11-18 12:5x,Git PATH 前置壳)
This commit is contained in:
@@ -37,18 +37,13 @@ export const JD_APP_MENU_KEYS: readonly string[] = [
|
||||
'jd-publish',
|
||||
]
|
||||
|
||||
/** 双侧共用菜单(2026-11-17 用户口径「这些亚马逊这边也要有」;2026-11-18 扩双侧):账号域
|
||||
* 页面在两个平台 tab 下都显示——同一套组件、按当前 tab 给接口传 platform,各自只看/管各自
|
||||
* 平台的账号、分组、公司(后端 V206 三表加列,存量默认亚马逊,京东侧数据在编辑弹窗里翻档)。
|
||||
* 2026-11-18 平台隔离落地(「非站点超管只看自己平台侧」)把三个账号域管理页也标双侧:
|
||||
* 它们是账号域功能而非亚马逊业务,京东侧公司超管被锁单侧后仍要能配菜单权限、管密钥。 */
|
||||
/** 双侧共用账号管理页面:用户、分组、公司与菜单权限配置。
|
||||
* 密钥管理/密钥用量统计按 2026-11-18 截图口径收回亚马逊侧。 */
|
||||
export const BOTH_PLATFORM_MENU_KEYS: readonly string[] = [
|
||||
'admin_users',
|
||||
'admin_group_manage',
|
||||
'admin_companies',
|
||||
'admin_columns',
|
||||
'admin_user_secrets',
|
||||
'admin_user_secret_usage',
|
||||
]
|
||||
|
||||
/** menuKey → 平台归属清单(唯一判定出口):京东独占(后台或桌面端清单)→ ['jd'];
|
||||
|
||||
@@ -6,6 +6,8 @@ import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { filterMenuTreeNodesByPlatform } from '@/config/platform-scope'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
@@ -31,11 +33,22 @@ import {
|
||||
interface MenuRow extends MenuManageNode {
|
||||
depth: number
|
||||
}
|
||||
interface PlatformMenuNode extends MenuManageNode {
|
||||
key: string
|
||||
children?: PlatformMenuNode[]
|
||||
}
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<MenuManageNode[]>([])
|
||||
const platformTab = usePlatformTabStore()
|
||||
// 菜单字典保留全树;显示与父级候选先分平台,再展平分页,避免京东项被亚马逊菜单挤到后页。
|
||||
const visibleMenuTree = computed(() => {
|
||||
const withKeys = (nodes: MenuManageNode[]): PlatformMenuNode[] =>
|
||||
nodes.map((node) => ({ ...node, key: node.columnKey, children: withKeys(node.children || []) }))
|
||||
return filterMenuTreeNodesByPlatform(withKeys(rows.value), platformTab.active)
|
||||
})
|
||||
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
||||
const filterName = ref('')
|
||||
const filterType = ref('')
|
||||
@@ -63,14 +76,14 @@ const menuRows = computed<MenuRow[]>(() => {
|
||||
if (node.children?.length) walk(node.children, depth + 1)
|
||||
}
|
||||
}
|
||||
walk(rows.value, 0)
|
||||
walk(visibleMenuTree.value, 0)
|
||||
return out
|
||||
})
|
||||
const createVisible = ref(false)
|
||||
const saving = ref(false)
|
||||
const editingNode = ref<MenuManageNode | null>(null)
|
||||
const menuForm = reactive<MenuManageForm>(createMenuForm(null, 0))
|
||||
const parentOptions = computed(() => menuParentCandidates(rows.value, menuForm.menuType))
|
||||
const parentOptions = computed(() => menuParentCandidates(visibleMenuTree.value, menuForm.menuType))
|
||||
const dialogTitle = computed(() => (editingNode.value ? '编辑菜单' : '新增菜单'))
|
||||
/** 节点 id -> 名称,供「上级菜单」列展示。 */
|
||||
const nameById = computed(() => {
|
||||
@@ -114,7 +127,7 @@ function openEdit(node: MenuManageNode) {
|
||||
|
||||
/** 菜单类型切换时:当前父菜单不属于新类型则重置为根。 */
|
||||
function onMenuTypeChange(): void {
|
||||
const candidates = menuParentCandidates(rows.value, menuForm.menuType)
|
||||
const candidates = menuParentCandidates(visibleMenuTree.value, menuForm.menuType)
|
||||
if (menuForm.parentId != null && !candidates.some((node) => node.id === menuForm.parentId)) {
|
||||
menuForm.parentId = null
|
||||
}
|
||||
@@ -215,6 +228,7 @@ async function removeMenu(node: MenuManageNode) {
|
||||
/** 切公司:菜单名称/类型是客户端筛选(在 filteredMenuRows 上筛,不进请求),留着上一家填的值
|
||||
* 就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」而输入框里还显示着它;页码回 1
|
||||
* 是因为新一家的行数不同。末尾的 void loadMenus() 才是本页唯一的数据出口。 */
|
||||
watch(() => platformTab.active, () => { filterName.value = ''; filterType.value = ''; page.value = 1; createVisible.value = false })
|
||||
watch(() => companyTab.activeId, () => { filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus() })
|
||||
|
||||
onMounted(loadMenus)
|
||||
|
||||
@@ -114,7 +114,7 @@ button, input, textarea, select { font: inherit; }
|
||||
.admin-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
|
||||
.admin-topbar {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 24px;
|
||||
min-height: 76px; padding: 0 32px;
|
||||
min-height: 56px; padding: 0 16px; flex-shrink: 0;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
border-bottom: 1px solid var(--admin-border);
|
||||
box-shadow: 0 10px 28px -28px rgba(39, 67, 94, 0.42);
|
||||
@@ -135,8 +135,8 @@ button, input, textarea, select { font: inherit; }
|
||||
}
|
||||
.admin-user-logout.el-button:hover { color: var(--admin-primary-strong); border-color: #95b1cb; background: #edf5fb; }
|
||||
|
||||
.admin-content { flex: 1; min-width: 0; padding: 30px 32px 56px; overflow: auto; }
|
||||
.page-stack { display: flex; flex-direction: column; gap: 18px; }
|
||||
.admin-content { flex: 1; min-width: 0; min-height: 0; padding: 12px 16px 20px; overflow: auto; }
|
||||
.page-stack { display: flex; flex-direction: column; gap: 10px; }
|
||||
/* 表格操作按钮工具栏:置于表格卡片顶部、右对齐(新增/删除/导入/导出等贴近表格行操作)。 */
|
||||
.table-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
|
||||
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
@@ -227,11 +227,67 @@ button, input, textarea, select { font: inherit; }
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.admin-sidebar { flex-basis: 64px; }
|
||||
.admin-brand-copy, .admin-menu .el-sub-menu__title span, .admin-menu .el-menu-item { display: none; }
|
||||
.admin-topbar { align-items: flex-start; flex-direction: column; padding: 12px 18px; }
|
||||
.admin-user { width: 100%; justify-content: space-between; }
|
||||
.admin-user-meta { align-items: flex-start; }
|
||||
.admin-content { padding: 18px 16px 40px; }
|
||||
/* 列表密度统一收口;带壳层作用域的选择器覆盖各页 scoped 旧皮肤,不影响弹窗编辑表单。 */
|
||||
.admin-shell .admin-content :is(.panel-box, .form-box) { padding: 12px 14px; }
|
||||
.admin-shell .admin-content .el-card { --el-card-padding: 12px; }
|
||||
.admin-shell .admin-content > [class$="-view"] { gap: 10px; min-width: 0; }
|
||||
.admin-shell .admin-content :is(.panel-box, .form-box) h3 { margin-bottom: 8px; }
|
||||
.admin-shell .admin-content :is(.jd-panel-head, .dedupe-panel-head) { margin-bottom: 8px; }
|
||||
.admin-shell .admin-content :is(.jd-panel-head, .dedupe-panel-head) h3 { margin-bottom: 0; }
|
||||
.admin-shell .admin-content :is(.users-desc, .page-heading p) { margin-top: 4px; margin-bottom: 8px; }
|
||||
.admin-shell .admin-content :is(.form-row, .clean-filter-row, .dedupe-filter-row, .dedupe-filter-date-row, .jd-filter-row) {
|
||||
display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 10px;
|
||||
}
|
||||
.admin-shell .admin-content :is(.clean-filter-row, .dedupe-filter-row, .jd-filter-row) > .form-group {
|
||||
flex: 1 1 140px; min-width: 0; max-width: 220px;
|
||||
}
|
||||
.admin-shell .admin-content :is(.form-row, .clean-filter-row, .dedupe-filter-row, .dedupe-filter-date-row, .jd-filter-row) .form-group { gap: 4px; }
|
||||
.admin-shell .admin-content :is(.panel-box, .form-box) .form-group input:not([type="checkbox"]):not([type="radio"]),
|
||||
.admin-shell .admin-content .jd-group-locked { min-height: 34px; padding: 5px 10px; }
|
||||
.admin-shell .admin-content .el-select.admin-filter .el-select__wrapper { min-height: 34px; padding: 4px 10px; }
|
||||
.admin-shell .admin-content :is(.panel-box, .form-box) .btn:not(.btn-sm) { min-height: 34px; padding: 5px 12px; }
|
||||
.admin-shell .admin-content :is(.clean-filter-actions, .dedupe-filter-actions, .jd-filter-actions) { flex-wrap: wrap; gap: 6px; }
|
||||
.admin-shell .admin-content .jd-filter-row > .el-select.admin-filter { width: 170px; }
|
||||
.admin-shell .admin-content :is(.table-toolbar, .clean-toolbar) { margin-bottom: 8px; }
|
||||
.admin-shell .admin-content :is(.table-scroll, .table-wrap) :is(th, td) { padding-top: 6px; padding-bottom: 6px; }
|
||||
.admin-shell .admin-content :is(.table-scroll, .table-wrap) .btn-sm { min-height: 28px; padding: 3px 6px; font-size: 12.5px; }
|
||||
.admin-shell .admin-content :is(.table-scroll, .table-wrap) .ops-cell { gap: 4px; }
|
||||
.admin-shell .admin-content .el-table .el-table__cell { padding: 5px 0; }
|
||||
.admin-shell .admin-content .old-pagination { gap: 8px; margin-top: 10px; }
|
||||
.admin-shell .admin-content .table-footer { padding-top: 10px; }
|
||||
.admin-shell .admin-content .admin-breadcrumb { margin-bottom: 8px; }
|
||||
.admin-shell .admin-content .company-tabs { margin-bottom: 8px; }
|
||||
.admin-shell .admin-content .company-tab { padding: 4px 12px; }
|
||||
.admin-shell .admin-content .operation-guide { margin-bottom: 10px; padding: 8px 12px; }
|
||||
.admin-shell .admin-content .og-body { margin-top: 4px; }
|
||||
.admin-shell .admin-content .og-text { line-height: 1.5; }
|
||||
.admin-shell .admin-content .og-steps { gap: 4px; margin-top: 4px; }
|
||||
|
||||
@media (max-width: 1440px) {
|
||||
.admin-sidebar { flex-basis: 208px; }
|
||||
.admin-content { padding: 10px 12px 16px; }
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.admin-sidebar { flex-basis: 160px; }
|
||||
.admin-brand { padding: 12px 10px; }
|
||||
.admin-brand-copy span, .admin-kicker { display: none; }
|
||||
.admin-topbar { min-height: 56px; gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
|
||||
.admin-topbar h1 { margin-top: 0; font-size: 16px; }
|
||||
.admin-user { gap: 8px; flex-wrap: wrap; }
|
||||
.admin-content { padding: 8px 10px 12px; }
|
||||
.admin-shell .admin-content :is(.panel-box, .form-box) { padding: 10px; }
|
||||
.admin-shell .admin-content .form-row > .form-group { flex: 1 1 140px; min-width: 0; max-width: 100%; }
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.admin-sidebar { flex-basis: 128px; }
|
||||
.admin-brand { gap: 6px; }
|
||||
.admin-brand-logo { width: 28px; height: 28px; }
|
||||
.admin-brand-copy strong { font-size: 13px; }
|
||||
.admin-menu-scroll { padding: 8px 4px; }
|
||||
.admin-menu .el-sub-menu__title, .admin-menu .el-menu-item { padding: 0 8px; font-size: 12px; }
|
||||
.menu-group-title { font-size: 13px; }
|
||||
.admin-user-role { display: none; }
|
||||
.admin-shell .admin-content :is(.clean-filter-row, .dedupe-filter-row, .jd-filter-row) > .form-group { max-width: 100%; }
|
||||
}
|
||||
|
||||
@@ -84,4 +84,8 @@ test('align_menu_page_drag_and_type_wiring', () => {
|
||||
assert.match(page, /menuSiblingGroupKey/, '拖拽分组按类型+父级')
|
||||
assert.match(page, /MENU_TYPE_OPTIONS|菜单类型/, '新建/编辑弹窗含菜单类型下拉')
|
||||
assert.match(page, /menuParentCandidates/, '父菜单候选按类型过滤')
|
||||
assert.match(page, /filterMenuTreeNodesByPlatform/, '配置树必须先按当前平台裁剪,再展平分页')
|
||||
assert.match(page, /platformTab\.active/, '配置树跟随当前平台')
|
||||
assert.match(page, /walk\(visibleMenuTree\.value, 0\)/, '展平读取当前平台树,京东数据库不能被全量菜单分页挤走')
|
||||
assert.match(page, /watch\(\(\) => platformTab\.active/, '切平台必须回第一页并清筛选')
|
||||
})
|
||||
|
||||
@@ -112,9 +112,10 @@ describe('AdminLayout × 平台锁定(2026-11-18)', () => {
|
||||
const texts = wrapper.findAll('.admin-menu .el-menu-item').map((item) => item.text())
|
||||
expect(texts).toContain('京东数据库')
|
||||
expect(texts).not.toContain('查询ASIN')
|
||||
// 双侧账号域照画(2026-11-18 扩双侧后含菜单权限配置/密钥管理/密钥用量统计)
|
||||
// 共用菜单配置保留,两个密钥入口仅亚马逊侧可见。
|
||||
expect(texts).toContain('菜单权限配置')
|
||||
expect(texts).toContain('密钥管理')
|
||||
expect(texts).not.toContain('密钥管理')
|
||||
expect(texts).not.toContain('密钥用量统计')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import ElementPlus from 'element-plus'
|
||||
import { createPinia, setActivePinia, type Pinia } from 'pinia'
|
||||
|
||||
import MenusPage from '@/pages/account/MenusPage.vue'
|
||||
import type { MenuManageNode } from '@/pages/account/menu-manage-model'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
|
||||
const menuApi = vi.hoisted(() => ({
|
||||
loadMenuManageTree: vi.fn(),
|
||||
createMenu: vi.fn(),
|
||||
updateMenu: vi.fn(),
|
||||
deleteMenu: vi.fn(),
|
||||
reorderMenus: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/pages/account/menu-manage-api', () => menuApi)
|
||||
|
||||
/** 同一次加载返回完整字典,平台隔离由真实页面完成。 */
|
||||
function mixedMenuTree(): MenuManageNode[] {
|
||||
let nextId = 1
|
||||
function node(
|
||||
columnKey: string,
|
||||
name: string,
|
||||
menuType: 'admin' | 'app',
|
||||
children: MenuManageNode[] = [],
|
||||
): MenuManageNode {
|
||||
const id = nextId++
|
||||
return {
|
||||
id, columnKey, name, menuType, parentId: null, routePath: '', sortOrder: id,
|
||||
children: children.map((child) => ({ ...child, parentId: id })),
|
||||
}
|
||||
}
|
||||
return [
|
||||
node('video_image', '视频图片', 'app'),
|
||||
node('admin_account', '账号与权限管理', 'admin', [
|
||||
node('admin_columns', '菜单权限管理', 'admin'),
|
||||
node('admin_users', '用户管理', 'admin'),
|
||||
node('admin_group_manage', '分组管理', 'admin'),
|
||||
node('admin_companies', '公司管理', 'admin'),
|
||||
node('admin_user_secrets', '密钥管理', 'admin'),
|
||||
node('admin_user_secret_usage', '密钥用量统计', 'admin'),
|
||||
]),
|
||||
node('admin_data', '数据管理', 'admin', [
|
||||
node('admin_shop_manage', '店铺管理', 'admin'),
|
||||
node('admin_appearance_patent', '外观专利管理', 'admin'),
|
||||
node('admin_similar_asin', '相似ASIN管理', 'admin'),
|
||||
node('admin_price_track', '跟价管理', 'admin'),
|
||||
node('admin_collect_data', '采集数据管理', 'admin'),
|
||||
node('admin_publish', '发布管理', 'admin'),
|
||||
node('admin_brand', '品牌管理', 'admin'),
|
||||
node('admin_records', '生成记录管理', 'admin'),
|
||||
node('admin_jd_database', '京东数据库', 'admin'),
|
||||
]),
|
||||
node('jd_tools', '京东工具台', 'app', [
|
||||
node('jd-collect', '京东店铺数据采集', 'app'),
|
||||
node('jd-publish', '京东商品上架', 'app'),
|
||||
]),
|
||||
]
|
||||
}
|
||||
|
||||
let pinia: Pinia
|
||||
let wrapper: VueWrapper<Element> | undefined
|
||||
let host: HTMLDivElement
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
window.localStorage.removeItem('admin-platform-tab')
|
||||
pinia = createPinia()
|
||||
setActivePinia(pinia)
|
||||
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
|
||||
useCompanyTabStore().setActiveId(7)
|
||||
menuApi.loadMenuManageTree.mockResolvedValue(mixedMenuTree())
|
||||
host = document.createElement('div')
|
||||
document.body.appendChild(host)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
host.remove()
|
||||
window.localStorage.removeItem('admin-platform-tab')
|
||||
})
|
||||
|
||||
async function mountMenus() {
|
||||
wrapper = mount(MenusPage, { attachTo: host, global: { plugins: [pinia, ElementPlus] } })
|
||||
await flushPromises()
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledWith(7)
|
||||
return wrapper
|
||||
}
|
||||
|
||||
function visibleNames(page: VueWrapper<Element>) {
|
||||
return page.findAll('tbody .menu-name-text').map((cell) => cell.text())
|
||||
}
|
||||
|
||||
async function clickNextPage(page: VueWrapper<Element>) {
|
||||
const next = page.findAll('.old-pagination button').find((button) => button.text() === '下一页')
|
||||
expect(next).toBeTruthy()
|
||||
expect(next!.attributes('disabled')).toBeUndefined()
|
||||
await next!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
/** 通过真实分页收齐表格行,避免只检查首屏而漏掉后页的跨平台菜单。 */
|
||||
async function allVisibleNames(page: VueWrapper<Element>) {
|
||||
const names = visibleNames(page)
|
||||
while (true) {
|
||||
const next = page.findAll('.old-pagination button').find((button) => button.text() === '下一页')
|
||||
if (!next || next.attributes('disabled') !== undefined) return names
|
||||
await clickNextPage(page)
|
||||
names.push(...visibleNames(page))
|
||||
}
|
||||
}
|
||||
|
||||
async function pickMenuType(page: VueWrapper<Element>, label: string) {
|
||||
const input = page.get('[aria-label="筛选菜单类型"]')
|
||||
await input.trigger('click')
|
||||
await flushPromises()
|
||||
const contentId = input.attributes('aria-controls')
|
||||
const panel = contentId ? document.getElementById(contentId) : null
|
||||
expect(panel).toBeTruthy()
|
||||
const option = [...panel!.querySelectorAll('.el-select-dropdown__item')]
|
||||
.find((item) => !item.classList.contains('is-hidden') && item.textContent?.trim() === label)
|
||||
expect(option).toBeTruthy()
|
||||
await new DOMWrapper(option!).trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
describe('菜单权限配置页的平台隔离', () => {
|
||||
it('京东表格排除视频图片和密钥,保留账号基础菜单、数据管理祖先及京东工具', async () => {
|
||||
usePlatformTabStore().setActive('jd')
|
||||
const page = await mountMenus()
|
||||
|
||||
expect(await allVisibleNames(page)).toEqual([
|
||||
'账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'数据管理', '京东数据库', '京东工具台', '京东店铺数据采集', '京东商品上架',
|
||||
])
|
||||
const databaseRow = page.findAll('tbody tr')
|
||||
.find((row) => row.find('.menu-name-text').text() === '京东数据库')
|
||||
expect(databaseRow!.findAll('td')[4].text()).toBe('数据管理')
|
||||
expect(databaseRow!.find('.column-child-mark').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('从京东切回亚马逊,视频图片和密钥仍在,京东数据库及京东工具均消失', async () => {
|
||||
usePlatformTabStore().setActive('jd')
|
||||
const page = await mountMenus()
|
||||
usePlatformTabStore().setActive('amazon')
|
||||
await flushPromises()
|
||||
|
||||
expect(await allVisibleNames(page)).toEqual([
|
||||
'视频图片', '账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'密钥管理', '密钥用量统计', '数据管理', '店铺管理', '外观专利管理',
|
||||
'相似ASIN管理', '跟价管理', '采集数据管理', '发布管理', '品牌管理', '生成记录管理',
|
||||
])
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('带名称和类型筛选进入第二页后切平台,回到第一页并清空两项筛选', async () => {
|
||||
const page = await mountMenus()
|
||||
const nameInput = page.get<HTMLInputElement>('input[placeholder="输入菜单名称"]')
|
||||
await nameInput.setValue('管理')
|
||||
await pickMenuType(page, '后台')
|
||||
expect(page.findAll('.menus-filter-row .el-select__selected-item').map((item) => item.text())).toContain('后台')
|
||||
expect(page.findAll('tbody .menu-type-text').every((cell) => cell.text() === '后台')).toBe(true)
|
||||
await clickNextPage(page)
|
||||
expect(page.get('.page-cur').text()).toBe('第 2 / 2 页')
|
||||
expect(visibleNames(page).length).toBeGreaterThan(0)
|
||||
expect(visibleNames(page).every((name) => name.includes('管理'))).toBe(true)
|
||||
|
||||
usePlatformTabStore().setActive('jd')
|
||||
await flushPromises()
|
||||
|
||||
expect(nameInput.element.value).toBe('')
|
||||
expect(page.findAll('.menus-filter-row .el-select__selected-item').map((item) => item.text())).toContain('全部')
|
||||
expect(page.get('.page-cur').text()).toBe('第 1 / 1 页')
|
||||
expect(page.get('.page-total').text()).toBe('共 10 条')
|
||||
expect(visibleNames(page)).toEqual([
|
||||
'账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'数据管理', '京东数据库', '京东工具台', '京东店铺数据采集', '京东商品上架',
|
||||
])
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -60,12 +60,11 @@ test('menuKey 平台归属:京东独占即 [jd],双侧清单即两侧,其
|
||||
assert.deepEqual(platformsOfMenuKey(''), ['amazon'])
|
||||
})
|
||||
|
||||
test('京东 tab:账号与权限只余双侧六项(2026-11-18 平台隔离把三个账号域管理页也标双侧),数据管理只余京东独占页(2026-11-17 分类管理并入京东数据库页后只剩数据库一页);顺序与 route 原样透传', () => {
|
||||
test('京东 tab:账号与权限保留账号管理四项,隐藏密钥管理与用量统计;数据管理保留京东数据库', () => {
|
||||
const filtered = filterMenuTreeByPlatform(TREE, 'jd')
|
||||
assert.deepEqual(filtered.map((item) => item.key), ['admin_group_account', 'admin_group_data'])
|
||||
assert.deepEqual(groupChildKeys(filtered, 'admin_group_account'),
|
||||
['admin_columns', 'admin_users', 'admin_group_manage', 'admin_user_secrets',
|
||||
'admin_user_secret_usage', 'admin_companies'])
|
||||
['admin_columns', 'admin_users', 'admin_group_manage', 'admin_companies'])
|
||||
// 2026-11-17 晚用户口径「京东分类管理并到京东数据库分类编辑里」:分类管理子菜单
|
||||
// (V204)下线,京东侧数据管理组只剩京东数据库一页。
|
||||
assert.deepEqual(groupChildKeys(filtered, 'admin_group_data'), ['admin_jd_database'])
|
||||
@@ -125,8 +124,9 @@ test('平台 tab 定义与菜单清单钉死(防清单漂移):京东独占
|
||||
// 2026-11-17 晚分类管理(admin_jd_category_manage)并入京东数据库页后从清单摘除。
|
||||
assert.deepEqual([...JD_MENU_KEYS], ['admin_jd_database'])
|
||||
assert.deepEqual([...BOTH_PLATFORM_MENU_KEYS].sort(),
|
||||
['admin_columns', 'admin_companies', 'admin_group_manage', 'admin_user_secret_usage',
|
||||
'admin_user_secrets', 'admin_users'])
|
||||
['admin_columns', 'admin_companies', 'admin_group_manage', 'admin_users'])
|
||||
assert.deepEqual(platformsOfMenuKey('admin_user_secrets'), ['amazon'])
|
||||
assert.deepEqual(platformsOfMenuKey('admin_user_secret_usage'), ['amazon'])
|
||||
// 桌面端(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'])
|
||||
|
||||
@@ -2,13 +2,13 @@ import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
// module 13 task 243:壳层换皮成 admin.html 蓝白浅色 —— 侧栏 252px 浅底、顶栏 76px、
|
||||
// module 13 task 243:壳层换皮成 admin.html 蓝白浅色 —— 侧栏 252px 浅底、顶栏 56px、
|
||||
// 角色胶囊 + 次级退出按钮、去掉顶栏重复 logo、菜单激活态浅蓝渐变+左蓝条。
|
||||
|
||||
test('test_task_243_shell_normal_primary_path', () => {
|
||||
const css = readSource('src/styles/main.css')
|
||||
assert.match(css, /\.admin-sidebar\s*\{[^}]*flex:\s*0\s*0\s*252px/, '侧栏宽度应为 252px')
|
||||
assert.match(css, /\.admin-topbar\s*\{[^}]*min-height:\s*76px/, '顶栏高度应为 76px')
|
||||
assert.match(css, /\.admin-topbar\s*\{[^}]*min-height:\s*56px/, '顶栏高度应为 56px')
|
||||
assert.match(css, /linear-gradient\(180deg,\s*var\(--admin-sidebar\)\s*0%,/, '侧栏应为浅色渐变底')
|
||||
// 壳层锁视口高(2026-11-18「菜单加个滚动条」绊线):.admin-shell 必须 height:100vh +
|
||||
// overflow:hidden——侧边栏固定、菜单区 el-scrollbar 与内容区 overflow:auto 才能各自独立滚动;
|
||||
@@ -28,8 +28,8 @@ test('test_task_243_shell_normal_variant_input', () => {
|
||||
|
||||
test('test_task_243_shell_normal_repeated_operation_is_idempotent', () => {
|
||||
const css = readSource('src/styles/main.css')
|
||||
const first = /\.admin-topbar\s*\{[^}]*min-height:\s*76px/.test(css)
|
||||
const second = /\.admin-topbar\s*\{[^}]*min-height:\s*76px/.test(css)
|
||||
const first = /\.admin-topbar\s*\{[^}]*min-height:\s*56px/.test(css)
|
||||
const second = /\.admin-topbar\s*\{[^}]*min-height:\s*56px/.test(css)
|
||||
assert.equal(first, true)
|
||||
assert.equal(first, second)
|
||||
})
|
||||
|
||||
@@ -10,6 +10,12 @@ test('test_task_244_component_normal_primary_path', () => {
|
||||
assert.match(css, /--el-table-header-bg-color:\s*#edf4fa/, '表头底色应对齐 admin #edf4fa')
|
||||
assert.match(css, /--el-table-header-text-color:\s*#4e6479/, '表头文字色应对齐 admin')
|
||||
assert.match(css, /--el-table-row-hover-bg-color:\s*#f1f7fb/, '行 hover 应对齐 admin')
|
||||
assert.match(css, /\.admin-content\s*\{[^}]*padding:\s*12px 16px 20px/, '内容区应减少留白')
|
||||
assert.match(css, /\.admin-content :is\(\.panel-box, \.form-box\)\s*\{[^}]*padding:\s*12px 14px/, '列表卡片应紧凑')
|
||||
assert.match(css, /\.admin-content :is\(\.table-scroll, \.table-wrap\) :is\(th, td\)\s*\{[^}]*padding-top:\s*6px;\s*padding-bottom:\s*6px/, '普通列表应缩小行间距')
|
||||
assert.match(css, /\.admin-content \.el-select\.admin-filter \.el-select__wrapper\s*\{[^}]*min-height:\s*34px/, '筛选下拉应与紧凑输入同高')
|
||||
assert.match(css, /\.admin-content :is\(\.form-row, \.clean-filter-row, \.dedupe-filter-row, \.dedupe-filter-date-row, \.jd-filter-row\)\s*\{[^}]*display:\s*flex;\s*flex-wrap:\s*wrap/, '筛选栏必须随可用宽度换行')
|
||||
assert.equal(/\.admin-menu \.el-menu-item\s*\{\s*display:\s*none/.test(css), false, '窄屏菜单项不能被直接隐藏')
|
||||
})
|
||||
|
||||
test('test_task_244_component_normal_variant_input', () => {
|
||||
|
||||
+2
-7
@@ -33,14 +33,9 @@ public final class AdminMenuPlatformScope {
|
||||
/** 桌面端(app 树)京东菜单 key(与前端 JD_APP_MENU_KEYS 逐字一致,V209:组行 + 两工具子行)。 */
|
||||
public static final Set<String> JD_APP_MENU_KEYS = Set.of("jd_tools", "jd-collect", "jd-publish");
|
||||
|
||||
/**
|
||||
* 双侧共用菜单 key(与前端 BOTH_PLATFORM_MENU_KEYS 逐字一致):账号域基础三页 +
|
||||
* 2026-11-18 用户口径补进的三个账号域管理页(菜单权限配置/密钥管理/密钥用量统计)——
|
||||
* 它们是账号域功能而非亚马逊业务,京东侧公司超管被锁单侧后仍要能配菜单、管密钥。
|
||||
*/
|
||||
/** 双侧共用账号管理页面;密钥管理与用量统计按 2026-11-18 截图口径收回亚马逊侧。 */
|
||||
public static final Set<String> BOTH_MENU_KEYS = Set.of(
|
||||
"admin_users", "admin_group_manage", "admin_companies",
|
||||
"admin_columns", "admin_user_secrets", "admin_user_secret_usage");
|
||||
"admin_users", "admin_group_manage", "admin_companies", "admin_columns");
|
||||
|
||||
private AdminMenuPlatformScope() {
|
||||
}
|
||||
|
||||
+4
-2
@@ -34,11 +34,13 @@ class AdminMenuPlatformScopeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("双侧清单逐字:账号域基础三页 + 2026-11-18 补进的三个账号域管理页")
|
||||
@DisplayName("双侧清单逐字:用户、分组、公司与菜单权限配置;密钥相关页面仅亚马逊")
|
||||
void bothPlatformMenuKeysArePinnedVerbatim() {
|
||||
assertThat(AdminMenuPlatformScope.BOTH_MENU_KEYS).containsExactlyInAnyOrder(
|
||||
"admin_users", "admin_group_manage", "admin_companies",
|
||||
"admin_columns", "admin_user_secrets", "admin_user_secret_usage");
|
||||
"admin_columns");
|
||||
assertThat(AdminMenuPlatformScope.platformsOfMenuKey("admin_user_secrets")).containsExactly("amazon");
|
||||
assertThat(AdminMenuPlatformScope.platformsOfMenuKey("admin_user_secret_usage")).containsExactly("amazon");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ key 归属判定
|
||||
|
||||
+3
-3
@@ -82,9 +82,9 @@ class AdminConsoleCurrentUserMenusPlatformTest {
|
||||
List<String> keys = new java.util.ArrayList<>();
|
||||
collectKeys(items(), keys);
|
||||
|
||||
assertThat(keys).contains("admin_jd_database", "admin_users", "admin_group_manage",
|
||||
"admin_columns", "admin_user_secrets", "admin_user_secret_usage");
|
||||
assertThat(keys).doesNotContain("admin_brand_gating", "admin_query_asin");
|
||||
assertThat(keys).contains("admin_jd_database", "admin_users", "admin_group_manage", "admin_columns");
|
||||
assertThat(keys).doesNotContain("admin_brand_gating", "admin_query_asin",
|
||||
"admin_user_secrets", "admin_user_secret_usage");
|
||||
assertThat(keys).contains("group-account");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user