fix(admin): 折叠时恢复图标栏和右侧悬浮菜单

This commit is contained in:
2026-12-02 09:31:36 +08:00
parent 608e912966
commit edfc67e6f6
10 changed files with 487 additions and 426 deletions
+114 -75
View File
@@ -23,6 +23,7 @@ NAMES = "业务报表"
SIMILAR = ("全院财务结算与跨部门对账月报表", "全院财务退款与跨部门对账月报表")
DUPLICATE = "回访明细"
TITLE = ".el-sub-menu__title"
POPUP = ".admin-nav-popper.el-menu--popup-container > .el-menu--popup:visible"
def setup_menu(fixture):
@@ -190,35 +191,46 @@ def compact_layout(page, rail, panel, fold, baseline=None):
assert abs(metrics["rail"] - 64) <= 1, ("compact rail", metrics)
assert abs(metrics["main_x"] - 64) <= 2, ("main should start next to the rail", metrics)
if baseline is not None:
assert metrics == baseline, ("drilling or resizing moved the content", metrics, baseline)
# Measuring width alone would pass even with an absolutely positioned flyout over the page.
expect(page.locator(".el-menu--popup:visible, .el-popover:visible, .el-drawer:visible")).to_have_count(0)
assert rail.evaluate("""nav => {
const b = nav.getBoundingClientRect();
return [...nav.querySelectorAll('a,button')].every(item => {
const r = item.getBoundingClientRect();
return !r.width || (r.left >= b.left - 1 && r.right <= b.right + 1);
});
}"""), "menu controls extend outside the compact rail"
assert page.locator("main").evaluate("""main => {
const b = main.getBoundingClientRect();
return [4, 64, 160].every(dx => [8, 64, 144].every(dy =>
main.contains(document.elementFromPoint(b.left + dx, b.top + dy))));
}"""), "sidebar flyout or backdrop intercepts the content"
assert metrics == baseline, ("opening a flyout or resizing moved the content", metrics, baseline)
return metrics
def compact_label(row):
# A full title can be shortened on screen, but it may not collapse to a single glyph
# or become tooltip-only. The full title remains the control's accessible name.
label = row.locator(".compact-label")
expect(label).to_be_visible()
text = label.inner_text().strip()
assert len(text) > 1 and row.get_attribute("title"), ("missing visible or full label", text)
box, ink = row.bounding_box(), label.bounding_box()
assert box["x"] - 1 <= ink["x"] and ink["x"] + ink["width"] <= box["x"] + box["width"] + 1
return text
def icon_only(row, name):
# Count painted text within the row, not textContent: Element keeps accessible
# names for controls whose visual label is hidden. A fallback initial is an icon.
expect(row).to_have_accessible_name(name)
visible = row.evaluate("""row => {
const walk = document.createTreeWalker(row, NodeFilter.SHOW_TEXT);
const rect = row.getBoundingClientRect(), words = [];
for (let n; (n = walk.nextNode());) {
if (!n.textContent.trim() || n.parentElement.closest('.menu-item-icon,svg')) continue;
const range = document.createRange(); range.selectNodeContents(n);
const r = range.getBoundingClientRect();
if (r.width < 1 || r.height < 1) continue;
const x = Math.max(r.left, rect.left), y = Math.max(r.top, rect.top);
if (x >= Math.min(r.right, rect.right) || y >= Math.min(r.bottom, rect.bottom)) continue;
if (n.parentElement.checkVisibility({opacityProperty: true, visibilityProperty: true}))
words.push(n.textContent.trim());
}
return words;
}""")
assert visible == [], ("compact rail must contain icons only", name, visible)
def popup_box(row, anchor):
# A child that opens in place would also be visible. Verify it is painted to
# the right of its own trigger, within the viewport, not clipped by a rail.
expect(row).to_be_visible()
box = row.locator("xpath=ancestor::ul[contains(@class,'el-menu--popup')][1]")
settle(box.locator("xpath=ancestor::*[contains(concat(' ',normalize-space(@class),' '),' el-popper ')][1]"))
b, a = box.bounding_box(), anchor.bounding_box()
assert a["x"] + a["width"] - 2 <= b["x"] <= a["x"] + a["width"] + 32, (a, b)
assert b["x"] + b["width"] <= row.page.viewport_size["width"] + 1, b
assert row.evaluate("""e => {
const r = e.getBoundingClientRect();
return e.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2));
}"""), "floating menu row is covered or clipped"
return {k: round(v, 1) for k, v in b.items()}
def clipped(row, selector, label):
@@ -373,92 +385,119 @@ def check(page, fixture, out):
def unchanged():
return compact_layout(page, compact, panel, fold, report["collapsed"])
group = lambda name: compact.get_by_role("button", name=name, exact=True)
entry = lambda name: compact.get_by_role("link", name=name, exact=True)
back = group("返回上一级")
popups = page.locator(POPUP)
group = lambda name: compact.get_by_role("menuitem", name=name, exact=True)
entry = lambda name: popups.get_by_role("link", name=name, exact=True)
top_leaf = compact.get_by_role("link", name=TOP_LEAF, exact=True)
def only_roots():
expect(compact.get_by_role("menuitem")).to_have_count(4)
for name in (ROOT, OTHER, TOP_LEAF, NAMES):
icon_only(group(name), name)
expect(compact.get_by_role("button", name=re.compile("返回"))).to_have_count(0)
expect(group(NESTED)).to_have_count(0)
expect(group(HIDDEN_ROOT)).to_have_count(0)
def leave_menus():
page.mouse.move(page.viewport_size["width"] - 12, page.viewport_size["height"] - 12)
expect(popups).to_have_count(0)
page.set_viewport_size({"width": 1350, "height": 960})
unchanged()
expect(back).to_be_hidden()
expect(group(HIDDEN_ROOT)).to_have_count(0)
only_roots()
expect(popups).to_have_count(0)
report["collapsed_centers"] = {"logo": center(compact, compact.locator(".logo img"), "brand image")}
for name, row in ((ROOT, group(ROOT)), (OTHER, group(OTHER)), (TOP_LEAF, entry(TOP_LEAF))):
compact_label(row)
expect(row).to_have_attribute("title", name)
report["collapsed_centers"][name] = center(compact, row.locator(".compact-icon svg"), name)
for name in (ROOT, OTHER, TOP_LEAF):
icon = group(name).locator(".menu-item-icon")
report["collapsed_centers"][name] = center(compact, icon, name)
initial = group(OTHER).locator(".menu-item-icon")
assert initial.evaluate("""e => e.querySelector('svg') !== null || !!e.textContent.trim() ||
!['none','normal','""'].includes(getComputedStyle(e, '::before').content)"""), "missing fallback icon"
screenshot(page, out, "collapsed")
# Similar and identical sibling names must be distinguishable without hovering.
group(NAMES).click()
assert compact_label(entry(SIMILAR[0])) != compact_label(entry(SIMILAR[1]))
twins = compact.get_by_role("link", name=re.compile("^" + DUPLICATE))
# Hover previews groups without navigating. Full labels and distinct link targets
# remain available in the flyout rather than abbreviated or wrapped in the rail.
group(NAMES).hover()
for name in SIMILAR:
expect(entry(name).get_by_text(name, exact=True)).to_be_visible()
twins = popups.get_by_role("link", name=re.compile("^" + DUPLICATE))
expect(twins).to_have_count(2)
assert twins.nth(0).inner_text() != twins.nth(1).inner_text()
assert twins.nth(0).get_attribute("aria-label") != twins.nth(1).get_attribute("aria-label")
assert twins.nth(0).get_attribute("href") != twins.nth(1).get_attribute("href")
route_at(page, h_path, h_query)
unchanged()
back.click()
expect(group(NAMES)).to_be_focused()
# Browsing directories (including one with only one permitted child) never chooses a route.
group(OTHER).hover()
page.wait_for_timeout(650) # Exercise the legacy Element Plus hover-to-open delay.
unchanged()
expect(entry(DETAIL)).to_be_hidden()
group(OTHER).press("Enter")
expect(entry(DETAIL)).to_be_focused()
report["single_level_popup"] = popup_box(entry(DETAIL), group(OTHER))
expect(twins).to_have_count(0)
expect(entry(HIDDEN)).to_have_count(0)
entry(DETAIL).hover()
page.wait_for_timeout(650) # Hold the pointer in the popper beyond the menu's leave delay.
expect(entry(DETAIL)).to_be_visible()
route_at(page, h_path, h_query)
only_roots()
unchanged()
back.press("Space")
expect(group(OTHER)).to_be_focused()
leave_menus()
route_at(page, h_path, h_query)
unchanged()
group(ROOT).click()
expect(group(NESTED)).to_be_focused()
# The next level is another flyout, not a replacement list or an expanded aside.
group(ROOT).hover()
nested = title(popups, NESTED)
report["second_level_popup"] = popup_box(nested, group(ROOT))
arrow_metrics(nested, NESTED)
expect(entry(LEAF)).to_be_hidden()
route_at(page, h_path, h_query)
unchanged()
group(NESTED).press("Space")
expect(entry(HOME)).to_be_focused()
compact_label(entry(LEAF))
expect(group(ROOT)).to_be_hidden()
nested.hover()
leaf = entry(LEAF)
report["third_level_popup"] = popup_box(leaf, nested)
leaf.hover()
page.wait_for_timeout(650)
expect(leaf).to_be_visible()
expect(nested).to_be_visible()
expect(popups).to_have_count(2)
only_roots()
route_at(page, h_path, h_query)
unchanged()
screenshot(page, out, "collapsed-third-level")
page.keyboard.press("Tab")
expect(entry(LEAF)).to_be_focused()
page.keyboard.press("Enter")
leaf.click()
route_at(page, c_path, c_query)
expect(cost_page).to_be_visible()
expect(entry(LEAF)).to_have_attribute("aria-current", "page")
unchanged()
back.click()
expect(group(NESTED)).to_be_focused()
back.press("Enter")
expect(group(ROOT)).to_be_focused()
expect(back).to_be_hidden()
route_at(page, c_path, c_query)
expect(popups).to_have_count(0)
only_roots()
unchanged()
entry(TOP_LEAF).click()
route_at(page, "solo", {})
expect(entry(TOP_LEAF)).to_have_attribute("aria-current", "page")
# Visit a nested index (empty path with default params), a direct root leaf, then
# a single-child directory using the exact router links the collapsed sidebar displays.
group(ROOT).hover()
nested.hover()
entry(HOME).click()
route_at(page, h_path, h_query, trailing=True)
expect(tab(HOME)).to_have_count(1)
expect(popups).to_have_count(0)
unchanged()
group(OTHER).click()
top_leaf.click()
route_at(page, "solo", {})
expect(top_leaf).to_have_attribute("aria-current", "page")
unchanged()
group(OTHER).hover()
route_at(page, "solo", {})
entry(DETAIL).click()
route_at(page, d_path, d_query)
expect(entry(DETAIL)).to_have_attribute("aria-current", "page")
expect(cost_page).to_be_visible()
expect(popups).to_have_count(0)
unchanged()
page.reload()
route_at(page, d_path, d_query)
expect(cost_page).to_be_visible()
expect(popups).to_have_count(0)
only_roots()
unchanged()
# The mobile drawer starts closed, performs real link navigation, then closes. Neither
# opening it nor choosing a link changes the desktop preference saved by the fold button.
group(OTHER).hover()
expect(entry(DETAIL)).to_be_visible()
page.set_viewport_size({"width": 390, "height": 844})
expect(popups).to_have_count(0)
expect(compact).to_be_hidden()
expect(rail).to_be_hidden()
expect(panel).to_be_hidden()
@@ -1,46 +0,0 @@
import type { DualNode } from './dual-model'
/** Resolve against today's authorized tree, not node objects saved before a role change. */
export function compactTrail(roots: DualNode[], keys: string[]) {
const trail: DualNode[] = []
let level = roots
for (const key of keys) {
const directory = level.find(node => node.key === key && node.children.length)
if (!directory) break
trail.push(directory)
level = directory.children
}
return trail
}
/** Keep recognizable beginnings and endings. Never hide the only distinguishing text. */
export function compactEntries(nodes: DualNode[]) {
const titles = nodes.map(node => node.title.trim() || (node.children.length ? '目录' : '页面'))
const shortened = titles.map(title => {
const chars = Array.from(title)
return chars.length <= 8 ? title : chars.slice(0, 4).join('') + '…' + chars.slice(-3).join('')
})
const counts = new Map<string, number>()
const names = new Map<string, Set<string>>()
titles.forEach((title, i) => {
counts.set(title, (counts.get(title) || 0) + 1)
const bucket = names.get(shortened[i]) || new Set<string>()
bucket.add(title)
names.set(shortened[i], bucket)
})
const seen = new Map<string, number>()
return nodes.map((node, i) => {
const title = titles[i]
const ordinal = (seen.get(title) || 0) + 1
seen.set(title, ordinal)
const count = counts.get(title)!
const badge = count > 1 ? `${ordinal}/${count}` : ''
return {
node,
// Full names wrap if shortening would conflate two different menu entries.
label: names.get(shortened[i])!.size > 1 ? title : shortened[i],
name: badge ? `${title}(${badge})` : title,
badge
}
})
}
@@ -1,181 +0,0 @@
<template>
<div ref="rail" class="compact-rail" :data-depth="trail.length">
<div v-if="directory" class="compact-context">
<button type="button" class="compact-back" aria-label="返回上一级" title="返回上一级" @click="back">
<icon name="el-icon-ArrowLeft" :size="14" aria-hidden="true" />
返回
</button>
<div class="compact-heading" :title="directory.title">{{ directory.title }}</div>
</div>
<ul ref="list" class="compact-list" :aria-label="directory ? directory.title + '的子菜单' : '一级菜单'">
<li v-for="{ node, name, label, badge } in entries" :key="node.key">
<component
:is="node.children.length ? 'button' : AppLink"
:type="node.children.length ? 'button' : undefined"
:to="node.children.length ? undefined : node.target"
:rel="node.external ? 'noopener noreferrer' : undefined"
class="compact-node"
:class="{ 'is-active': node.key === leafKey || ancestorKeys.includes(node.key) }"
:data-key="node.key"
:aria-current="node.key === leafKey ? 'page' : undefined"
:aria-label="name"
:title="name"
@click="node.children.length && enter(node)"
>
<span class="compact-icon" aria-hidden="true">
<icon :name="node.icon || (node.children.length ? 'el-icon-Folder' : 'el-icon-Document')"
:size="18" />
</span>
<span class="compact-label">{{ label }}</span>
<span v-if="badge" class="compact-badge" aria-hidden="true">{{ badge }}</span>
<icon v-if="node.children.length" class="compact-next" name="el-icon-ArrowRight"
:size="10" aria-hidden="true" />
</component>
</li>
</ul>
</div>
</template>
<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue'
import AppLink from '@/components/app-link/index.vue'
import { compactEntries, compactTrail } from './compact-model'
import type { DualNode } from './dual-model'
const props = defineProps<{
roots: DualNode[]
ancestorKeys: string[]
leafKey?: string
routeKey: string
}>()
// Manual folding mounts a fresh root list; no sidebar/global store writes on drill-down.
const keys = ref<string[]>([])
const trail = computed(() => compactTrail(props.roots, keys.value))
const directory = computed(() => trail.value[trail.value.length - 1])
const entries = computed(() => compactEntries(directory.value?.children ?? props.roots))
const rail = ref<HTMLElement>()
const list = ref<HTMLElement>()
function focusItem(key?: string) {
const items = Array.from(list.value?.querySelectorAll<HTMLElement>('.compact-node') ?? [])
const item = items.find(el => el.getAttribute('data-key') === key) || items[0]
item?.focus()
}
function enter(node: DualNode) {
keys.value = [...keys.value, node.key]
void nextTick(() => focusItem())
}
function back() {
const returningTo = directory.value?.key
keys.value = keys.value.slice(0, -1)
void nextTick(() => focusItem(returningTo))
}
// While browsing a sublevel, tab/history navigation may select a different branch.
// A rail at its top level remains an overview. Neither action should move focus out of the page.
watch(() => props.routeKey, () => {
if (keys.value.length) keys.value = [...props.ancestorKeys]
})
watch(() => props.roots, () => {
if (trail.value.length !== keys.value.length) keys.value = trail.value.map(node => node.key)
})
// If a permission update or a route change removes the focused row, restore focus locally.
watch(entries, () => {
const owner = rail.value?.ownerDocument
if (!owner?.activeElement || !rail.value?.contains(owner.activeElement)) return
void nextTick(() => {
if (owner.activeElement === owner.body) focusItem(props.leafKey)
})
})
</script>
<style scoped>
.compact-rail {
display: flex;
flex: 1 1 0;
flex-direction: column;
min-height: 0;
}
.compact-context {
flex: none;
margin: 0 4px 4px;
padding-bottom: 6px;
border-bottom: 1px solid var(--zyt-card-border);
text-align: center;
}
.compact-back, .compact-node {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: 100%;
border: none;
border-radius: 5px;
background: transparent;
color: var(--zyt-nav-text);
cursor: pointer;
}
.compact-back { min-height: 32px; gap: 2px; font-size: 12px; }
.compact-heading {
overflow: hidden;
color: var(--zyt-nav-title);
font-size: 12px;
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
.compact-list {
flex: 1;
min-height: 0;
overflow: hidden auto;
overscroll-behavior: contain;
scrollbar-width: none;
margin: 0;
padding: 4px 4px 12px;
list-style: none;
}
.compact-list::-webkit-scrollbar { display: none; }
.compact-list li + li { margin-top: 3px; }
.compact-node {
position: relative;
flex-direction: column;
gap: 3px;
min-height: 52px;
padding: 6px 2px;
text-align: center;
text-decoration: none;
}
.compact-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
color: var(--zyt-nav-icon);
}
.compact-next {
position: absolute;
top: 9px;
right: 4px;
color: var(--zyt-nav-icon);
}
.compact-label {
max-width: 100%;
overflow-wrap: anywhere;
font-size: 12px;
line-height: 15px;
}
.compact-badge { font-size: 11px; line-height: 13px; }
.compact-back:hover, .compact-node:hover { background: var(--zyt-nav-hover); }
.compact-node.is-active {
background: var(--zyt-nav-active);
color: var(--zyt-nav-selected);
}
.compact-node.is-active .compact-icon { color: inherit; }
.compact-node:focus-visible, .compact-back:focus-visible {
outline: 2px solid var(--zyt-nav-selected);
outline-offset: -2px;
}
</style>
@@ -13,9 +13,10 @@
<circle cx="19" cy="6.5" r="2" fill="currentColor"/>
</svg>
</div>
<compact-rail v-if="app.isCollapsed"
:roots="roots" :ancestor-keys="ancestorKeys" :leaf-key="selection.leaf?.key"
:route-key="route.fullPath" />
<side-menu v-if="app.isCollapsed"
:nodes="roots" :active-key="selection.leaf?.key"
:is-collapsed="true" :classic="false" :theme="settings.sideTheme"
:unique-opened="settings.isUniqueOpened" />
<ul v-else ref="rootList" class="dual-roots">
<li v-for="root in roots" :key="root.key">
<component
@@ -64,8 +65,8 @@ import AppLink from '@/components/app-link/index.vue'
import useAppStore from '@/stores/modules/app'
import useSettingStore from '@/stores/modules/setting'
import CompactRail from './compact-rail.vue'
import DualBranch from './dual-branch.vue'
import SideMenu from './menu.vue'
import { buildDualMenu, findDualSelection, firstDualLeaf, type DualNode } from './dual-model'
const props = defineProps<{ routes: RouteRecordRaw[] }>()
@@ -0,0 +1,50 @@
import type { MenuInstance } from 'element-plus'
import { nextTick, useId, type Ref } from 'vue'
import type { DualNode } from './dual-model'
/** ElMenu supplies hover, positioning, dismissal and selection. Its vertical
* popup mode doesn't supply keyboard entry, so drive its public open/close API. */
export function useFlyoutKeyboard(
menu: Ref<MenuInstance | undefined>,
activeKey: () => string | undefined,
dismiss: () => void
) {
// Popup children may be teleported outside the nav. Scope IDs to this menu
// instance (the mobile drawer can leave another sidebar mounted).
const prefix = useId()
const id = (node: DualNode) => `nav-${prefix}-${node.key}`
const focus = (node: DualNode) => document.getElementById(id(node))?.focus()
return (node: DualNode, parent?: DualNode) => ({
id: id(node),
tabindex: node.children.length ? 0 : undefined,
'aria-current': node.key === activeKey() ? 'page' as const : undefined,
onClick: node.children.length ? undefined : dismiss,
onKeydown(event: KeyboardEvent) {
// A nested, non-teleported popup also bubbles through its parent
// directory. Only the focused row owns this keystroke.
if (event.target !== event.currentTarget) return
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
const trigger = event.currentTarget as HTMLElement
const key = event.key
if (node.children.length && ['ArrowRight', 'Enter', ' '].includes(key)) {
menu.value?.open(node.key)
void nextTick(() => focus(node.children[0]))
} else if (key === 'Escape' || key === 'ArrowLeft') {
const group = trigger.getAttribute('aria-expanded') === 'true' ? node : parent
if (!group) return
menu.value?.close(group.key)
focus(group)
} else if (!node.children.length && key === ' ') {
trigger.click()
} else {
return
}
event.preventDefault()
event.stopPropagation()
}
})
}
export type FlyoutKeyboard = ReturnType<typeof useFlyoutKeyboard>
@@ -1,33 +1,43 @@
<template>
<template v-if="!route.meta?.hidden">
<app-link v-if="!hasShowChild" :to="menuTarget" :class="{ 'admin-nav-link': art }">
<el-menu-item :index="routePath" :aria-label="art ? routeMeta?.title : undefined">
<template v-if="node || !route?.meta?.hidden">
<app-link v-if="!hasShowChild" :to="node?.target ?? menuTarget" :class="{ 'admin-nav-link': art }"
v-bind="flyoutAttrs" :aria-label="node?.title" :rel="node?.external ? 'noopener noreferrer' : undefined">
<el-menu-item :index="node?.key ?? routePath" :aria-label="art ? title : undefined">
<icon
class="menu-item-icon"
:size="art ? 20 : 16"
v-if="routeMeta?.icon"
:name="routeMeta?.icon"
v-if="iconName"
:name="iconName"
/>
<i v-else-if="art" class="menu-item-icon admin-nav-icon--empty" aria-hidden="true"
:data-initial="titleInitial" />
<template #title>
<span class="menu-name" :title="art ? routeMeta?.title : undefined">{{ routeMeta?.title }}</span>
<span class="menu-name" :title="art ? title : undefined">{{ title }}</span>
</template>
</el-menu-item>
</app-link>
<el-sub-menu v-else :index="routePath" :popper-class="popperClass"
:aria-label="art ? routeMeta?.title : undefined">
<el-sub-menu v-else v-bind="flyoutAttrs" :index="node?.key ?? routePath" :popper-class="popperClass"
:aria-label="art ? title : undefined">
<template #title>
<icon
class="menu-item-icon"
:size="art ? 20 : 16"
v-if="routeMeta?.icon"
:name="routeMeta?.icon"
v-if="iconName"
:name="iconName"
/>
<i v-else-if="art" class="menu-item-icon admin-nav-icon--empty" aria-hidden="true"
:data-initial="titleInitial" />
<span class="menu-name" :title="art ? routeMeta?.title : undefined">{{ routeMeta?.title }}</span>
<span class="menu-name" :title="art ? title : undefined">{{ title }}</span>
</template>
<menu-item
v-for="child in node?.children"
:key="child.key"
:node="child"
:parent-node="node"
:flyout="flyout"
:popper-class="popperClass"
:art="art"
/>
<menu-item
v-for="item in route?.children"
:key="resolvePath(item.path)"
@@ -46,24 +56,33 @@ import type { RouteRecordRaw } from 'vue-router'
import { getNormalPath, objectToQuery } from '@/utils/util'
import { isExternal } from '@/utils/validate'
import type { DualNode } from './dual-model'
import type { FlyoutKeyboard } from './flyout-keyboard'
interface Props {
route: RouteRecordRaw
routePath: string
node?: DualNode
parentNode?: DualNode
flyout?: FlyoutKeyboard
route?: RouteRecordRaw
routePath?: string
popperClass: string
art?: boolean
}
const props = defineProps<Props>()
const props = withDefaults(defineProps<Props>(), { routePath: '' })
const flyoutAttrs = computed(() =>
props.node ? props.flyout?.(props.node, props.parentNode) : undefined
)
const hasShowChild = computed(() => {
const children: RouteRecordRaw[] = props.route.children ?? []
if (props.node) return !!props.node.children.length
const children: RouteRecordRaw[] = props.route?.children ?? []
return !!children.filter((item) => !item.meta?.hidden).length
})
const routeMeta = computed(() => {
return props.route.meta
})
const titleInitial = computed(() => Array.from(String(routeMeta.value?.title || '').trim())[0])
const title = computed(() => props.node?.title ?? props.route?.meta?.title)
const iconName = computed(() => props.node?.icon ?? props.route?.meta?.icon)
const titleInitial = computed(() => Array.from(String(title.value || '').trim())[0])
const resolvePath = (path: string) => {
// The online preview uses generated absolute item IDs to preserve arbitrary
@@ -76,7 +95,7 @@ const resolvePath = (path: string) => {
return newPath
}
const queryStr = computed<string>(() => {
const query = props.route.meta?.query as string
const query = props.route?.meta?.query as string
try {
const queryObj = JSON.parse(query)
return objectToQuery(queryObj)
@@ -6,13 +6,24 @@
>
<el-scrollbar>
<el-menu
ref="menu"
v-bind="config"
:default-active="activeMenu"
:collapse="isCollapsed"
mode="vertical"
:unique-opened="uniqueOpened"
@select="$emit('select')"
@open="trackOpen"
@close="openGroups.delete($event)"
@select="handleSelect"
>
<menu-item
v-for="node in nodes"
:key="node.key"
:node="node"
:flyout="flyout"
:art="true"
:popper-class="popperClass"
/>
<menu-item
v-for="route in routes"
:key="route.path"
@@ -27,13 +38,18 @@
</template>
<script setup lang="ts">
import type { PropType } from 'vue'
import type { MenuInstance } from 'element-plus'
import { computed, nextTick, ref, type PropType } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import type { DualNode } from './dual-model'
import { useFlyoutKeyboard } from './flyout-keyboard'
import MenuItem from './menu-item.vue'
const props = defineProps({
classic: { type: Boolean, default: true },
nodes: Array as PropType<DualNode[]>,
activeKey: String,
routes: {
type: Object as PropType<RouteRecordRaw[]>
},
@@ -57,10 +73,28 @@ const props = defineProps({
}
})
defineEmits(['select'])
const emit = defineEmits(['select'])
const menu = ref<MenuInstance>()
const openGroups = new Set<string>()
const trackOpen = (key: string) => { if (props.nodes) openGroups.add(key) }
function dismissFlyouts() {
// The anchor can be activated directly (including assistive technology
// and new-tab links), bypassing ElMenuItem's native select handler.
for (const key of openGroups) menu.value?.close(key)
openGroups.clear()
}
const flyout = useFlyoutKeyboard(menu, () => props.activeKey, dismissFlyouts)
const route = useRoute()
const activeMenu = computed<string>(() => route.meta?.activeMenu || route.path)
const activeMenu = computed<string>(() =>
props.nodes ? props.activeKey ?? '' : route.meta?.activeMenu || route.path
)
function handleSelect() {
emit('select')
// ElMenu closes its popups on select. Keep the highlight on the actual page
// if a link opens a new tab instead of changing the current route.
if (props.nodes && activeMenu.value) void nextTick(() => menu.value?.updateActiveIndex(activeMenu.value))
}
const themeClass = computed(() => `theme-${props.theme}`)
// Teleported flyouts do not inherit the palette from .side.
const popperClass = computed(() =>
+5
View File
@@ -7,6 +7,11 @@
--nav-row-end: var(--el-menu-base-level-padding);
.admin-nav-link { display: block; }
.el-sub-menu[tabindex='0']:focus-visible > .el-sub-menu__title,
.admin-nav-link[id]:focus-visible > .el-menu-item {
outline: 2px solid var(--zyt-nav-selected);
outline-offset: -2px;
}
.menu-name {
min-width: 0;
overflow: hidden;
+230 -96
View File
@@ -1,113 +1,247 @@
// Real Vue component, router, and event handlers; the host tree is in memory (not a browser/layout engine).
// Run with node --test. ZYT_TEST_ADMIN_SOURCE can point at an untouched admin source tree.
// The menu, submenus, menu items, Vue timers and vue-router are real. Only the tooltip
// painting/positioning layer is replaced; there is no browser, CSS layout or Popper here.
const assert = require('node:assert/strict')
const test = require('node:test')
const fs = require('node:fs')
const path = require('node:path')
const test = require('node:test')
const { build } = require('esbuild')
const { parse, compileScript } = require('@vue/compiler-sfc')
const { createRenderer, reactive, h, nextTick, markRaw } = require('vue')
const { createRouter, createMemoryHistory } = require('vue-router')
const admin = process.env.ZYT_TEST_ADMIN_SOURCE || path.resolve(__dirname, '..')
const treeDir = path.join(admin, 'src/layout/default/components/sidebar')
async function components(doc) {
const mod = { exports: {} }
const { createRenderer, reactive, h, nextTick, markRaw, computed, ref, watch, onMounted } = require('vue')
const { createRouter, createMemoryHistory, useRoute, useRouter } = require('vue-router')
const admin = path.resolve(process.env.ZYT_TEST_ADMIN_SOURCE || path.join(__dirname, '..'))
const menuPackage = path.join(path.dirname(require.resolve('element-plus/package.json')), 'es/components/menu/index.mjs')
async function components(document) {
const { outputFiles } = await build({
absWorkingDir: admin, stdin: {contents: `export { default as Dual } from '${treeDir}/dual-sidebar.vue'
export { default as Link } from '@/components/app-link/index.vue'`,resolveDir:admin},
alias: {'@':path.join(admin,'src')}, bundle:true, write:false, platform:'node',format:'cjs',
external:['vue','vue-router','@vue/shared','lodash'],define:{'import.meta.env.MODE':'"live-native"'},
plugins:[{name:'mounted-sfc',setup(b){
b.onResolve({filter:/^@\/stores\/modules\/(app|setting)$/},a=>({path:a.path.split('/').pop(),namespace:'store'}))
b.onLoad({filter:/.*/,namespace:'store'},a=>({contents:`import { inject } from 'vue'; export default ()=>inject('test-${a.path}')`}))
b.onLoad({filter:/\.vue$/},async a=>{
const s=fs.readFileSync(a.path,'utf8'), {descriptor,errors}=parse(s,{filename:a.path})
assert.deepEqual(errors,[])
let output=compileScript(descriptor,{id:path.basename(a.path),inlineTemplate:true}).content
if(a.path.endsWith('app-link/index.vue'))output="import {computed} from 'vue';\n"+output
return {contents:output,loader:'ts',resolveDir:path.dirname(a.path)}
})
}}]
absWorkingDir: admin,
stdin: {
contents: `export { default as Dual } from '@/layout/default/components/sidebar/dual-sidebar.vue'
export { default as Link } from '@/components/app-link/index.vue'
export { ElMenu, ElSubMenu, ElMenuItem } from ${JSON.stringify(menuPackage)}`,
resolveDir: admin
},
alias: { '@': path.join(admin, 'src') },
bundle: true, write: false, platform: 'node', format: 'cjs',
external: ['vue', 'vue-router', '@vue/shared', '@element-plus/icons-vue', 'lodash'],
define: { 'import.meta.env.MODE': '"live-native"' },
plugins: [{
name: 'mounted-sidebar',
setup(b) {
b.onResolve({ filter: /^@\/stores\/modules\/(app|setting)$/ }, a => ({
path: a.path.split('/').pop(), namespace: 'store'
}))
b.onLoad({ filter: /.*/, namespace: 'store' }, a => ({
contents: `import { inject } from 'vue'; export default () => inject('test-${a.path}')`
}))
b.onResolve({ filter: /\/tooltip\/index\.mjs$/ }, a => ({ path: a.path, namespace: 'paint' }))
b.onLoad({ filter: /.*/, namespace: 'paint' }, () => ({
// Visibility, teleport and placement come from the real ElSubMenu.
contents: `import { h, Fragment, Teleport } from 'vue'
export const ElTooltip = {
inheritAttrs: false, props: ['visible', 'teleported', 'placement', 'persistent'],
setup(props, {slots}) { return () => h(Fragment, [
slots.default?.(),
props.visible || props.persistent ? h(Teleport, {to: 'body', disabled: !props.teleported}, [
h('section', {hidden: !props.visible, 'data-placement': props.placement}, slots.content?.())
]) : null
]) }
}`
}))
b.onLoad({ filter: /\.vue$/ }, a => {
const { descriptor, errors } = parse(fs.readFileSync(a.path, 'utf8'), { filename: a.path })
assert.deepEqual(errors, [])
const { content } = compileScript(descriptor, { id: path.basename(a.path), inlineTemplate: true })
return { contents: content, loader: 'ts', resolveDir: path.dirname(a.path) }
})
}
}]
})
new Function('require','module','exports','document',outputFiles[0].text)(require,mod,mod.exports,doc)
// Make the same auto-imports as Vite available and allow VueUse to start its real
// hover timers. All document/window references are local to this bundle.
const bindings = { document, window: { document }, MouseEvent: Event, computed, ref, watch, onMounted, nextTick, useRoute, useRouter }
const mod = { exports: {} }
new Function('require', 'module', 'exports', ...Object.keys(bindings), outputFiles[0].text)(
require, mod, mod.exports, ...Object.values(bindings)
)
return mod.exports
}
function memoryHost() {
let focus
let active
class Node {
constructor(type,text=''){this.type=type;this.text=text;this.props={};this.children=[];this.parent=null;this.scrollTop=0;markRaw(this)}
nodes(){return this.children.flatMap(n=>[n,...n.nodes()])}
get childrenText(){return this.text+this.children.map(n=>n.childrenText).join('')}
matches(s){
s=s.trim()
if (s.startsWith('.'))return String(this.props.class||'').split(/\s+/).includes(s.slice(1))
if (s.startsWith('[')){const m=s.match(/^\[([\w-]+)(?:=["']?([^"'\]]+)["']?)?\]$/);return !!m && this.props[m[1]]!=null && (m[2]===undefined || String(this.props[m[1]])===m[2])}
return this.type===s
constructor(type, text = '') {
Object.assign(this, { type, text, props: {}, children: [], parent: null, scrollTop: 0, style: {} })
markRaw(this)
}
querySelectorAll(selector){return this.nodes().filter(n=>selector.split(',').some(s=>n.matches(s)))}
querySelector(s){return this.querySelectorAll(s)[0]??null}
get dataset(){return {key:this.props['data-key']}}
getAttribute(k){return this.props[k]??null}
getBoundingClientRect(){return {top:0,bottom:40,left:0,right:64,width:64,height:40}}
contains(n){return n===this||this.nodes().includes(n)}
focus(){focus=this}
scrollIntoView(){}
nodes() { return this.children.flatMap(n => [n, ...n.nodes()]) }
get visible() { return !this.props.hidden && (!this.parent || this.parent.visible) }
hasClass(name) { return String(this.props.class || '').split(/\s+/).includes(name) }
querySelector(s) { return this.nodes().find(n => n.hasClass(s.slice(1))) }
getBoundingClientRect() { return { top: 0, bottom: 40 } }
getAttribute(key) {
const value = this.props[key] ?? this.props[key.replace(/-([a-z])/g, (_, c) => c.toUpperCase())]
return value == null ? null : String(value)
}
focus() { active = this }
click() { fire(this, 'click') }
dispatchEvent(e) { fire(this, e.type) }
}
function detach(el){if(el.parent)el.parent.children.splice(el.parent.children.indexOf(el),1);el.parent=null}
const renderer=createRenderer({
createElement:t=>new Node(t),createText:t=>new Node('#text',t),createComment:t=>new Node('#comment',t),
parentNode:e=>e.parent,nextSibling:e=>e.parent?.children[e.parent.children.indexOf(e)+1]??null,
setText:(e,t)=>e.text=t,setElementText:(e,t)=>{e.children=[];e.text=t},
patchProp:(e,k,old,v)=>{e.props[k]=v},setScopeId:()=>{},
remove:detach,insert:(e,parent,anchor)=>{detach(e);e.parent=parent;const at=parent.children.indexOf(anchor);parent.children.splice(at<0?parent.children.length:at,0,e)},
insertStaticContent:(s,p,a)=>{const e=new Node('#static',s);e.parent=p;const i=p.children.indexOf(a);p.children.splice(i<0?p.children.length:i,0,e);return [e,e]}
function detach(el) {
if (el.parent) el.parent.children.splice(el.parent.children.indexOf(el), 1)
el.parent = null
}
function insert(el, parent, anchor) {
detach(el)
el.parent = parent
const at = parent.children.indexOf(anchor)
parent.children.splice(at < 0 ? parent.children.length : at, 0, el)
}
const body = new Node('body')
const root = new Node('app')
insert(root, body)
const renderer = createRenderer({
createElement: t => new Node(t), createText: t => new Node('#text', t), createComment: t => new Node('#comment', t),
parentNode: e => e.parent, nextSibling: e => e.parent?.children[e.parent.children.indexOf(e) + 1] ?? null,
setText: (e, t) => { e.text = t }, setElementText: (e, t) => { e.children = []; e.text = t },
patchProp: (e, k, old, v) => { e.props[k] = v }, setScopeId() {},
remove: detach, insert, querySelector: s => s === 'body' ? body : null,
insertStaticContent: (s, p, a) => { const el = new Node('#static', s); insert(el, p, a); return [el, el] }
})
return {renderer,root:new Node('root'),getFocus:()=>focus}
return { renderer, root, body, document: {
body, addEventListener() {}, get activeElement() { return active || body },
getElementById: id => body.nodes().find(el => el.props.id === id)
} }
}
async function settle(){await nextTick();await new Promise(r=>setImmediate(r));await nextTick()}
function click(el){
assert.ok(el)
const e={type:'click',currentTarget:el,target:el,button:0,preventDefault(){this.defaultPrevented=true}, defaultPrevented:false}
for (const fn of [].concat(el.props.onClick || [])) fn(e)
// Click bubbles through the real link + menu item regardless of their nesting order;
// mouseenter/leave do not bubble. No helper toggles popup state or calls router.push.
function fire(target, type, key) {
assert.ok(target, 'event target: ' + type)
const e = { type, target, key, button: 0, defaultPrevented: false, preventDefault() { this.defaultPrevented = true },
stopPropagation() { this.stopped = true } }
const prop = 'on' + type[0].toUpperCase() + type.slice(1)
for (let el = target; el; el = el.parent) {
e.currentTarget = el
for (const fn of [].concat(el.props[prop] || [])) fn(e)
if (!['click', 'keydown'].includes(type) || e.stopped) break
}
}
test('compact groups browse in place and links keep their query; only explicit expansion restores a column',async()=>{
const {renderer,root,getFocus} = memoryHost()
const {Dual,Link} = await components({body:root,get activeElement(){return getFocus() || root}})
const page=(path,title,query)=>({path,meta:{title,type:'C',query}})
const group=(path,title,children)=>({path,meta:{title,type:'M'},children})
const routes=reactive([group('/stats','数据统计',[group('reports','报表',[page('one','报表一'),page('two','报表二','?source=menu')]),page('summary','汇总')]),page('/solo','首页'),group('/links','帮助',[page('https://example.invalid/help','使用说明')])])
const appStore=reactive({isCollapsed:false,config:{},toggleCollapsed(v){this.isCollapsed=v??!this.isCollapsed}})
const settings=reactive({showLogo:false,sideWidth:230,isUniqueOpened:true})
const router=createRouter({history:createMemoryHistory(),routes:['/solo','/stats/reports/one','/stats/reports/two','/stats/summary'].map(path=>({path,component:{render:()=>null}}))})
await router.push('/solo');await router.isReady()
const app=renderer.createApp({render:()=>h(Dual,{routes})})
app.provide('test-app',appStore);app.provide('test-setting',settings)
app.component('app-link',Link);app.component('icon',{render:()=>h('svg')});app.component('image-contain',{render:()=>h('img')});app.use(router)
app.mount(root)
const controls=()=>root.nodes().filter(n=>n.type==='button'||n.type==='a')
const named=(name)=>controls().find(n=>n.props['aria-label']===name || n.props.title===name || n.childrenText.trim()===name)
const fixedPane=()=>root.nodes().some(n=>n.type==='nav'&&n.props['aria-label']==='二级菜单')
appStore.toggleCollapsed(true);await settle()
click(named('数据统计'));await settle()
assert.deepEqual({collapsed:appStore.isCollapsed,path:router.currentRoute.value.fullPath,pane:fixedPane()},
{collapsed:true,path:'/solo',pane:false},'a compact directory should neither expand nor navigate')
assert.equal(getFocus(),named('报表'),'focus enters the first child')
click(named('报表'));await settle();assert.ok(named('报表一'));assert.ok(named('报表二'))
click(named('报表二'));await settle()
assert.equal(router.currentRoute.value.fullPath,'/stats/reports/two?source=menu')
assert.ok(named('报表一'),'sibling remains reachable');assert.equal(appStore.isCollapsed,true)
click(named('返回上一级'));await settle();assert.equal(getFocus(),named('报表'),'back restores focus to the directory');assert.ok(named('汇总'));assert.ok(named('报表'));assert.equal(fixedPane(),false)
click(named('返回上一级'));await settle();assert.ok(named('首页'));assert.ok(named('数据统计'))
assert.equal(router.currentRoute.value.fullPath,'/stats/reports/two?source=menu','back is menu-only')
click(named('帮助'));await settle()
assert.equal(router.currentRoute.value.fullPath,'/stats/reports/two?source=menu')
assert.equal(named('使用说明').props.href,'https://example.invalid/help')
// Change the permission-projected tree in place; no orphaned group or link survives.
routes.pop();await settle();assert.ok(!named('使用说明'));assert.ok(!named('返回上一级'))
click(named('首页'));await settle();assert.equal(router.currentRoute.value.path,'/solo')
assert.equal(appStore.isCollapsed,true)
click(named('数据统计'));await settle();click(named('报表'));await settle()
await router.push('/stats/summary');await settle();assert.ok(named('汇总'));assert.ok(!named('报表二'))
assert.equal(appStore.isCollapsed,true)
appStore.toggleCollapsed(false);await settle();assert.equal(fixedPane(),true)
app.unmount()
async function settle() {
await nextTick(); await new Promise(resolve => setImmediate(resolve)); await nextTick()
}
async function until(check, message) {
const end = Date.now() + 3000
while (!check() && Date.now() < end) await new Promise(r => setTimeout(r, 20))
assert.ok(check(), message)
}
test('collapsed directories fly out on hover without drilling or navigation; leaves retain authorized targets', async t => {
const { renderer, root, body, document } = memoryHost()
const { Dual, Link, ElMenu, ElSubMenu, ElMenuItem } = await components(document)
const leaf = (path, title, query) => ({ path, meta: { title, type: 'C', query } })
const group = (path, title, children) => ({ path, meta: { title, type: 'M' }, children })
const routes = reactive([
group('/stats', '数据统计', [
group('reports', '报表', [
leaf('two', '报表二', '?source=menu'),
{ path: 'hidden', meta: { title: '不可见', type: 'C', hidden: true } },
{ path: 'edit', meta: { title: '按钮权限', type: 'A' } }
]),
leaf('summary', '汇总'),
group('empty', '无可见页面', [])
]),
leaf('/solo', '首页'),
group('/help', '帮助', [leaf('https://example.invalid/help', '使用说明')])
])
const appStore = reactive({ isCollapsed: false, config: {}, toggleCollapsed(v) { this.isCollapsed = v ?? !this.isCollapsed } })
const settings = reactive({ showLogo: false, sideWidth: 230, isUniqueOpened: true, sideTheme: 'light' })
const router = createRouter({
history: createMemoryHistory(),
routes: ['/solo', '/stats/reports/two', '/stats/summary'].map(path => ({ path, component: { render: () => null } }))
})
await router.push('/solo'); await router.isReady()
const app = renderer.createApp({ render: () => h(Dual, { routes }) })
app.provide('test-app', appStore); app.provide('test-setting', settings)
Object.entries({ ElMenu, ElSubMenu, ElMenuItem, AppLink: Link, Icon: { render: () => h('svg') },
ImageContain: { render: () => h('img') },
ElScrollbar: { render() { return h('div', this.$slots.default?.()) } }
}).forEach(([name, component]) => app.component(name, component))
app.use(router); app.mount(root)
t.after(() => app.unmount())
const named = (node, name) => node.props['aria-label'] === name || node.props.title === name
const find = predicate => body.nodes().find(n => n.visible && predicate(n))
const submenu = name => find(n => n.hasClass('el-sub-menu') && named(n, name))
const href = value => find(n => n.type === 'a' && n.props.href === value)
const column = () => find(n => n.type === 'nav' && named(n, '二级菜单'))
const unchanged = (path = '/solo') => {
assert.equal(router.currentRoute.value.fullPath, path)
assert.equal(appStore.isCollapsed, true)
assert.equal(column(), undefined, 'no fixed secondary column while folded')
}
const hover = async name => {
const el = submenu(name)
assert.ok(el, 'missing hoverable collapsed directory: ' + name)
fire(el, 'mouseenter')
await until(() => el.hasClass('is-opened'), name + ' should open on hover alone')
return el
}
appStore.toggleCollapsed(true); await settle()
const menu = root.querySelector('.el-menu--collapse')
assert.ok(menu, 'the folded rail must use a collapsed hover menu, not the old click-through list')
assert.ok(href('/solo')); assert.ok(!href('/stats/summary'))
const target = '/stats/reports/two?source=menu'
const keydown = async (el, key) => { fire(el, 'keydown', key); await settle() }
const directory = submenu('数据统计')
assert.equal(directory?.getAttribute('tabindex'), '0', 'directory can receive keyboard focus')
directory.focus()
await keydown(directory, 'Enter')
assert.equal(document.activeElement, submenu('报表'), 'Enter focuses the first child in its popup')
await keydown(document.activeElement, 'ArrowRight')
assert.equal(document.activeElement, href(target), 'Right opens the nested popup')
await keydown(document.activeElement, 'Escape')
assert.equal(document.activeElement, submenu('报表')); assert.ok(!href(target))
await keydown(document.activeElement, 'ArrowLeft')
assert.equal(document.activeElement, directory); assert.ok(!href('/stats/summary'))
unchanged()
const top = await hover('数据统计')
unchanged()
assert.ok(href('/solo'), 'hover leaves the first-level entries in place')
assert.ok(href('/stats/summary'), 'hover exposes a direct leaf without a click')
assert.equal(root.querySelector('.el-menu--popup'), undefined, 'first popup is outside the rail')
assert.ok(find(n => n.props['data-placement'] === 'right-start'), 'submenu requests a right-side popup')
fire(top.querySelector('.el-sub-menu__title'), 'click'); await settle(); unchanged()
assert.ok(!submenu('无可见页面'))
// Crossing from the rail into the floating panel must keep that panel open.
fire(top, 'mouseleave')
fire(find(n => n.hasClass('el-menu--popup-container')), 'mouseenter')
const nested = await hover('报表')
assert.ok(href(target)); assert.ok(!href('/stats/reports/hidden')); assert.ok(!href('/stats/reports/edit'))
unchanged()
fire(nested.querySelector('.el-sub-menu__title'), 'click'); await settle(); unchanged()
const link = href(target)
fire(link.querySelector('.el-menu-item') || link, 'click')
await settle(); unchanged(target)
assert.ok(!href(target), 'selecting a leaf dismisses the popup')
assert.ok(top.hasClass('is-active'), 'the selected route highlights its module')
const help = await hover('帮助')
const external = 'https://example.invalid/help'
assert.equal(href(external)?.props.target, '_blank')
assert.match(href(external).props.rel, /noopener/)
unchanged(target)
fire(help, 'mouseleave')
await until(() => !href(external), 'leaving the directory closes the flyout')
await hover('帮助')
routes.pop(); await settle()
assert.ok(!submenu('帮助')); assert.ok(!href(external), 'revoking permissions removes an already-open external link')
unchanged(target)
appStore.toggleCollapsed(false); await settle()
assert.ok(!root.querySelector('.el-menu--collapse'))
assert.ok(column(), 'explicit expansion restores the secondary column')
assert.equal(href(target)?.props['aria-current'], 'page')
})
@@ -42,3 +42,9 @@
- 原行为:在折叠栏点目录会强制展开,并且自动跳到该目录的第一个页面。现把“浏览目录”“打开页面”“展开布局”分开。展开时仍是原来的固定双列;收起时点目录只替换当前窄栏的内容,点具体页面才跳转。“返回上一级”只退菜单层级,不改变正在查看的页面。
- 桌面新版的顶栏按钮记住用户的折叠选择;手机抽屉和经典版不改这一偏好。刷新恢复的是折叠/展开选择,不持久化患者、页面数据或菜单目录内容。
- 已在内存中挂载实际 Vue 菜单,用真实 Vue Router 检查点击、焦点、层级返回、含参数链接、外链分组与权限树更新,并测试偏好恢复与存储不可用。浏览器脚本同步了宽度、鼠标/键盘和抽屉切换检查;因本机缺少专用 Headless Shell,未运行像素实测,未调用系统 Chrome。
### V7:折叠时恢复右侧悬浮子菜单(2026-12-02)
替代 V6 的窄栏逐级浏览。只改桌面新版的折叠态:窄栏仅保留一级标识,不显示“返回”、目录标题或多行子菜单文字。悬停一级目录打开右侧浮层,较深目录继续在侧边浮出。浏览目录不跳业务页;点击页面后按原路由与参数打开,栏保持收起。展开后仍使用固定双列。保留桌面折叠偏好、Logo 对齐、手机抽屉和经典版。
使用真实 Vue Router、Element Plus 和离线 DOM 验收悬停、嵌套浮层、选页与离开收起;没有调用系统 Chrome。真实浏览器的像素测量由 browser_sidebar.py 在装有专用 Headless Shell 的环境中执行,不把 DOM 仿真当截图验收。