feat: add collapsible workspace sidebar supporting Local PC, SSH, and Serial Dev Boards
This commit is contained in:
+35
-6
@@ -1,5 +1,6 @@
|
||||
import { themeManager } from './theme-manager.js';
|
||||
import { TabManager } from './tab-manager.js';
|
||||
import { WorkspaceManager } from './workspace-manager.js';
|
||||
import { CommandPalette } from './command-palette.js';
|
||||
import { SettingsModal } from './settings.js';
|
||||
|
||||
@@ -8,15 +9,13 @@ class TerminalApp {
|
||||
this.initElements();
|
||||
this.initTheme();
|
||||
this.initTabManager();
|
||||
this.initWorkspaceManager();
|
||||
this.initModals();
|
||||
this.initSearch();
|
||||
this.initWindowControls();
|
||||
this.initIpcListeners();
|
||||
this.initKeyboardShortcuts();
|
||||
this.initStatusBar();
|
||||
|
||||
// 创建初始标签页
|
||||
this.tabManager.createTab();
|
||||
}
|
||||
|
||||
initElements() {
|
||||
@@ -63,7 +62,21 @@ class TerminalApp {
|
||||
});
|
||||
|
||||
this.newTabBtn.addEventListener('click', () => {
|
||||
this.tabManager.createTab();
|
||||
const activeWs = this.workspaceManager ? this.workspaceManager.getActiveWorkspace() : null;
|
||||
const spawnOpts = this.workspaceManager ? this.workspaceManager.getSpawnOptions(activeWs?.id) : {};
|
||||
this.tabManager.createTab({
|
||||
workspaceId: activeWs?.id,
|
||||
title: spawnOpts.title,
|
||||
cwd: spawnOpts.cwd,
|
||||
shell: spawnOpts.shell,
|
||||
args: spawnOpts.args,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initWorkspaceManager() {
|
||||
this.workspaceManager = new WorkspaceManager({
|
||||
tabManager: this.tabManager,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,6 +86,7 @@ class TerminalApp {
|
||||
input: this.commandPaletteInput,
|
||||
list: this.commandPaletteList,
|
||||
tabManager: this.tabManager,
|
||||
workspaceManager: this.workspaceManager,
|
||||
onOpenSettings: () => this.settings.open(),
|
||||
onToggleSearch: () => this.toggleSearch(),
|
||||
});
|
||||
@@ -211,10 +225,25 @@ class TerminalApp {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ctrl+Shift+T: 新建标签
|
||||
// Ctrl+B: 切换左侧工作区侧边栏
|
||||
if (e.ctrlKey && e.key.toLowerCase() === 'b') {
|
||||
e.preventDefault();
|
||||
this.workspaceManager?.toggleSidebar();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ctrl+Shift+T: 新建当前工作区标签页
|
||||
if (e.ctrlKey && e.shiftKey && e.key.toLowerCase() === 't') {
|
||||
e.preventDefault();
|
||||
this.tabManager.createTab();
|
||||
const activeWs = this.workspaceManager ? this.workspaceManager.getActiveWorkspace() : null;
|
||||
const spawnOpts = this.workspaceManager ? this.workspaceManager.getSpawnOptions(activeWs?.id) : {};
|
||||
this.tabManager.createTab({
|
||||
workspaceId: activeWs?.id,
|
||||
title: spawnOpts.title,
|
||||
cwd: spawnOpts.cwd,
|
||||
shell: spawnOpts.shell,
|
||||
args: spawnOpts.args,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user