diff --git a/src/renderer/src/components/ConnectionList.vue b/src/renderer/src/components/ConnectionList.vue index cf2c8bc..b2237ea 100644 --- a/src/renderer/src/components/ConnectionList.vue +++ b/src/renderer/src/components/ConnectionList.vue @@ -1,7 +1,7 @@ @@ -113,8 +155,13 @@ function handleNew() { padding: 40px 0; } +.list-footer { + padding: 14px; + border-top: 1px solid var(--border-color); +} + .list-add-btn { - margin: 14px; + width: 100%; padding: 10px; background: var(--bg-card); border: 1px dashed var(--border-color); @@ -123,6 +170,7 @@ function handleNew() { font-size: 12px; cursor: pointer; transition: all 0.2s; + margin-bottom: 8px; } .list-add-btn:hover { @@ -130,4 +178,10 @@ function handleNew() { color: var(--accent-light); background: var(--bg-card-hover); } + +.list-actions { + display: flex; + justify-content: center; + gap: 8px; +} diff --git a/src/renderer/src/components/NewConnectionDialog.vue b/src/renderer/src/components/NewConnectionDialog.vue index 9330d7f..ee789cd 100644 --- a/src/renderer/src/components/NewConnectionDialog.vue +++ b/src/renderer/src/components/NewConnectionDialog.vue @@ -20,6 +20,7 @@ const form = reactive({ }) const saving = ref(false) +const testing = ref(false) const isEdit = ref(false) watch(() => props.visible, (v) => { @@ -49,6 +50,30 @@ function close() { emit('update:visible', false) } +async function handleTest() { + if (!form.host.trim()) { + ElMessage.warning('Host is required') + return + } + testing.value = true + try { + const result = await connStore.testConnection({ + host: form.host.trim(), + port: Number(form.port) || 6379, + auth: form.auth || undefined, + username: form.username || undefined, + tls: form.tls, + }) + if (result.success) { + ElMessage.success('Connection successful') + } else { + ElMessage.error(result.error || 'Connection failed') + } + } finally { + testing.value = false + } +} + async function handleSave() { if (!form.name.trim() || !form.host.trim()) { ElMessage.warning('Name and host are required') @@ -128,10 +153,28 @@ async function handleSave() { + + diff --git a/src/renderer/src/components/Sidebar.vue b/src/renderer/src/components/Sidebar.vue index 80f3ae5..4487ae8 100644 --- a/src/renderer/src/components/Sidebar.vue +++ b/src/renderer/src/components/Sidebar.vue @@ -4,9 +4,12 @@ import { ref } from 'vue' import ConnectionList from './ConnectionList.vue' import NewConnectionDialog from './NewConnectionDialog.vue' import { useConnectionStore } from '@renderer/stores/connection' +import { useKeyStore } from '@renderer/stores/key' import type { ConnectionConfig } from '@renderer/stores/connection' +import { useKeyboard } from '@renderer/composables/useKeyboard' const connStore = useConnectionStore() +const keyStore = useKeyStore() const dialogVisible = ref(false) const editingConnection = ref(null) @@ -14,6 +17,20 @@ function handleEdit(conn: ConnectionConfig | null) { editingConnection.value = conn dialogVisible.value = true } + +function handleNew() { + editingConnection.value = null + dialogVisible.value = true +} + +useKeyboard({ + 'ctrl+n': handleNew, + 'ctrl+r': () => { + if (connStore.activeId) { + keyStore.scanKeys(connStore.activeId, '0', true) + } + }, +})