update
This commit is contained in:
@@ -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
|
// Determine WebSocket URL based on hostname for RDP
|
||||||
if (window.location.hostname === 'localhost') {
|
if (window.location.hostname === 'localhost') {
|
||||||
backendBaseUrl = LOCAL_BACKEND_URL;
|
backendBaseUrl = LOCAL_BACKEND_URL;
|
||||||
console.log(`[RemoteDesktopModal] Using localhost RDP WebSocket base URL: ${backendBaseUrl}`);
|
|
||||||
} else {
|
} else {
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
const wsHostAndPort = window.location.host;
|
const wsHostAndPort = window.location.host;
|
||||||
backendBaseUrl = `${wsProtocol}//${wsHostAndPort}/ws`; // Assuming RDP proxy is at /ws path
|
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 () => {
|
const handleConnection = async () => {
|
||||||
@@ -106,27 +90,7 @@ const handleConnection = async () => {
|
|||||||
heightToSend = Math.max(100, heightToSend);
|
heightToSend = Math.max(100, heightToSend);
|
||||||
}
|
}
|
||||||
tunnelUrl = `${backendBaseUrl}/rdp-proxy?token=${encodeURIComponent(token)}&width=${widthToSend}&height=${heightToSend}&dpi=${dpiToSend}`;
|
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 {
|
} else {
|
||||||
throw new Error(`Unsupported connection type: ${props.connection.type}`);
|
throw new Error(`Unsupported connection type: ${props.connection.type}`);
|
||||||
}
|
}
|
||||||
@@ -158,7 +122,7 @@ const handleConnection = async () => {
|
|||||||
currentStatus = 'disconnected';
|
currentStatus = 'disconnected';
|
||||||
break;
|
break;
|
||||||
case 1: // CONNECTING
|
case 1: // CONNECTING
|
||||||
i18nKeyPart = props.connection?.type === 'VNC' ? 'connectingVnc' : 'connectingRdp';
|
i18nKeyPart = 'connectingRdp';
|
||||||
currentStatus = 'connecting';
|
currentStatus = 'connecting';
|
||||||
break;
|
break;
|
||||||
case 2: // WAITING
|
case 2: // WAITING
|
||||||
|
|||||||
@@ -47,11 +47,9 @@ const VNC_WS_PORT_FROM_ENV = import.meta.env.VITE_VNC_WS_PORT || '8082';
|
|||||||
|
|
||||||
if (window.location.hostname === 'localhost') {
|
if (window.location.hostname === 'localhost') {
|
||||||
vncWsBaseUrl = `ws://localhost:${VNC_WS_PORT_FROM_ENV}`;
|
vncWsBaseUrl = `ws://localhost:${VNC_WS_PORT_FROM_ENV}`;
|
||||||
console.log(`[VncModal] Using localhost VNC WebSocket base URL: ${vncWsBaseUrl}`);
|
|
||||||
} else {
|
} else {
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
vncWsBaseUrl = `${wsProtocol}//${window.location.hostname}:${VNC_WS_PORT_FROM_ENV}`;
|
vncWsBaseUrl = `${wsProtocol}//${window.location.hostname}:${VNC_WS_PORT_FROM_ENV}`;
|
||||||
console.log(`[VncModal] Using production VNC WebSocket base URL: ${vncWsBaseUrl}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConnection = async () => {
|
const handleConnection = async () => {
|
||||||
@@ -77,7 +75,7 @@ const handleConnection = async () => {
|
|||||||
}
|
}
|
||||||
statusMessage.value = t('remoteDesktopModal.status.connectingWs');
|
statusMessage.value = t('remoteDesktopModal.status.connectingWs');
|
||||||
const tunnelUrl = `${vncWsBaseUrl}?token=${encodeURIComponent(token)}`;
|
const tunnelUrl = `${vncWsBaseUrl}?token=${encodeURIComponent(token)}`;
|
||||||
console.log(`[VncModal] Connecting to VNC tunnel: ${tunnelUrl}`);
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const tunnel = new Guacamole.WebSocketTunnel(tunnelUrl);
|
const tunnel = new Guacamole.WebSocketTunnel(tunnelUrl);
|
||||||
@@ -320,10 +318,9 @@ const closeModal = () => {
|
|||||||
|
|
||||||
watch(desiredModalWidth, (newWidth, oldWidth) => {
|
watch(desiredModalWidth, (newWidth, oldWidth) => {
|
||||||
if (newWidth === oldWidth && typeof newWidth === 'number' && typeof oldWidth === 'number') {
|
if (newWidth === oldWidth && typeof newWidth === 'number' && typeof oldWidth === 'number') {
|
||||||
// console.log(`[VncModal] 宽度监听触发,但值 (${newWidth}) 未改变。跳过。`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log(`[VncModal] 监听 desiredModalWidth 触发: ${oldWidth} -> ${newWidth}`);
|
|
||||||
|
|
||||||
const validatedWidth = Math.max(MIN_MODAL_WIDTH, Number(newWidth) || MIN_MODAL_WIDTH);
|
const validatedWidth = Math.max(MIN_MODAL_WIDTH, Number(newWidth) || MIN_MODAL_WIDTH);
|
||||||
|
|
||||||
@@ -335,7 +332,6 @@ watch(desiredModalWidth, (newWidth, oldWidth) => {
|
|||||||
|
|
||||||
if (saveWidthTimeout) clearTimeout(saveWidthTimeout);
|
if (saveWidthTimeout) clearTimeout(saveWidthTimeout);
|
||||||
saveWidthTimeout = setTimeout(() => {
|
saveWidthTimeout = setTimeout(() => {
|
||||||
// console.log(`[VncModal] 防抖保存 - 保存宽度: ${validatedWidth}`);
|
|
||||||
if (String(validatedWidth) !== settingsStore.settings.vncModalWidth) {
|
if (String(validatedWidth) !== settingsStore.settings.vncModalWidth) {
|
||||||
settingsStore.updateSetting('vncModalWidth', String(validatedWidth));
|
settingsStore.updateSetting('vncModalWidth', String(validatedWidth));
|
||||||
} else {
|
} else {
|
||||||
@@ -370,9 +366,8 @@ watch(desiredModalHeight, (newHeight, oldHeight) => {
|
|||||||
}, DEBOUNCE_DELAY);
|
}, 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(() => {
|
onMounted(() => {
|
||||||
if (props.connection) {
|
if (props.connection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user