fix(menu): refactor menu system to use pure config objects and fix submenu click events
This commit is contained in:
@@ -89,6 +89,30 @@ onMounted(() => {
|
||||
engine.value = new Engine(appContainer.value, { locale: 'zh-CN' });
|
||||
initEngine();
|
||||
console.log('Engine initialized:', engine.value);
|
||||
|
||||
// --- 新增:注册右键菜单 ---
|
||||
engine.value.rightKey.registerHandler((event: any) => {
|
||||
const { x, y } = event;
|
||||
return [
|
||||
{
|
||||
id: 'home',
|
||||
label: 'toolbar.home', // 使用国际化 Key
|
||||
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>',
|
||||
onClick: () => {
|
||||
console.log('Go Home');
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'log-pos',
|
||||
label: '打印坐标',
|
||||
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>',
|
||||
onClick: () => {
|
||||
console.log(`Clicked at: ${x}, ${y}`);
|
||||
alert(`Right clicked at: ${x}, ${y}`);
|
||||
}
|
||||
}
|
||||
];
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Init failed:', err);
|
||||
|
||||
Reference in New Issue
Block a user