feat(admin): 以固定双列替代桌面二级悬浮菜单

This commit is contained in:
2026-12-01 19:39:25 +08:00
parent e8da0054fa
commit d8a16b0778
12 changed files with 888 additions and 118 deletions
+15 -14
View File
@@ -109,13 +109,19 @@ class Fixture:
return route.fulfill(headers=cors, json={"code": 1, "show": 0, "msg": "", "data": data})
def open_group(parent, name):
label = parent.locator(".el-sub-menu__title").filter(has_text=re.compile("^" + re.escape(name) + "$"))
expect(label).to_be_visible()
group = label.locator("..")
if "is-opened" not in (group.get_attribute("class") or "").split():
label.click()
return group
def desktop_entry(page, name, root="数据统计", nested="自录数据统计"):
"""Use the visible desktop controls; avoid reselecting a root that is already open."""
rail = page.get_by_role("navigation", name="一级菜单", exact=True)
panel = page.get_by_role("navigation", name="二级菜单", exact=True)
group = rail.get_by_role("button", name=root, exact=True)
if group.get_attribute("aria-expanded") != "true":
group.click()
expect(panel).to_be_visible()
if nested:
branch = panel.get_by_role("button", name=nested, exact=True)
if branch.get_attribute("aria-expanded") != "true":
branch.click()
return panel.get_by_role("link", name=name, exact=True)
def check_app(page, fixture, out):
@@ -132,17 +138,12 @@ def check_app(page, fixture, out):
expect(page.get_by_text(label, exact=True)).to_be_visible()
page.mouse.move(1, 1)
aside = page.locator(".app-aside .menu:visible")
def entry(name):
parent = open_group(open_group(aside, "数据统计"), "自录数据统计")
return parent.get_by_role("menuitem", name=name, exact=True)
# First visit the sibling; the empty child below must be selected by click, not just by initial redirect.
entry("账户消耗录入").click()
desktop_entry(page, "账户消耗录入").click()
expect(page.locator("main .personal-account-cost-page")).to_be_visible()
expect(page.locator("main .personal-account-cost-page").get_by_role("button", name="新增", exact=True)).to_be_visible() # Authorized control is present; never submit any business write.
assert parse_qs(urlsplit(page.url).query).get("via") == ["sidebar"], page.url
entry("自录转化统计").click()
desktop_entry(page, "自录转化统计").click()
stats = page.locator("main .self-input-stats-page")
expect(stats.get_by_text("业绩明细", exact=True)).to_be_visible()
expect(stats.locator(".el-table").get_by_text("OFFLINE-today", exact=True)).to_be_visible()