Files
u-desk/docs/代码改进清单.md
T

58 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 代码改进清单
> 基于 Wails 开发文档 vs 项目现状审查,2026-05-16
## 已完成
- [x] 🔴① `main.go` 添加 `SingleInstance` 单实例锁(`top.1216.udesk`)
- [x] 🔴② `app.go:74-97` RegisterGlobalHotkey 竞态修复(合并为单一 `defer mu.Unlock()`)
- [x] 🔴③ `build/windows/info.json` 版本号 0.1.0→0.4.0,公司名→1216.top
- [x] 🟡⑤ 删除 `frontend/src/wailsjs/wailsjs/` v2 遗留绑定目录
- [x] 🟡⑥ `LoadConnectionProfiles` 手动 map 转换改用 `json.Marshal/Unmarshal`
- [x] 🟡⑨ `App.vue` onMounted 添加 `contextmenu` 事件拦截(禁用浏览器默认右键菜单)
- [x] 🟡⑫ `main.go` Run() 错误输出改用 `fmt.Fprintf(os.Stderr, ...)`
- [x] Sidebar 设置按钮 `···` 点击无响应修复:移除 `.stop` + Teleport 重构 + 增大点击区域
## 待处理
- [x] ④ App 结构体拆分 — 1281行 app.go 拆为 9 个域文件:app_update/filesystem/sftp/oss/window/system/config/recycle/pdf + app_windows.go
- [ ] ⑦ `internal/api/pdf_api.go:371` SelectDirectory 改用 Wails 原生对话框 `application.Get().Dialog.OpenFile()`
- [ ] ⑧ `app.go:176-189` HWND 轮询改事件驱动 — v3 alpha 暂无对应 API,后续跟进
- [x] ⑩ `app.go:29` Windows 专用导入拆到 `app_windows.go`(registry/w32 包隔离)
- [x] ⑪ 全局结构化日志 — `fmt.Println/Printf` 全部替换为 `log/slog`(app.go + internal/ 共 45 处)
- [x] ⑬ `app.go` 更新检查 URL 改从 `update_config.json` 动态读取,不再硬编码
## 代码审查修复 (2026-05-16)
> 基于 App 拆分后全量审查,17 项问题已修复 15 项
### 已修复
- [x] 🔴① app_windows.go 添加 `//go:build windows` 构建标签
- [x] 🔴② app_windows.go 移除 `fallbackName` 死参数
- [x] 🔴③ initModulesByConfig 复用 initFilesystemModule,消除重复初始化逻辑
- [x] 🔴④ WindowToggleAlwaysOnTop 的 isAlwaysOnTop 修改加 mu 锁保护
- [x] 🟡⑤ GetEnvVars 从 app_filesystem.go 移至 app_system.go(归属修正)
- [x] 🟡⑥ GetAuditLogs 从 app_config.go 移至 app_filesystem.go(归属修正)
- [x] 🟡⑦ BgmGetPlaylist 处理 db.Find 错误
- [x] 🟡⑧ LoadConnectionProfiles 处理 json.Unmarshal 错误
- [x] 🟡⑨ startAutoUpdateCheck 改用 requireUpdateAPI 统一加锁
- [x] 🟡⑩ startAutoUpdateCheck 配置读取失败添加 slog.Warn 日志
- [x] 🟡⑪ MigrateTabConfig 错误从 `_ =` 改为 slog.Warn
- [x] 🟡⑫ app_recycle.go 移除空 import 块
- [x] ⚪⑭ OssConnect 补充 godoc 注释
- [x] ⚪⑮ EmitEvent 闭包提取为 app.emitEvent 方法,消除重复
## Bug 修复 (2026-05-16)
- [x] 🔴 预览状态级联失败: `clearContent()` 未重置 `isBinaryFile`,打开二进制文件后所有图片/视频预览失效
- [x] 🔴 Tab 切换状态不同步: 跨服务器 Tab 切换时面包屑和文件列表未更新
- [x] 🟡 AsyncCodeEditor 永久死亡: `defineAsyncComponent` 添加 `onError` 重试(限 2 次)
- [x] 🟡 loadDirectory 静默吞异常: 切换 Tab 加载目录失败时添加用户提示
### 暂不处理
- [ ] ⚪⑬ fallback 路径在非英文 Windows 上不匹配 — 边缘场景,影响有限
- [ ] ⚪⑯ SftpDisconnect 未走 ensureSftpService — 功能正确,风格统一待后续
- [ ] ⚪⑰ ensure 模式 5 种写法统一 — 大规模重构,独立迭代