diff --git a/packages/frontend/src/components/RemoteDesktopModal.vue b/packages/frontend/src/components/RemoteDesktopModal.vue index 8c8b08a..5fd7584 100644 --- a/packages/frontend/src/components/RemoteDesktopModal.vue +++ b/packages/frontend/src/components/RemoteDesktopModal.vue @@ -42,26 +42,10 @@ const LOCAL_BACKEND_URL = 'ws://localhost:3001'; // For RDP proxy via main backe // Determine WebSocket URL based on hostname for RDP if (window.location.hostname === 'localhost') { backendBaseUrl = LOCAL_BACKEND_URL; - console.log(`[RemoteDesktopModal] Using localhost RDP WebSocket base URL: ${backendBaseUrl}`); } else { const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const wsHostAndPort = window.location.host; backendBaseUrl = `${wsProtocol}//${wsHostAndPort}/ws`; // Assuming RDP proxy is at /ws path - console.log(`[RemoteDesktopModal] Using production RDP WebSocket base URL (from window.location): ${backendBaseUrl}`); -} - -// NEW: VNC WebSocket URL determination -let vncWsBaseUrl: string; -const VNC_WS_PORT_FROM_ENV = import.meta.env.VITE_VNC_WS_PORT || '8082'; // Get from env or default - -if (window.location.hostname === 'localhost') { - vncWsBaseUrl = `ws://localhost:${VNC_WS_PORT_FROM_ENV}`; - console.log(`[RemoteDesktopModal] Using localhost VNC WebSocket base URL: ${vncWsBaseUrl}`); -} else { - const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - // Assuming VNC proxy runs on the same host but different port (or path if configured) - vncWsBaseUrl = `${wsProtocol}//${window.location.hostname}:${VNC_WS_PORT_FROM_ENV}`; - console.log(`[RemoteDesktopModal] Using production VNC WebSocket base URL: ${vncWsBaseUrl}`); } const handleConnection = async () => { @@ -106,27 +90,7 @@ const handleConnection = async () => { heightToSend = Math.max(100, heightToSend); } tunnelUrl = `${backendBaseUrl}/rdp-proxy?token=${encodeURIComponent(token)}&width=${widthToSend}&height=${heightToSend}&dpi=${dpiToSend}`; - console.log(`[RemoteDesktopModal] Connecting to RDP tunnel: ${tunnelUrl}`); - } else if (props.connection.type === 'VNC') { - token = await connectionsStore.getVncSessionToken(props.connection.id); - if (!token) { - throw new Error('VNC Token not found from store action'); - } - statusMessage.value = t('remoteDesktopModal.status.connectingWs'); // Generic message - tunnelUrl = `${vncWsBaseUrl}?token=${encodeURIComponent(token)}`; - // Optional: Add width/height if VNC proxy needs them, though Guacamole usually handles this post-connection. - // await nextTick(); - // let widthToSend = 800; - // let heightToSend = 600; - // if (rdpContainerRef.value) { - // widthToSend = rdpContainerRef.value.clientWidth; - // heightToSend = rdpContainerRef.value.clientHeight - 1; - // widthToSend = Math.max(100, widthToSend); - // heightToSend = Math.max(100, heightToSend); - // tunnelUrl += `&width=${widthToSend}&height=${heightToSend}`; - // } - console.log(`[RemoteDesktopModal] Connecting to VNC tunnel: ${tunnelUrl}`); } else { throw new Error(`Unsupported connection type: ${props.connection.type}`); } @@ -158,7 +122,7 @@ const handleConnection = async () => { currentStatus = 'disconnected'; break; case 1: // CONNECTING - i18nKeyPart = props.connection?.type === 'VNC' ? 'connectingVnc' : 'connectingRdp'; + i18nKeyPart = 'connectingRdp'; currentStatus = 'connecting'; break; case 2: // WAITING diff --git a/packages/frontend/src/components/VncModal.vue b/packages/frontend/src/components/VncModal.vue index f7ca2c1..ecc01a7 100644 --- a/packages/frontend/src/components/VncModal.vue +++ b/packages/frontend/src/components/VncModal.vue @@ -47,11 +47,9 @@ const VNC_WS_PORT_FROM_ENV = import.meta.env.VITE_VNC_WS_PORT || '8082'; if (window.location.hostname === 'localhost') { vncWsBaseUrl = `ws://localhost:${VNC_WS_PORT_FROM_ENV}`; - console.log(`[VncModal] Using localhost VNC WebSocket base URL: ${vncWsBaseUrl}`); } else { const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; vncWsBaseUrl = `${wsProtocol}//${window.location.hostname}:${VNC_WS_PORT_FROM_ENV}`; - console.log(`[VncModal] Using production VNC WebSocket base URL: ${vncWsBaseUrl}`); } const handleConnection = async () => { @@ -77,7 +75,7 @@ const handleConnection = async () => { } statusMessage.value = t('remoteDesktopModal.status.connectingWs'); const tunnelUrl = `${vncWsBaseUrl}?token=${encodeURIComponent(token)}`; - console.log(`[VncModal] Connecting to VNC tunnel: ${tunnelUrl}`); + // @ts-ignore const tunnel = new Guacamole.WebSocketTunnel(tunnelUrl); @@ -320,10 +318,9 @@ const closeModal = () => { watch(desiredModalWidth, (newWidth, oldWidth) => { if (newWidth === oldWidth && typeof newWidth === 'number' && typeof oldWidth === 'number') { - // console.log(`[VncModal] 宽度监听触发,但值 (${newWidth}) 未改变。跳过。`); return; } - // console.log(`[VncModal] 监听 desiredModalWidth 触发: ${oldWidth} -> ${newWidth}`); + const validatedWidth = Math.max(MIN_MODAL_WIDTH, Number(newWidth) || MIN_MODAL_WIDTH); @@ -335,7 +332,6 @@ watch(desiredModalWidth, (newWidth, oldWidth) => { if (saveWidthTimeout) clearTimeout(saveWidthTimeout); saveWidthTimeout = setTimeout(() => { - // console.log(`[VncModal] 防抖保存 - 保存宽度: ${validatedWidth}`); if (String(validatedWidth) !== settingsStore.settings.vncModalWidth) { settingsStore.updateSetting('vncModalWidth', String(validatedWidth)); } else { @@ -370,9 +366,8 @@ watch(desiredModalHeight, (newHeight, oldHeight) => { }, DEBOUNCE_DELAY); }); -// The watchEffect that was here (lines 359-372) is removed as its functionality -// is now covered by the direct initialization of desiredModalWidth/Height from the store -// and the updated watch listeners. + + onMounted(() => { if (props.connection) {