style(menu): remove default list style bullets from menu

This commit is contained in:
yuding
2025-12-10 09:42:05 +08:00
parent 9ae1d9d809
commit 9903a71015
15 changed files with 1668 additions and 1683 deletions

View File

@@ -1,6 +1,9 @@
import { Engine, type EngineOptions, type ModelLoadOptions } from '../components/engine';
import { BimComponent } from '../core/component';
import type { BimEngine } from '../bim-engine';
import { RightKeyManager } from './right-key-manager';
import { infoMenuButton } from '../components/menu/buttons/info';
import { homeMenuButton } from '../components/menu/buttons/home';
/**
* 3D 引擎管理器
@@ -13,6 +16,8 @@ export class EngineManager extends BimComponent {
/** 3D 引擎组件实例 */
private engineInstance: Engine | null = null;
public rightKey: RightKeyManager | null = null; // 右键菜单管理器
/**
* 构造函数
* @param engine 引擎实例
@@ -47,6 +52,17 @@ export class EngineManager extends BimComponent {
// 调用组件的 init 方法初始化引擎
this.engineInstance.init();
// 初始化右键 (移到 return 之前)
this.rightKey = new RightKeyManager(this.engine, this.container);
// 注册默认右键菜单
this.rightKey.registerHandler((_e) => {
return [
infoMenuButton(this.engine),
homeMenuButton(this.engine)
];
});
return this.engineInstance.isInitialized();
} catch (error) {
console.error('[EngineManager] Failed to initialize 3D engine:', error);
@@ -54,9 +70,8 @@ export class EngineManager extends BimComponent {
return false;
}
}
/**
* 检 3D 引擎是否已初始化
* 检<EFBFBD><EFBFBD><EFBFBD> 3D 引擎是否已初始化
*/
public isInitialized(): boolean {
return this.engineInstance !== null && this.engineInstance.isInitialized();
@@ -95,6 +110,10 @@ export class EngineManager extends BimComponent {
this.engineInstance.destroy();
this.engineInstance = null;
}
if (this.rightKey) {
this.rightKey.destroy();
this.rightKey = null;
}
}
}

View File

@@ -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();
}
};
}
}