Skip to content

请问一下可以设置打开编辑器,默认选中左侧边栏指定的某一项吗 #1692

Answered by bytemain
bytemain asked this question in Q&A
Discussion options

You must be logged in to vote

这一块在 layout 配置里应该是属于 left 插槽,IMainLayoutService.getTabbarService('left') 就可以拿到这个 tabbar 的控制权了。
可以设置选中哪一个 item。

import { IMainLayoutService } from '@opensumi/ide-main-layout';
@Injectable()
class XXX {
  @Autowired(IMainLayoutService)
  mainLayoutService: IMainLayoutService;

  func() {
     const tabbarService = this.mainLayoutService.getTabbarService('left');
     tabbarService.currentContainerId = 'explorer';
  }
}

这里的 explorer 可以换成你想要的。

插件注册视图的时候都会有一个 id,可以去看这个插件的 package.json。里面会声明它注册的按钮。

直接看 dom 节点也能看出来:

Replies: 1 comment 1 reply

Comment options

bytemain
Sep 21, 2022
Maintainer Author

You must be logged in to vote
1 reply
@Aaaaash
Comment options

Answer selected by bytemain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants