refactor: restructure project layout
- Move main process to electron/main/ - Move preload to electron/preload/ - Add shared types in electron/shared/ - Split redis-service into modular redis/ directory - Flatten renderer to src/ (remove src/renderer/ nesting) - Update electron.vite.config.ts paths - Update tsconfig paths - Output to electron-dist/
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<script setup lang="ts">
|
||||
// src/renderer/src/components/Sidebar.vue
|
||||
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'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
const connStore = useConnectionStore()
|
||||
const keyStore = useKeyStore()
|
||||
const dialogVisible = ref(false)
|
||||
const editingConnection = ref<ConnectionConfig | null>(null)
|
||||
|
||||
function handleEdit(conn: ConnectionConfig | null) {
|
||||
editingConnection.value = conn
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleNew() {
|
||||
editingConnection.value = null
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function deleteSelectedKey() {
|
||||
if (!connStore.activeId || !keyStore.selectedKey) return
|
||||
try {
|
||||
await ElMessageBox.confirm(`Delete key "${keyStore.selectedKey}"?`, 'Confirm')
|
||||
await window.electronAPI.redis.deleteKey(connStore.activeId, keyStore.selectedKey)
|
||||
ElMessage.success('Deleted')
|
||||
keyStore.selectedKey = null
|
||||
keyStore.keyData = null
|
||||
await keyStore.scanKeys(connStore.activeId, '0', true)
|
||||
} catch { /* cancelled */ }
|
||||
}
|
||||
|
||||
function deselectKey() {
|
||||
keyStore.selectedKey = null
|
||||
keyStore.keyData = null
|
||||
}
|
||||
|
||||
function refreshAll() {
|
||||
if (connStore.activeId) {
|
||||
keyStore.scanKeys(connStore.activeId, '0', true)
|
||||
}
|
||||
}
|
||||
|
||||
useKeyboard({
|
||||
'ctrl+n': handleNew,
|
||||
'ctrl+r': refreshAll,
|
||||
'f5': refreshAll,
|
||||
'delete': deleteSelectedKey,
|
||||
'escape': deselectKey,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="sidebar">
|
||||
<ConnectionList @edit="handleEdit" />
|
||||
<NewConnectionDialog
|
||||
v-model:visible="dialogVisible"
|
||||
:connection="editingConnection"
|
||||
/>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
flex-shrink: 0;
|
||||
background: var(--bg-secondary);
|
||||
border-right: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user