From cf3e171438d23faa86709f8fae3dce6d3922a5af Mon Sep 17 00:00:00 2001 From: dalaolala Date: Sat, 28 Feb 2026 11:16:13 +0800 Subject: [PATCH] feat: Implement quick SSH connect feature with connection history management and dedicated terminal views. --- frontend/src/router/index.js | 8 +- frontend/src/views/QuickConnect.vue | 689 ++++++++---- frontend/src/views/QuickConnectTerminal.vue | 1049 +++++++++++++++++++ frontend/src/views/Terminal.vue | 8 + 4 files changed, 1533 insertions(+), 221 deletions(-) create mode 100644 frontend/src/views/QuickConnectTerminal.vue diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 8e2c329..9d69fcf 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -38,6 +38,12 @@ const routes = [ component: () => import('@/views/QuickConnect.vue'), meta: { requiresAuth: true } }, + { + path: '/quick-connect-terminal', + name: 'QuickConnectTerminal', + component: () => import('@/views/QuickConnectTerminal.vue'), + meta: { requiresAuth: true } + }, { path: '/terminal-new', name: 'TerminalNew', @@ -66,7 +72,7 @@ const router = createRouter({ // 路由守卫 router.beforeEach((to, from, next) => { const authStore = useAuthStore() - + // 检查是否需要认证 if (to.meta.requiresAuth && !authStore.isAuthenticated) { next('/login') diff --git a/frontend/src/views/QuickConnect.vue b/frontend/src/views/QuickConnect.vue index 436e986..1fac7c7 100644 --- a/frontend/src/views/QuickConnect.vue +++ b/frontend/src/views/QuickConnect.vue @@ -4,7 +4,7 @@
- + 返回 @@ -12,133 +12,183 @@
- - -
- - - - - - - - - - - - - - - - - - - 密码认证 - 私钥认证 - - - - - - - - - - - - - - - 连接 - - - - - -
- + + + +
+ 连接历史 + + + 清空 + +
+ +
+ + + +
+ + +
+ +
+ +
+ + + +
+ + + + -
- -
- -
- - - - - - -
-
-

Ubuntu服务器

-

主机: 192.168.1.100

-

端口: 22

-

用户: ubuntu

+ + + + + + + + + + + + + + + + + + + + + 密码认证 + 私钥认证 + + + + + + + + + + + + + + + 保存密码到本地(记住凭据) + + + + + + + 连接 + + + + + +
+
-
-

CentOS服务器

-

主机: 192.168.1.101

-

端口: 22

-

用户: root

+
+
- -
-

Docker容器

-

主机: localhost

-

端口: 2222

-

用户: root

-
-
- -
- + +
+
+
\ No newline at end of file diff --git a/frontend/src/views/QuickConnectTerminal.vue b/frontend/src/views/QuickConnectTerminal.vue new file mode 100644 index 0000000..54d046e --- /dev/null +++ b/frontend/src/views/QuickConnectTerminal.vue @@ -0,0 +1,1049 @@ + + + + + diff --git a/frontend/src/views/Terminal.vue b/frontend/src/views/Terminal.vue index d3e6ba9..fe34ab8 100644 --- a/frontend/src/views/Terminal.vue +++ b/frontend/src/views/Terminal.vue @@ -565,6 +565,12 @@ const hideContextMenu = () => { contextMenu.value.visible = false } +const onDocumentClick = () => { + if (contextMenu.value.visible) { + hideContextMenu() + } +} + // 检查是否有选中的文本 const hasSelection = () => { return term && term.getSelection() && term.getSelection().length > 0 @@ -762,6 +768,7 @@ onMounted(async () => { // 监听窗口大小变化 window.addEventListener('resize', handleResize) + document.addEventListener('click', onDocumentClick) // 如果是服务器连接,自动连接 if (route.params.serverId) { @@ -786,6 +793,7 @@ onUnmounted(() => { viewportWheelHandler = null } window.removeEventListener('resize', handleResize) + document.removeEventListener('click', onDocumentClick) })