添加测试信息

This commit is contained in:
yuding
2025-12-08 10:02:24 +08:00
parent 244891ceec
commit c112c87dad
21 changed files with 3355 additions and 2192 deletions

View File

@@ -1,16 +1,28 @@
import type { ButtonConfig } from '../../../index.type';
import type { BimEngine } from '../../../../../bim-engine';
/**
* 首页按钮配置
* 使用工厂函数模式,注入 engine 实例
*/
export const homeButton: ButtonConfig = {
id: 'home',
groupId: 'group-1',
type: 'button',
label: 'toolbar.home',
icon: '<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M4 21V9l8-6l8 6v12h-6v-7h-4v7z"/></svg>',
keepActive: true,
onClick: (button) => {
console.log('首页按钮被点击:', button.id);
}
export const createHomeButton = (engine: BimEngine): ButtonConfig => {
return {
id: 'home',
groupId: 'group-1',
type: 'button',
label: 'toolbar.home',
icon: '<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M4 21V9l8-6l8 6v12h-6v-7h-4v7z"/></svg>',
keepActive: true,
onClick: (button) => {
console.log('首页按钮被点击:', button.id);
// 演示:使用 engine 发送事件
// engine.dialog?.showInfoDialog()
engine.emit('ui:open-dialog', { id: 'home-info' });
// 或者直接调用 engine 的方法
// if (engine.engine) {
// engine.engine.loadModel('...');
// }
}
};
};

View File

@@ -12,7 +12,7 @@ export class Toolbar extends BimButtonGroup {
await super.init();
// 动态加载默认按钮配置
const { homeButton } = await import('./buttons/home');
const { createHomeButton } = await import('./buttons/home');
const { locationButton } = await import('./buttons/location');
const { walkMenuButton } = await import('./buttons/walk/walk-menu');
const { walkPersonButton } = await import('./buttons/walk/walk-person');
@@ -21,7 +21,14 @@ export class Toolbar extends BimButtonGroup {
const { infoButton } = await import('./buttons/info');
this.addGroup('group-1');
this.addButton(homeButton);
// 使用工厂函数创建按钮,并注入 engine
if (this.engine) {
this.addButton(createHomeButton(this.engine));
} else {
console.warn('[Toolbar] Engine not available when creating buttons.');
}
this.addButton(walkMenuButton);
this.addButton(walkPersonButton);
this.addButton(walkBirdButton);