iter: d25 menu 条目支持快捷键提示

This commit is contained in:
ui-arch-bot
2026-10-23 17:06:17 +08:00
parent 6efe3ab57b
commit 6a5e6623fe
9 changed files with 42 additions and 11 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ export function menu(props: MenuProps): HTMLElement {
disabled: item.disabled ? true : undefined,
onClick: () => pick(item),
},
item.label,
h('span', { class: 'ua-menu-label' }, item.label),
item.shortcut ? h('kbd', { class: 'ua-menu-key' }, item.shortcut) : null, // 快捷键只做提示,不拦截按键
) as HTMLButtonElement;
if (!item.disabled) focusables.push(btn); // 禁用项不参与导航
return btn;
+1
View File
@@ -103,6 +103,7 @@ export interface MenuItem {
label: string; // 条目文案
disabled?: boolean; // 禁用该条目:置灰且不参与键盘导航
danger?: boolean; // 危险操作条目:文案取 danger 语义色
shortcut?: string; // 右侧快捷键提示(仅展示,不绑定按键),如 '⌘K'
divider?: boolean; // 该条目渲染为分隔线(忽略 value / label)
}