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:
2026-07-04 21:12:50 +08:00
parent bb885c6d6d
commit bdcf4fe299
59 changed files with 654 additions and 624 deletions
+20 -6
View File
@@ -6,9 +6,10 @@ Fork of [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesk
## Stack
- **Shell:** Electron 33 (`src/main/index.ts`)
- **Preload:** `src/preload/index.ts` (contextBridge, typed API)
- **Shell:** Electron 43 (`electron/main/index.ts`)
- **Preload:** `electron/preload/index.ts` (contextBridge, typed API)
- **Renderer:** Vue 3 + Pinia + Element Plus + Vue Router (`src/renderer/`)
- **Shared:** `electron/shared/types.ts` (cross-process types)
- **Build:** electron-vite + Vite 6 + TypeScript 5
- **Redis client:** ioredis 5 (main process only)
- **Persistence:** electron-store + safeStorage (credentials)
@@ -17,7 +18,7 @@ Fork of [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesk
```bash
npm run dev # electron-vite dev (HMR, renderer on :5173)
npm run build # production build → out/
npm run build # production build → electron-dist/
npm start # preview built app
npm run build:unpack # build + electron-builder --dir
npm run build:win # build + electron-builder --win
@@ -28,18 +29,31 @@ npm run build:linux # build + electron-builder --linux
## Architecture
```
Electron main (src/main/)
Electron main (electron/main/)
├── index.ts # Window creation, app lifecycle
├── redis-service.ts # ioredis wrapper (connect, scan, CRUD, stream)
├── redis/ # Redis service modules
│ ├── index.ts # Unified export
│ ├── connection.ts # connect, disconnect, isClientConnected
│ ├── keys.ts # scan, delete, rename, ttl, batchDelete
│ ├── string.ts # get, set
│ ├── hash.ts # hscan, hset, hdel
│ ├── list.ts # range, push, set, remove
│ ├── set.ts # members, add, remove
│ ├── zset.ts # range, add, remove
│ ├── stream.ts # info, range, add, trim
│ └── server.ts # info, select, ping, slowlog
├── store.ts # electron-store (connections, settings)
├── credential.ts # safeStorage encrypt/decrypt
├── win-state.ts # window position persistence
└── ipc-handlers.ts # all IPC channel handlers
Preload (src/preload/)
Preload (electron/preload/)
├── index.ts # contextBridge.exposeInMainWorld
└── index.d.ts # ElectronAPI type declarations
Shared (electron/shared/)
└── types.ts # Cross-process type definitions
Renderer (src/renderer/src/)
├── main.ts # Vue 3 bootstrap (Pinia, Element Plus)
├── App.vue # Shell layout (TitleBar + Sidebar + MainArea + StatusBar)