From 6bd1682ffe1bd1bfe807c4b115d2ac4bdcbdb950 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Tue, 13 May 2025 17:37:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=90=8E=E7=9A=84=E7=8A=B6=E6=80=81=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/websocket/connection.ts | 6 ++++- .../src/websocket/handlers/ssh.handler.ts | 14 +++++++++++ .../settings/WorkspaceSettingsSection.vue | 21 ++++------------ .../settings/useWorkspaceSettings.ts | 14 +++++------ .../frontend/src/stores/settings.store.ts | 24 +++++++++---------- 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/packages/backend/src/websocket/connection.ts b/packages/backend/src/websocket/connection.ts index 23b9c0a..43fb293 100644 --- a/packages/backend/src/websocket/connection.ts +++ b/packages/backend/src/websocket/connection.ts @@ -33,7 +33,8 @@ import { handleRdpProxyConnection } from './handlers/rdp.handler'; import { handleSshConnect, handleSshInput, - handleSshResize + handleSshResize, + handleSshResumeSuccess } from './handlers/ssh.handler'; import { handleDockerGetStatus, @@ -257,6 +258,9 @@ export function initializeConnectionHandler(wss: WebSocketServer, sshSuspendServ // console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_SUSPEND_RESUMED_NOTIF 前已关闭 (会话 ${newFrontendSessionId})。`); } + // 在成功恢复并通知前端后,调用 handleSshResumeSuccess 启动状态监控 + handleSshResumeSuccess(newFrontendSessionId); + } else { // console.warn(`[WebSocket Handler][${type}] sshSuspendService.resumeSession 返回 null,无法恢复会话 ${suspendSessionId}。`); throw new Error('服务未能恢复会话,或会话不存在/状态不正确。'); diff --git a/packages/backend/src/websocket/handlers/ssh.handler.ts b/packages/backend/src/websocket/handlers/ssh.handler.ts index 6ddc6db..2fedf17 100644 --- a/packages/backend/src/websocket/handlers/ssh.handler.ts +++ b/packages/backend/src/websocket/handlers/ssh.handler.ts @@ -251,4 +251,18 @@ export function handleSshResize(ws: AuthenticatedWebSocket, payload: any): void console.warn(`WebSocket: 会话 ${sessionId} 收到调整大小请求,但 Shell 尚未就绪或流不存在 (isShellReady: ${state.isShellReady})。尺寸将不会立即应用。`); // A more robust solution would queue the resize or store it in ClientState to be applied later. } +} + +// 处理会话恢复后的状态监控启动 +export function handleSshResumeSuccess(sessionId: string): void { + console.log(`[状态DEBUG] [SSH Handler ${sessionId}] 会话恢复成功,准备启动状态轮询`); + const state = clientStates.get(sessionId); + if (state && state.sshClient) { + statusMonitorService.startStatusPolling(sessionId); + console.log(`[状态DEBUG] [SSH Handler ${sessionId}] 已为恢复的会话调用 startStatusPolling`); + // 如果 Docker 状态也需要恢复,可以在这里添加 + // startDockerStatusPolling(sessionId); + } else { + console.error(`[状态DEBUG] [SSH Handler ${sessionId}] 无法为恢复的会话启动状态轮询:未找到会话状态或 SSH 客户端。`); + } } \ No newline at end of file diff --git a/packages/frontend/src/components/settings/WorkspaceSettingsSection.vue b/packages/frontend/src/components/settings/WorkspaceSettingsSection.vue index 59f05b4..cbd7d56 100644 --- a/packages/frontend/src/components/settings/WorkspaceSettingsSection.vue +++ b/packages/frontend/src/components/settings/WorkspaceSettingsSection.vue @@ -239,58 +239,47 @@ const { t } = useI18n(); const { popupEditorEnabled, - // popupEditorLoading, // Not directly used by template if button has its own loading state management popupEditorMessage, popupEditorSuccess, handleUpdatePopupEditorSetting, shareTabsEnabled, - // shareTabsLoading, shareTabsMessage, shareTabsSuccess, handleUpdateShareTabsSetting, autoCopyEnabled, - // autoCopyLoading, autoCopyMessage, autoCopySuccess, handleUpdateAutoCopySetting, workspaceSidebarPersistentEnabled, - // workspaceSidebarPersistentLoading, workspaceSidebarPersistentMessage, workspaceSidebarPersistentSuccess, handleUpdateWorkspaceSidebarSetting, commandInputSyncTargetLocal, - // commandInputSyncLoading, commandInputSyncMessage, commandInputSyncSuccess, handleUpdateCommandInputSyncTarget, showConnectionTagsLocal, - // showConnectionTagsLoading, showConnectionTagsMessage, showConnectionTagsSuccess, handleUpdateShowConnectionTags, showQuickCommandTagsLocal, - // showQuickCommandTagsLoading, showQuickCommandTagsMessage, showQuickCommandTagsSuccess, handleUpdateShowQuickCommandTags, terminalScrollbackLimitLocal, - // terminalScrollbackLimitLoading, terminalScrollbackLimitMessage, terminalScrollbackLimitSuccess, handleUpdateTerminalScrollbackLimit, fileManagerShowDeleteConfirmationLocal, - // fileManagerShowDeleteConfirmationLoading, fileManagerShowDeleteConfirmationMessage, fileManagerShowDeleteConfirmationSuccess, handleUpdateFileManagerDeleteConfirmation, - terminalEnableRightClickPasteLocal, // NEW - terminalEnableRightClickPasteLoading, // NEW (Not used in template, but available) - terminalEnableRightClickPasteMessage, // NEW - terminalEnableRightClickPasteSuccess, // NEW - handleUpdateTerminalRightClickPasteSetting, // NEW - // Popup File Manager + terminalEnableRightClickPasteLocal, + terminalEnableRightClickPasteLoading, + terminalEnableRightClickPasteMessage, + terminalEnableRightClickPasteSuccess, + handleUpdateTerminalRightClickPasteSetting, showPopupFileManagerLocal, - // showPopupFileManagerLoading, // Not used showPopupFileManagerMessage, showPopupFileManagerSuccess, handleUpdateShowPopupFileManager, diff --git a/packages/frontend/src/composables/settings/useWorkspaceSettings.ts b/packages/frontend/src/composables/settings/useWorkspaceSettings.ts index d44b23d..5b11fde 100644 --- a/packages/frontend/src/composables/settings/useWorkspaceSettings.ts +++ b/packages/frontend/src/composables/settings/useWorkspaceSettings.ts @@ -17,7 +17,7 @@ export function useWorkspaceSettings() { showQuickCommandTagsBoolean, terminalScrollbackLimitNumber, fileManagerShowDeleteConfirmationBoolean, - terminalEnableRightClickPasteBoolean, // NEW + terminalEnableRightClickPasteBoolean, showPopupFileManagerBoolean, // +++ Import the new getter +++ } = storeToRefs(settingsStore); @@ -296,7 +296,7 @@ export function useWorkspaceSettings() { watch(showQuickCommandTagsBoolean, (newValue) => { showQuickCommandTagsLocal.value = newValue; }, { immediate: true }); watch(terminalScrollbackLimitNumber, (newValue) => { terminalScrollbackLimitLocal.value = newValue; }, { immediate: true }); watch(fileManagerShowDeleteConfirmationBoolean, (newValue) => { fileManagerShowDeleteConfirmationLocal.value = newValue; }, { immediate: true }); - watch(terminalEnableRightClickPasteBoolean, (newValue) => { terminalEnableRightClickPasteLocal.value = newValue; }, { immediate: true }); // NEW + watch(terminalEnableRightClickPasteBoolean, (newValue) => { terminalEnableRightClickPasteLocal.value = newValue; }, { immediate: true }); watch(showPopupFileManagerBoolean, (newValue) => { showPopupFileManagerLocal.value = newValue; }, { immediate: true }); // +++ Watch for popup file manager +++ @@ -355,11 +355,11 @@ export function useWorkspaceSettings() { fileManagerShowDeleteConfirmationSuccess, handleUpdateFileManagerDeleteConfirmation, - terminalEnableRightClickPasteLocal, // NEW - terminalEnableRightClickPasteLoading, // NEW - terminalEnableRightClickPasteMessage, // NEW - terminalEnableRightClickPasteSuccess, // NEW - handleUpdateTerminalRightClickPasteSetting, // NEW + terminalEnableRightClickPasteLocal, + terminalEnableRightClickPasteLoading, + terminalEnableRightClickPasteMessage, + terminalEnableRightClickPasteSuccess, + handleUpdateTerminalRightClickPasteSetting, // Popup File Manager showPopupFileManagerLocal, diff --git a/packages/frontend/src/stores/settings.store.ts b/packages/frontend/src/stores/settings.store.ts index ebc7007..a2264ab 100644 --- a/packages/frontend/src/stores/settings.store.ts +++ b/packages/frontend/src/stores/settings.store.ts @@ -391,12 +391,12 @@ export const useSettingsStore = defineStore('settings', () => { 'ipBlacklistEnabled', 'dashboardSortBy', 'dashboardSortOrder', - 'showConnectionTags', // NEW - 'showQuickCommandTags', // NEW - 'layoutLocked', // NEW - 'terminalScrollbackLimit', // NEW - 'fileManagerShowDeleteConfirmation', // NEW - 'terminalEnableRightClickPaste' // NEW + 'showConnectionTags', + 'showQuickCommandTags', + 'layoutLocked', + 'terminalScrollbackLimit', + 'fileManagerShowDeleteConfirmation', + 'terminalEnableRightClickPaste' ]; if (!allowedKeys.includes(key)) { console.error(`[SettingsStore] 尝试更新不允许的设置键: ${key}`); @@ -486,12 +486,12 @@ export const useSettingsStore = defineStore('settings', () => { 'ipBlacklistEnabled', 'dashboardSortBy', 'dashboardSortOrder', - 'showConnectionTags', // NEW - 'showQuickCommandTags', // NEW - 'layoutLocked', // NEW - 'terminalScrollbackLimit', // NEW - 'fileManagerShowDeleteConfirmation', // NEW - 'terminalEnableRightClickPaste' // NEW + 'showConnectionTags', + 'showQuickCommandTags', + 'layoutLocked', + 'terminalScrollbackLimit', + 'fileManagerShowDeleteConfirmation', + 'terminalEnableRightClickPaste' ]; const filteredUpdates: Partial = {}; let languageUpdate: string | undefined = undefined;