refactor: 重构终端底层渲染逻辑

Refs #28
This commit is contained in:
Baobhan Sith
2025-05-12 20:29:55 +08:00
parent 35717dea47
commit 62717ef7ef
2 changed files with 63 additions and 49 deletions
@@ -125,6 +125,7 @@ onMounted(() => {
subscribeToWorkspaceEvents('terminal:resize', handleTerminalResize);
subscribeToWorkspaceEvents('terminal:ready', handleTerminalReady);
subscribeToWorkspaceEvents('terminal:clear', handleClearTerminal);
subscribeToWorkspaceEvents('terminal:scrollToBottomRequest', handleScrollToBottomRequest);
subscribeToWorkspaceEvents('editor:closeTab', (payload) => handleCloseEditorTab(payload.tabId));
subscribeToWorkspaceEvents('editor:activateTab', (payload) => handleActivateEditorTab(payload.tabId));
@@ -167,6 +168,7 @@ onBeforeUnmount(() => {
unsubscribeFromWorkspaceEvents('terminal:resize', handleTerminalResize);
unsubscribeFromWorkspaceEvents('terminal:ready', handleTerminalReady);
unsubscribeFromWorkspaceEvents('terminal:clear', handleClearTerminal);
unsubscribeFromWorkspaceEvents('terminal:scrollToBottomRequest', handleScrollToBottomRequest);
unsubscribeFromWorkspaceEvents('editor:closeTab', (payload) => handleCloseEditorTab(payload.tabId));
unsubscribeFromWorkspaceEvents('editor:activateTab', (payload) => handleActivateEditorTab(payload.tabId));
@@ -449,6 +451,18 @@ const handleClearTerminal = () => { // +++ 修改 +++
}
};
// +++ 处理滚动到底部请求 +++
const handleScrollToBottomRequest = (payload: { sessionId: string }) => {
const session = sessionStore.sessions.get(payload.sessionId);
const terminalManager = session?.terminalManager as (SshTerminalInstance | undefined);
if (terminalManager?.terminalInstance?.value) {
console.log(`[WorkspaceView] Scrolling to bottom for session ${payload.sessionId}`);
terminalManager.terminalInstance.value.scrollToBottom();
} else {
console.warn(`[WorkspaceView] Cannot scroll to bottom for session ${payload.sessionId}, terminal instance not found.`);
}
};
// Removed computed properties for search results, will pass manager directly
// --- 编辑器操作处理 (用于 FileEditorContainer) ---
const handleCloseEditorTab = (tabId: string) => {