fix: 修复空回车导致恢复会话窗口重连的问题
This commit is contained in:
@@ -233,12 +233,25 @@ export function initializeConnectionHandler(wss: WebSocketServer, sshSuspendServ
|
|||||||
// console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_OUTPUT_CACHED_CHUNK 前已关闭 (会话 ${newFrontendSessionId})。`);
|
// console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_OUTPUT_CACHED_CHUNK 前已关闭 (会话 ${newFrontendSessionId})。`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const response: SshSuspendResumedNotification = {
|
// +++ 新增:发送 ssh:connected 消息 +++
|
||||||
type: 'SSH_SUSPEND_RESUMED',
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: 'ssh:connected',
|
||||||
|
payload: {
|
||||||
|
connectionId: newSessionState.dbConnectionId, // 使用已恢复的 dbConnectionId
|
||||||
|
sessionId: newFrontendSessionId // 使用新的前端会话 ID
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
console.log(`[WebSocket Handler][SSH_SUSPEND_RESUME_REQUEST] 已发送 ssh:connected 给 ${newFrontendSessionId}。`);
|
||||||
|
}
|
||||||
|
// +++ 结束新增 +++
|
||||||
|
|
||||||
|
const responseNotification: SshSuspendResumedNotification = { // 确保变量名不冲突且类型正确
|
||||||
|
type: 'SSH_SUSPEND_RESUMED_NOTIF', // 改回与前端和新类型定义一致
|
||||||
payload: { suspendSessionId, newFrontendSessionId, success: true }
|
payload: { suspendSessionId, newFrontendSessionId, success: true }
|
||||||
};
|
};
|
||||||
if (ws.readyState === WebSocket.OPEN) {
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
ws.send(JSON.stringify(response));
|
ws.send(JSON.stringify(responseNotification));
|
||||||
// console.log(`[WebSocket Handler][${type}] 已发送 SSH_SUSPEND_RESUMED_NOTIF 给 ${newFrontendSessionId}。`);
|
// console.log(`[WebSocket Handler][${type}] 已发送 SSH_SUSPEND_RESUMED_NOTIF 给 ${newFrontendSessionId}。`);
|
||||||
} else {
|
} else {
|
||||||
// console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_SUSPEND_RESUMED_NOTIF 前已关闭 (会话 ${newFrontendSessionId})。`);
|
// console.warn(`[WebSocket Handler][${type}] WebSocket 在发送 SSH_SUSPEND_RESUMED_NOTIF 前已关闭 (会话 ${newFrontendSessionId})。`);
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export interface SshSuspendListResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SshSuspendResumedNotification {
|
export interface SshSuspendResumedNotification {
|
||||||
type: "SSH_SUSPEND_RESUMED";
|
type: "SSH_SUSPEND_RESUMED_NOTIF"; // 统一为带 _NOTIF 后缀
|
||||||
payload: {
|
payload: {
|
||||||
suspendSessionId: string;
|
suspendSessionId: string;
|
||||||
newFrontendSessionId: string; // The frontend session ID this resumed session is now associated with
|
newFrontendSessionId: string; // The frontend session ID this resumed session is now associated with
|
||||||
|
|||||||
Reference in New Issue
Block a user