From 56e61683f8bb624598ebacf9bad55c09730df6fb Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:28:28 +0800 Subject: [PATCH] update --- .../frontend/src/components/WorkspaceConnectionList.vue | 2 +- packages/frontend/src/locales/en.json | 1 + packages/frontend/src/locales/zh.json | 1 + packages/frontend/src/stores/session.store.ts | 8 +++++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/WorkspaceConnectionList.vue b/packages/frontend/src/components/WorkspaceConnectionList.vue index 2fd0694..a09c85f 100644 --- a/packages/frontend/src/components/WorkspaceConnectionList.vue +++ b/packages/frontend/src/components/WorkspaceConnectionList.vue @@ -347,7 +347,7 @@ const scrollToHighlighted = async () => { class="mt-4 px-4 py-2 bg-primary text-white border-none rounded-lg text-sm font-semibold cursor-pointer shadow-md transition-colors duration-200 ease-in-out hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary" @click="handleMenuAction('add')" > - {{ t('connections.addFirstConnection') }} + {{ t('connections.addFirstConnection') }} diff --git a/packages/frontend/src/locales/en.json b/packages/frontend/src/locales/en.json index 51b6129..51457e5 100644 --- a/packages/frontend/src/locales/en.json +++ b/packages/frontend/src/locales/en.json @@ -108,6 +108,7 @@ "connections": { "addConnection": "Add New Connection", "noConnections": "No connections yet. Click 'Add New Connection' to create one!", + "addFirstConnection": "Add your first connection", "table": { "name": "Name", "host": "Host", diff --git a/packages/frontend/src/locales/zh.json b/packages/frontend/src/locales/zh.json index dae8703..efb9e74 100644 --- a/packages/frontend/src/locales/zh.json +++ b/packages/frontend/src/locales/zh.json @@ -108,6 +108,7 @@ "connections": { "addConnection": "添加新连接", "noConnections": "还没有任何连接。点击'添加新连接'来创建一个吧!", + "addFirstConnection": "添加第一个连接", "table": { "name": "名称", "host": "主机", diff --git a/packages/frontend/src/stores/session.store.ts b/packages/frontend/src/stores/session.store.ts index 284ac23..a60e51b 100644 --- a/packages/frontend/src/stores/session.store.ts +++ b/packages/frontend/src/stores/session.store.ts @@ -189,7 +189,13 @@ export const useSessionStore = defineStore('session', () => { console.log(`[SessionStore] 已创建新会话实例: ${newSessionId} for connection ${dbConnId}`); // 4. 启动 WebSocket 连接 - const wsUrl = `ws://${window.location.hostname}:3001`; // TODO: 从配置获取 URL + // 根据当前页面协议动态生成 WebSocket URL,并移除硬编码的端口 + // 假设 WebSocket 服务与 Web 服务在同一主机和端口上提供(通过反向代理) + const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; + // 移除端口 :3001,依赖反向代理或同源策略 + // 如果 WebSocket 有特定路径 (例如 /ws),需要在这里添加 + const wsUrl = `${protocol}//${window.location.hostname}/`; + console.log(`[SessionStore] Generated WebSocket URL: ${wsUrl}`); // 添加日志记录生成的 URL wsManager.connect(wsUrl); console.log(`[SessionStore] 已为会话 ${newSessionId} 启动 WebSocket 连接。`); };