style(menu): remove default list style bullets from menu
This commit is contained in:
@@ -3,8 +3,6 @@ import { BimEngine } from '../bim-engine';
|
||||
import { BimRightKey } from '../components/right-key';
|
||||
import { BimMenu } from '../components/menu';
|
||||
import { MenuItemConfig } from '../components/menu/item';
|
||||
import { infoMenuButton } from '../components/menu/buttons/info';
|
||||
import { homeMenuButton } from '../components/menu/buttons/home';
|
||||
|
||||
/**
|
||||
* 右键菜单管理器 (RightKeyManager)
|
||||
@@ -18,7 +16,7 @@ export class RightKeyManager extends BimComponent {
|
||||
private rightKeyPanel: BimRightKey;
|
||||
|
||||
// 存储注册的上下文处理器
|
||||
// 每个处理<E5A484><E79086><EFBFBD>接收鼠标事件,返回一组菜单项(如果没有对应菜单则返回 null)
|
||||
// 每个处理<E5A484><E79086>接收鼠标事件,返回一组菜单项(如果没有对应菜单则返回 null)
|
||||
private contextHandlers: Array<(e: MouseEvent) => MenuItemConfig[] | null> = [];
|
||||
|
||||
constructor(engine: BimEngine, container: HTMLElement) {
|
||||
@@ -55,7 +53,7 @@ export class RightKeyManager extends BimComponent {
|
||||
* @param x 屏幕 X 坐标
|
||||
* @param y 屏幕 Y 坐标
|
||||
* @param items 菜单项列表
|
||||
* @param groupOrder 可<EFBFBD><EFBFBD>的分组顺序
|
||||
* @param groupOrder 可选的分组顺序
|
||||
*/
|
||||
public showMenu(x: number, y: number, items: MenuItemConfig[], groupOrder?: string[]): void {
|
||||
if (!items || items.length === 0) return;
|
||||
@@ -84,11 +82,20 @@ export class RightKeyManager extends BimComponent {
|
||||
private handleContextMenu = (e: MouseEvent): void => {
|
||||
// 阻止浏览器默认的右键菜单
|
||||
e.preventDefault();
|
||||
let items: MenuItemConfig[] = [];
|
||||
items.push(infoMenuButton(this.engine))
|
||||
items.push(infoMenuButton(this.engine))
|
||||
items.push(infoMenuButton(this.engine))
|
||||
items.push(homeMenuButton(this.engine))
|
||||
|
||||
// 1. 确定上下文项
|
||||
// 遍历所有注册的处理器,找到第一个返回非空结果的处理器
|
||||
// 这种责任链模式允许插件优先处理特定对象的右键
|
||||
let items: MenuItemConfig[] | null = null;
|
||||
for (const handler of this.contextHandlers) {
|
||||
const result = handler(e);
|
||||
if (result && result.length > 0) {
|
||||
if (!items) items = [];
|
||||
items = items.concat(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 如果有菜单项,则显示
|
||||
if (items && items.length > 0) {
|
||||
this.showMenu(e.clientX, e.clientY, items);
|
||||
} else {
|
||||
@@ -96,4 +103,4 @@ export class RightKeyManager extends BimComponent {
|
||||
this.hide();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user