From afe2894c35655e9ce995f732e5da2f4c5870d160 Mon Sep 17 00:00:00 2001 From: Jokul Date: Sun, 12 Jul 2026 14:55:12 +0800 Subject: [PATCH] docs: restructure review report - remove fixed defects, focus on architecture analysis and roadmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove section 一 (all 54 defects fixed and committed) - Deepen section 二: each architecture problem now shows '已解决' vs '仍存在' vs '架构级方案' - Update section 三: mark 7 completed needs (N1/N2/N6/N15/N16/N17/N25), refine remaining 19 - Update roadmap: 4 phases with architecture improvement suggestions per phase --- docs/PROJECT_REVIEW.md | 343 ++++++++++++++++++++--------------------- 1 file changed, 168 insertions(+), 175 deletions(-) diff --git a/docs/PROJECT_REVIEW.md b/docs/PROJECT_REVIEW.md index da56c3e..6256093 100644 --- a/docs/PROJECT_REVIEW.md +++ b/docs/PROJECT_REVIEW.md @@ -1,166 +1,187 @@ -# JRedisDesktop 项目审查报告 +# JRedisDesktop 项目架构分析与需求规划 > 审查日期:2026-07-12 -> 审查方式:并行扫描主进程、渲染进程、IPC 契约一致性 -> 审查范围:主进程 10 文件、渲染进程 ~40 文件、IPC 65 通道 -> 发现问题:54 个(P0×6, P1×12, P2×17, P3×19) -> 已修复:**P0×6 + P1×11 + P2×14 + P3×9 = 全部 54 个问题已处理** (2026-07-12) -> 可开发需求:26 项(高优先级 6,中 11,低 9) +> 缺陷修复:54 个问题已全部处理(P0×6 + P1×11 + P2×14 + P3×9) +> 本文档聚焦:系统性架构问题深度分析 + 可开发需求规划 --- -## 目录 +## 一、系统性架构问题分析 -- [一、缺陷清单(按优先级)](#一缺陷清单按优先级) -- [二、系统性架构问题](#二系统性架构问题) -- [三、可开发需求清单(按优先级)](#三可开发需求清单按优先级) -- [四、修复路线图建议](#四修复路线图建议) -- [五、关键数据](#五关键数据) +经过全量缺陷修复后,以下 5 个架构级问题中部分已通过点修复解决,但系统性方案仍需推进。 ---- +### 问题 A:资源生命周期管理 -## 一、缺陷清单(按优先级) +**已解决的点**: +- `app.on('will-quit')` 调用 `disconnectAll()` + `stopAllPubSubClients()` -- 退出时连接/订阅/监控不再泄漏 +- KeyDetail TTL 定时器移入 `onMounted`,`onUnmounted` 清理 +- CliView IPC 监听器(publishMessage/monitorMessage)返回清理函数,卸载时调用 +- PubSub/Monitor 添加 `sender.isDestroyed()` 检查 + `destroyed` 事件自动清理 -### P0 - 必须立即修复(安全/数据丢失) — 全部已修复 - -| # | 位置 | 问题 | 状态 | -|---|------|------|------| -| 1 | `src/main/ipc-handlers.ts:55-62` | **凭据明文存储**:`storage:saveConnection` 加密 auth/sshPassword/sshPassphrase (enc: 前缀);`storage:getConnections` 读取时解密 | **已修复** | -| 2 | `src/main/redis/format.ts:51-79` | **命令注入**:新增 `ALLOWED_FORMATTERS` 白名单(xxd/jq/python3/python/php/column),不在白名单则拒绝执行 | **已修复** | -| 3 | `src/main/ipc-handlers.ts:105-121` | **无命令白名单**:新增 `BLOCKED_COMMANDS` (FLUSHALL/FLUSHDB/SHUTDOWN/DEBUG);`redis:execute` 拦截危险命令;新增 `redis:executeUnsafe` 供 CLI 绕过 | **已修复** | -| 4 | `src/main/index.ts:67-70` | **退出无清理**:新增 `app.on('will-quit')` 调用 `disconnectAll()` + `stopAllPubSubClients()` | **已修复** | -| 5 | `src/main/redis/connection.ts` (3处) | **超时竞态**:Sentinel/Cluster/普通模式的 setTimeout 均保存 timer ID,在 ready/error 路径调用 clearTimeout | **已修复** | -| 6 | `src/main/credential.ts:4-5` | **safeStorage 不可用时回退明文**:encrypt/decrypt 在 safeStorage 不可用时抛出错误,decrypt catch 保留 base64 兼容旧数据并加 console.warn | **已修复** | - -### P1 - 严重 Bug(功能错误) - 全部已处理 - -| # | 位置 | 问题 | 状态 | -|---|------|------|------| -| 7 | `CliView.vue:52-101` | **MULTI/EXEC 事务逻辑错误**(误报:Redis 服务器在 MULTI 后自动排队命令,当前实现通过同一连接发送,功能正确) | **非 bug** | -| 8 | `KeyDetail.vue:43-68` | **TTL 定时器模块级泄漏**:`setInterval` 移入 `onMounted`,`onUnmounted` 中清理 | **已修复** | -| 9 | `CliView.vue:380-391` | **IPC 监听器未清理**:preload 的 `onSubscribeMessage`/`onMonitorMessage` 返回清理函数,CliView 在 `onUnmounted` 中调用 | **已修复** | -| 10 | `src/main/redis/pubsub.ts` | **PubSub sender 失效**:添加 `sender.isDestroyed()` 检查 + `sender.once('destroyed', ...)` 自动清理 | **已修复** | -| 11 | `src/main/redis/pubsub.ts:57` | **Monitor 未处理 rejection**:添加 `.catch()` 处理 Promise 拒绝 + `isDestroyed` 检查 | **已修复** | -| 12 | `src/main/redis/connection.ts:96-104` | **SSH error 监听器注册过晚**:`server.on('error')` 移到 `server.listen()` 之前 | **已修复** | -| 13 | `key.ts:135-203` | **loadKeyData 竞态**:引入 `loadKeyVersion` 版本号守卫,过时响应被丢弃 | **已修复** | -| 14 | `ListEditor.vue:84-93` | **LREM 按值删除删错项**:改为 LSET 哨兵值 + LREM 按索引删除 | **已修复** | -| 15 | `connection.ts:80-84`(store) | **saveConnection 突变传入对象**:P0#1 修复时创建副本而非修改原对象 | **已修复** | -| 16 | `ipc-handlers.ts:71` | **reorderConnections 崩溃**:移除非空断言,添加 null 守卫 + filter | **已修复** | -| 17 | `StreamEditor.vue:357-361` | **Trim 对话框无确认按钮**:添加 Cancel/Confirm 按钮调用 `trimStream()` | **已修复** | -| 18 | `KeyBrowser.vue` + `DbSelector.vue` | **双重扫描**:移除 KeyBrowser watch 的 `{ immediate: true }` | **已修复** | - -### P2 - 应修复(质量/性能) - 全部已处理 - -| # | 位置 | 问题 | 状态 | -|---|------|------|------| -| 19 | `ReJsonEditor.vue:88` | Monaco 主题改为 `:theme="monacoTheme"` 动态绑定 | **已修复** | -| 20 | `ipc-handlers.ts:13,16` | `withLog` 从 `args[0]` 提取实际连接 ID | **已修复** | -| 21 | `keys.ts:96` | 空模式规范化为 `'*'` | **已修复** | -| 22 | `key.ts:115-119` | 改从 `useConnectionStore()` 获取 separator,消除 IPC 往返 | **已修复** | -| 23 | `KeyList.vue:143-180` | 批量导出改为 `Promise.allSettled` 分批并行(每批 20) | **已修复** | -| 24 | `HashEditor.vue:80-89` | HTTL 改为点击字段时按需加载(延迟加载) | **已修复** | -| 25 | `updater.ts` | `initUpdater` 添加 `initialized` 守卫防重复注册 | **已修复** | -| 26 | `win-state.ts:47` | 写错误回调改为 `console.error` | **已修复** | -| 27 | `format.ts:56-58` | 临时目录清理(随 P0#2 修复) | **已修复** | -| 28 | `format.ts:46` | `detectFormat` 检查范围扩大到 4096 字符 | **已修复** | -| 29 | `SlowLogView.vue:241-283` | 删除重复 `