fix: 处理会话恢复后的状态监控启动

This commit is contained in:
Baobhan Sith
2025-05-13 17:37:01 +08:00
parent 2910951c21
commit 6bd1682ffe
5 changed files with 43 additions and 36 deletions
+5 -1
View File
@@ -33,7 +33,8 @@ import { handleRdpProxyConnection } from './handlers/rdp.handler';
import { import {
handleSshConnect, handleSshConnect,
handleSshInput, handleSshInput,
handleSshResize handleSshResize,
handleSshResumeSuccess
} from './handlers/ssh.handler'; } from './handlers/ssh.handler';
import { import {
handleDockerGetStatus, handleDockerGetStatus,
@@ -257,6 +258,9 @@ export function initializeConnectionHandler(wss: WebSocketServer, sshSuspendServ
// console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_SUSPEND_RESUMED_NOTIF 前已关闭 (会话 ${newFrontendSessionId})。`); // console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_SUSPEND_RESUMED_NOTIF 前已关闭 (会话 ${newFrontendSessionId})。`);
} }
// 在成功恢复并通知前端后,调用 handleSshResumeSuccess 启动状态监控
handleSshResumeSuccess(newFrontendSessionId);
} else { } else {
// console.warn(`[WebSocket Handler][${type}] sshSuspendService.resumeSession 返回 null,无法恢复会话 ${suspendSessionId}。`); // console.warn(`[WebSocket Handler][${type}] sshSuspendService.resumeSession 返回 null,无法恢复会话 ${suspendSessionId}。`);
throw new Error('服务未能恢复会话,或会话不存在/状态不正确。'); throw new Error('服务未能恢复会话,或会话不存在/状态不正确。');
@@ -252,3 +252,17 @@ export function handleSshResize(ws: AuthenticatedWebSocket, payload: any): void
// A more robust solution would queue the resize or store it in ClientState to be applied later. // 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 客户端。`);
}
}
@@ -239,58 +239,47 @@ const { t } = useI18n();
const { const {
popupEditorEnabled, popupEditorEnabled,
// popupEditorLoading, // Not directly used by template if button has its own loading state management
popupEditorMessage, popupEditorMessage,
popupEditorSuccess, popupEditorSuccess,
handleUpdatePopupEditorSetting, handleUpdatePopupEditorSetting,
shareTabsEnabled, shareTabsEnabled,
// shareTabsLoading,
shareTabsMessage, shareTabsMessage,
shareTabsSuccess, shareTabsSuccess,
handleUpdateShareTabsSetting, handleUpdateShareTabsSetting,
autoCopyEnabled, autoCopyEnabled,
// autoCopyLoading,
autoCopyMessage, autoCopyMessage,
autoCopySuccess, autoCopySuccess,
handleUpdateAutoCopySetting, handleUpdateAutoCopySetting,
workspaceSidebarPersistentEnabled, workspaceSidebarPersistentEnabled,
// workspaceSidebarPersistentLoading,
workspaceSidebarPersistentMessage, workspaceSidebarPersistentMessage,
workspaceSidebarPersistentSuccess, workspaceSidebarPersistentSuccess,
handleUpdateWorkspaceSidebarSetting, handleUpdateWorkspaceSidebarSetting,
commandInputSyncTargetLocal, commandInputSyncTargetLocal,
// commandInputSyncLoading,
commandInputSyncMessage, commandInputSyncMessage,
commandInputSyncSuccess, commandInputSyncSuccess,
handleUpdateCommandInputSyncTarget, handleUpdateCommandInputSyncTarget,
showConnectionTagsLocal, showConnectionTagsLocal,
// showConnectionTagsLoading,
showConnectionTagsMessage, showConnectionTagsMessage,
showConnectionTagsSuccess, showConnectionTagsSuccess,
handleUpdateShowConnectionTags, handleUpdateShowConnectionTags,
showQuickCommandTagsLocal, showQuickCommandTagsLocal,
// showQuickCommandTagsLoading,
showQuickCommandTagsMessage, showQuickCommandTagsMessage,
showQuickCommandTagsSuccess, showQuickCommandTagsSuccess,
handleUpdateShowQuickCommandTags, handleUpdateShowQuickCommandTags,
terminalScrollbackLimitLocal, terminalScrollbackLimitLocal,
// terminalScrollbackLimitLoading,
terminalScrollbackLimitMessage, terminalScrollbackLimitMessage,
terminalScrollbackLimitSuccess, terminalScrollbackLimitSuccess,
handleUpdateTerminalScrollbackLimit, handleUpdateTerminalScrollbackLimit,
fileManagerShowDeleteConfirmationLocal, fileManagerShowDeleteConfirmationLocal,
// fileManagerShowDeleteConfirmationLoading,
fileManagerShowDeleteConfirmationMessage, fileManagerShowDeleteConfirmationMessage,
fileManagerShowDeleteConfirmationSuccess, fileManagerShowDeleteConfirmationSuccess,
handleUpdateFileManagerDeleteConfirmation, handleUpdateFileManagerDeleteConfirmation,
terminalEnableRightClickPasteLocal, // NEW terminalEnableRightClickPasteLocal,
terminalEnableRightClickPasteLoading, // NEW (Not used in template, but available) terminalEnableRightClickPasteLoading,
terminalEnableRightClickPasteMessage, // NEW terminalEnableRightClickPasteMessage,
terminalEnableRightClickPasteSuccess, // NEW terminalEnableRightClickPasteSuccess,
handleUpdateTerminalRightClickPasteSetting, // NEW handleUpdateTerminalRightClickPasteSetting,
// Popup File Manager
showPopupFileManagerLocal, showPopupFileManagerLocal,
// showPopupFileManagerLoading, // Not used
showPopupFileManagerMessage, showPopupFileManagerMessage,
showPopupFileManagerSuccess, showPopupFileManagerSuccess,
handleUpdateShowPopupFileManager, handleUpdateShowPopupFileManager,
@@ -17,7 +17,7 @@ export function useWorkspaceSettings() {
showQuickCommandTagsBoolean, showQuickCommandTagsBoolean,
terminalScrollbackLimitNumber, terminalScrollbackLimitNumber,
fileManagerShowDeleteConfirmationBoolean, fileManagerShowDeleteConfirmationBoolean,
terminalEnableRightClickPasteBoolean, // NEW terminalEnableRightClickPasteBoolean,
showPopupFileManagerBoolean, // +++ Import the new getter +++ showPopupFileManagerBoolean, // +++ Import the new getter +++
} = storeToRefs(settingsStore); } = storeToRefs(settingsStore);
@@ -296,7 +296,7 @@ export function useWorkspaceSettings() {
watch(showQuickCommandTagsBoolean, (newValue) => { showQuickCommandTagsLocal.value = newValue; }, { immediate: true }); watch(showQuickCommandTagsBoolean, (newValue) => { showQuickCommandTagsLocal.value = newValue; }, { immediate: true });
watch(terminalScrollbackLimitNumber, (newValue) => { terminalScrollbackLimitLocal.value = newValue; }, { immediate: true }); watch(terminalScrollbackLimitNumber, (newValue) => { terminalScrollbackLimitLocal.value = newValue; }, { immediate: true });
watch(fileManagerShowDeleteConfirmationBoolean, (newValue) => { fileManagerShowDeleteConfirmationLocal.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 +++ watch(showPopupFileManagerBoolean, (newValue) => { showPopupFileManagerLocal.value = newValue; }, { immediate: true }); // +++ Watch for popup file manager +++
@@ -355,11 +355,11 @@ export function useWorkspaceSettings() {
fileManagerShowDeleteConfirmationSuccess, fileManagerShowDeleteConfirmationSuccess,
handleUpdateFileManagerDeleteConfirmation, handleUpdateFileManagerDeleteConfirmation,
terminalEnableRightClickPasteLocal, // NEW terminalEnableRightClickPasteLocal,
terminalEnableRightClickPasteLoading, // NEW terminalEnableRightClickPasteLoading,
terminalEnableRightClickPasteMessage, // NEW terminalEnableRightClickPasteMessage,
terminalEnableRightClickPasteSuccess, // NEW terminalEnableRightClickPasteSuccess,
handleUpdateTerminalRightClickPasteSetting, // NEW handleUpdateTerminalRightClickPasteSetting,
// Popup File Manager // Popup File Manager
showPopupFileManagerLocal, showPopupFileManagerLocal,
+12 -12
View File
@@ -391,12 +391,12 @@ export const useSettingsStore = defineStore('settings', () => {
'ipBlacklistEnabled', 'ipBlacklistEnabled',
'dashboardSortBy', 'dashboardSortBy',
'dashboardSortOrder', 'dashboardSortOrder',
'showConnectionTags', // NEW 'showConnectionTags',
'showQuickCommandTags', // NEW 'showQuickCommandTags',
'layoutLocked', // NEW 'layoutLocked',
'terminalScrollbackLimit', // NEW 'terminalScrollbackLimit',
'fileManagerShowDeleteConfirmation', // NEW 'fileManagerShowDeleteConfirmation',
'terminalEnableRightClickPaste' // NEW 'terminalEnableRightClickPaste'
]; ];
if (!allowedKeys.includes(key)) { if (!allowedKeys.includes(key)) {
console.error(`[SettingsStore] 尝试更新不允许的设置键: ${key}`); console.error(`[SettingsStore] 尝试更新不允许的设置键: ${key}`);
@@ -486,12 +486,12 @@ export const useSettingsStore = defineStore('settings', () => {
'ipBlacklistEnabled', 'ipBlacklistEnabled',
'dashboardSortBy', 'dashboardSortBy',
'dashboardSortOrder', 'dashboardSortOrder',
'showConnectionTags', // NEW 'showConnectionTags',
'showQuickCommandTags', // NEW 'showQuickCommandTags',
'layoutLocked', // NEW 'layoutLocked',
'terminalScrollbackLimit', // NEW 'terminalScrollbackLimit',
'fileManagerShowDeleteConfirmation', // NEW 'fileManagerShowDeleteConfirmation',
'terminalEnableRightClickPaste' // NEW 'terminalEnableRightClickPaste'
]; ];
const filteredUpdates: Partial<SettingsState> = {}; const filteredUpdates: Partial<SettingsState> = {};
let languageUpdate: string | undefined = undefined; let languageUpdate: string | undefined = undefined;