Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 添加菜单错误 #238

Open
yangzehan opened this issue Nov 29, 2024 · 1 comment
Open

[BUG] 添加菜单错误 #238

yangzehan opened this issue Nov 29, 2024 · 1 comment
Labels

Comments

@yangzehan
Copy link

我使用示例仓库 增加了几个菜单

import {Autowired} from '@opensumi/di';
import {CommandContribution, CommandRegistry, CommandService, Domain} from '@opensumi/ide-core-browser';
import {IMenuRegistry, MenuContribution} from '@opensumi/ide-core-browser/lib/menu/next';

const TESTCOMMAND = {
id: 'ttttttt',
}

@Domain(CommandContribution, MenuContribution)
export class RegisterMenuContribution implements CommandContribution, MenuContribution {

@Autowired(CommandService)
private readonly commandService: CommandService;

registerMenus(registry: IMenuRegistry): void {
    // 在 Menubar 区域注册一个新的菜单
    registry.registerMenubarItem("TestMenuBarId", {
        label: 'OpenSumi',
        order: 0
    });
    // 注册二级菜单
    const SubMenuId = 'test/next';
    registry.registerMenuItem("TestMenuBarId", {
        submenu: SubMenuId,
        label: 'Hover Me',
        group: '1_second',
    });

}

registerCommands(commands: CommandRegistry): void {
    commands.registerCommand(
        {id: TESTCOMMAND.id},
        {
            execute: () => {
                console.log('test command')
            },
        })
    // 解绑 重命名命令
    commands.unregisterCommand('terminal.split')
    commands.registerCommand({id: 'terminal.split'})
    this.commandService.executeCommand(TESTCOMMAND.id)


}

}

引入

@Injectable()
export class StartupModule extends BrowserModule {
providers: Provider[] = [AlexAppContribution, RegisterMenuContribution];
}

npm run code
image
无法 展开第二个菜单

@yangzehan
Copy link
Author

image
貌似需要加上label: 'Test Command' 这个属性才可以
image
示例仓库里的registerMenu.ts 是不是有点问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant