mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-12 00:06:37 +08:00
120 lines
6.5 KiB
Markdown
120 lines
6.5 KiB
Markdown
# 2026-05-15 工作记录
|
||
|
||
## MediaStationGo 编译错误修复
|
||
|
||
修复了 8 个 Go 编译错误,构建通过:
|
||
|
||
| # | 文件 | 错误 | 修复 |
|
||
|---|------|------|------|
|
||
| 1 | emby_svc.go:63 | `ServerId` 字段不存在 | 改为 `ServerID` (EmbyAuthResponse 结构体字段名) |
|
||
| 2 | emby_svc.go:90 | 同上 | 同上 |
|
||
| 3 | emby_svc.go:930 | `proxy.Fetch undefined` | 给 ImageProxy 添加 `Fetch(ctx, url) ([]byte, string, error)` 方法 |
|
||
| 4 | scheduler_svc.go:279 | `cannot take address of now.Add()` | 引入 `nextRun` 中间变量 |
|
||
| 5 | site_adapter.go:16 | `model` imported and not used | 移除 import (仅注释中引用) |
|
||
| 6 | site_adapter.go:1280 | `ri.Description undefined` | 移除该行 (TorrentItem 无 Description 字段,TorrentDetail 才有) |
|
||
| 7 | site_svc.go:141 | `*SiteConfig` 不能作为 `SiteConfig` 值 | 解引用 `*cfg` |
|
||
| 8 | notify_webhook.go:5 | `bytes` imported and not used | 移除 import |
|
||
|
||
**新增代码**: `ImageProxy.Fetch()` — 约 65 行,带缓存和 MIME 检测的图片拉取方法。
|
||
|
||
**构建结果**: `go build ./cmd/server` → 通过,`server.exe` 24.7MB。
|
||
|
||
## 部署浏览测试 (22:26)
|
||
|
||
- 停止旧进程 (PID 10784),启动新版 server.exe
|
||
- **健康检查**: `GET /api/health` → `{"status":"ok"}`
|
||
- **登录 API**: `POST /api/auth/login` → 返回 JWT + user 信息
|
||
- **统计 API**: `GET /api/stats` → 正常返回系统硬件信息 (Go 1.25.0, 17 goroutines)
|
||
- **媒体库 API**: `GET /api/libraries` → `[]` (空库,符合预期)
|
||
- **前端**: `http://localhost:8080` 浏览器预览已打开,Web 界面正常加载
|
||
|
||
## 拉取合并上游代码 + 修复编译错误 (22:40-22:52)
|
||
|
||
### Git 操作
|
||
- `git fetch origin` → 4 commits ahead (PRs #5, #6)
|
||
- `git stash push -m "local fixes"` 暂存 8 个本地修改
|
||
- `git pull origin main --no-edit` → fast-forward, 49 files, +4181/−0
|
||
- `git stash pop` → 3 处合并冲突 (handler.go, model.go, service.go)
|
||
- 冲突已手动合并
|
||
|
||
### 删除的重复类型名文件
|
||
| 本地文件 | 上游替代 |
|
||
|---|---|
|
||
| `internal/service/crypto_svc.go` | `crypto.go` |
|
||
| `internal/service/emby_svc.go` | `emby_compat.go` |
|
||
| `internal/service/scheduler_svc.go` | `scheduler.go` |
|
||
|
||
### CryptoService API 签名适配
|
||
上游 `CryptoService.Encrypt(string) string` 和 `Decrypt(string) string` 不返回 error。
|
||
修复了以下文件中的调用:`api_config_svc.go`, `download_manager_svc.go`, `notify_svc.go`, `site_svc.go`
|
||
|
||
### 本轮修复的编译错误 (7 errors)
|
||
| # | 文件 | 问题 | 修复 |
|
||
|---|------|------|------|
|
||
| 1 | service.go:105 | `crypto` 变量重复声明 + `NewCryptoService(cfg)` 签名错误 | 删除行105(已有行91的正确初始化) |
|
||
| 2 | service.go:111 | `schedulerSvc` 未使用 + `NewSchedulerService(log)` 签名错误 | 删除行111(已有行102的正确初始化) |
|
||
| 3 | service.go:184-186 | `RegisterHandler`/`RegisterDefaultTasks` 不存在于上游 SchedulerService | 删除这些调用,保留 `Scheduler.Start()` |
|
||
| 4 | service.go:220-262 | 整个 `registerSchedulerHandlers()` 方法不兼容 | 删除方法(43行) |
|
||
| 5 | api_config_svc.go:65 | `Decrypt` 2变量赋值(返回1值) | 改为单变量赋值 |
|
||
| 6 | site_svc.go:97 | `encryptSite()` 返回 void 却用作条件 | 移除 err 检查 |
|
||
| 7 | site_svc.go:219-222 | `Decrypt` 后检查不存在的 `err` | 移除 err 检查块 |
|
||
| 8 | handler/ 多个文件 | `Encrypt` 2变量赋值 | 全部改为单变量赋值 |
|
||
| 9 | handler/scheduler_handler.go | `GetTasks`/`UpdateTask`/`RunTaskNow`/`TaskConfig` 不存在 | 重写,使用 `Status()`/`RunNow()` |
|
||
| 10 | handler/handler.go:388 | `h.UpdateTask` 不存在 | 删除 UpdateTask 函数和对应路由 |
|
||
|
||
### 冒烟测试验证
|
||
- 构建: `go build ./cmd/server` → ✅ 通过
|
||
- 健康检查: `/api/health` → ✅ `{"status":"ok"}`
|
||
- 登录: `/api/auth/login` → ✅ 返回 JWT
|
||
- 统计: `/api/stats` → ✅ 系统信息正常
|
||
- 媒体库: `/api/libraries` → ✅ 空数组
|
||
- 前端: ✅ 浏览器预览正常
|
||
|
||
## 全功能部署浏览测试 (23:04-23:18)
|
||
|
||
### 发现并修复的问题
|
||
|
||
| # | 问题 | 根因 | 修复 |
|
||
|---|------|------|------|
|
||
| 1 | 前端 dist 过期 | dist 构建于 19:31,后端代码最后更新于 22:52 | `npm run build` 重建 |
|
||
| 2 | `/api/admin/api-configs` 500 — `api_configs.deleted_at` 列不存在 | model.Base 嵌入 gorm.DeletedAt,旧 DB 无此列 | `ALTER TABLE api_configs ADD COLUMN deleted_at datetime` + `created_at datetime` |
|
||
| 3 | `/api/sites` 404 | 站点管理路由未注册到 handler.go | 创建 `site_handler.go`(114行),在 handler.go 注册 7 条路由 |
|
||
| 4 | 前端 AdminPage.tsx 编译错误 | `listTasks`/`updateTask`/`runTask` 引用不存在的 API 方法 | 改为 `status()/run(name)`,对齐后端实际 API |
|
||
|
||
### 新增文件
|
||
|
||
- `internal/handler/site_handler.go` — PT 站点 CRUD Handler(114行),支持 List/Get/Create/Update/Delete/Test/SiteTypes/AuthTypes
|
||
|
||
### 修改文件
|
||
|
||
- `internal/service/service.go` — 添加 `Site *SiteService` 字段 + `siteSvc := NewSiteService(...)` 初始化
|
||
- `internal/handler/handler.go` — 注册 `/api/sites` 路由组(7条)
|
||
- `web/src/pages/AdminPage.tsx` — SchedulerPanel 对齐后端 `JobStatus` 类型
|
||
|
||
### API 全面测试结果 (30+ 端点)
|
||
|
||
| 模块 | 端点 | 结果 |
|
||
|------|------|------|
|
||
| 健康检查 | `/api/health` | ✅ 200 |
|
||
| 认证 | `/api/auth/login` | ✅ 200, 返回 JWT |
|
||
| 用户 | `/api/me`, `/api/auth/permissions` | ✅ 200 |
|
||
| 媒体库 | `/api/libraries`, `/api/media` | ✅ 200 |
|
||
| 站点管理 | `/api/sites`, `/sites/types`, `/sites/auth-types` | ✅ 200 (新增) |
|
||
| 下载 | `/api/downloads`, `/api/download-clients` | ✅ 200 |
|
||
| 通知 | `/api/notify-channels`, `/notify-channels/types` | ✅ 200 |
|
||
| API配置 | `/api/api-config`, `/api/api-config/providers/list`, `/api/admin/api-configs` | ✅ 200 |
|
||
| 发现 | `/api/discover/trending`, `/api/discover/popular` | ✅ 200 |
|
||
| 播放 | `/api/history`, `/api/favourites`, `/api/playlists` | ✅ 200 |
|
||
| 文件 | `/api/files?path=/`, `/api/storage` | ✅ 200 |
|
||
| 订阅 | `/api/subscriptions` | ✅ 200 |
|
||
| AI | `/api/ai/status` | ✅ 200 |
|
||
| 管理 | `/api/admin/users`, `/admin/settings`, `/admin/scheduler`, `/admin/backups` | ✅ 200 |
|
||
| 调度器 | `/api/scheduler/tasks`, `/scheduler/status`, `POST .../run` | ✅ 200 |
|
||
| 其他 | `/api/recycle`, `/api/dlna/devices`, `/api/ws` | ✅ 200 |
|
||
| 缺失 | `/api/services` | ❌ 404 (Handler 未实现,非核心) |
|
||
|
||
### 前端验证
|
||
|
||
- 页面正常加载:WatchHistoryPage, PlaylistsPage, PosterWallPage, FavouritesPage
|
||
- 服务器日志无错误,仅 `/api/services` 404 为预期行为
|