fix: evaluation report P0/P1/P2 fixes, remove Docker, add upload UI

Backend:
- Add NotFoundException + BusinessException, return correct HTTP status (404/400)
- Add @Index on reports.project_id and reports.upload_time
- Add fileSize column to reports, populate on upload, return in DTO
- Cascade delete: deleting project now removes all reports (DB + files + PDFs)
- Delete report: also clean up pre-rendered PDF
- File upload MIME validation (extension + Content-Type)
- Remove duplicate @ExceptionHandler from ReportController
- Switch from System.err to SLF4J logger
- Handle MethodArgumentNotValid, MissingServletRequestPart, etc.

Frontend:
- Remove all Docker files (project uses 宝塔 panel deployment)
- Upgrade axios 1.6.8 -> 1.7.7 (CVE-2024-39338)
- Remove unused @vue-office/pptx + vue-demi (see CHANGELOG for rationale)
- Fix vite proxy port 37821 -> 30081
- Remove mock data fallback in production
- Add upload report UI (button + modal in ProjectDetail)
- Add create project UI (button + modal in ProjectList)
- Add filename search box in ProjectDetail
- New useApi methods: createProject, uploadReport, deleteProject, deleteReport
- FilePreview/ReportCard: show fileSize (was undefined before)

Docs:
- Add README.md (overview, quick start, structure)
- Add CHANGELOG.md (full change log + pptx removal rationale)
- Include EVALUATION_REPORT.md and blog-vibe-coding.md

Tests:
- All 73 backend tests pass
- All 43 frontend tests pass
- Updated test fixtures for new API contract
This commit is contained in:
2026-06-01 21:35:13 +08:00
parent 7000c186e2
commit afcd18c54f
77 changed files with 1498 additions and 2886 deletions
+89
View File
@@ -0,0 +1,89 @@
# 更新日志 / Changelog
记录项目重要变更。新增条目请按以下格式:
```
## [日期] 类别 - 简短描述
### 改动
- 文件 / 功能 / 行为
### 原因
- 原因
### 影响
- 兼容性 / 部署 / 用户操作
```
---
## 2026-06-01 修复 - 评测问题修复 (P0/P1/P2)
依据 `EVALUATION_REPORT.md`、code-review 与 product-review 报告综合修复。
### 后端修复
| # | 严重度 | 改动 | 文件 |
|---|--------|------|------|
| 1 | P0 | `reports.project_id` 添加数据库索引(同时给 `upload_time` 加索引) | `entity/Report.java` |
| 2 | P0 | `reports.file_size` 字段新增,上传时记录文件大小 | `entity/Report.java`, `dto/ReportResponse.java`, `service/ReportService.java` |
| 3 | P0 | 新增 `NotFoundException` / `BusinessException`,业务异常返回正确 HTTP 状态码(404/400 而非 500 | `exception/NotFoundException.java`, `exception/BusinessException.java`, `exception/GlobalExceptionHandler.java`, 所有 Service |
| 4 | P0/P1 | 移除 `ReportController` 底部的重复 `@ExceptionHandler`,统一由 `GlobalExceptionHandler` 处理 | `controller/ReportController.java` |
| 5 | P1 | 删除项目时级联清理 reports 记录、原文件、预渲染 PDF,并清理空项目目录 | `service/ProjectService.java` |
| 6 | P1 | 删除报告时同时清理预渲染 PDF 文件 | `service/ReportService.java` |
| 7 | P1 | 文件上传校验:文件扩展名必须与声明的 `fileType` 匹配 + `Content-Type` 白名单 | `service/ReportService.java#validateMimeType` |
| 8 | P1 | 日志改用 SLF4J Logger(替代 `System.err.println`),支持日志级别控制 | 所有 Service / Controller / Handler |
| 9 | P2 | `MultipartException` / `MaxUploadSizeExceededException` 返回 400/413 而非 500 | `exception/GlobalExceptionHandler.java` |
### 前端修复
| # | 严重度 | 改动 | 文件 |
|---|--------|------|------|
| 1 | P0 | **新建项目 UI**:在 ProjectList 顶部加"新建项目"按钮 + 模态框(名称必填 + 描述可选) | `pages/ProjectList.vue` |
| 2 | P0 | **上传报告 UI**:在 ProjectDetail 侧边栏加"上传"按钮 + 模态框(文件选择 + 类型选择 + 扩展名自动识别) | `pages/ProjectDetail.vue` |
| 3 | P1 | axios 升级 `^1.6.8``^1.7.7`(修复 CVE-2024-39338 SSRF / Cookie 泄漏) | `package.json` |
| 4 | P1 | **删除**未使用的 `@vue-office/pptx``vue-demi` 依赖(见下文说明) | `package.json` |
| 5 | P1 | 移除生产环境的 mock 数据静默降级(避免用户看到假数据) | `composables/useApi.js` |
| 6 | P1 | `useApi.js` 错误处理统一:不再吞错,返回明确错误信息 | `composables/useApi.js` |
| 7 | P1 | 修复 vite proxy 端口:`37821``30081`(与后端一致) | `vite.config.js` |
| 8 | P2 | 新增 `createProject` / `uploadReport` / `deleteProject` / `deleteReport` API 方法 | `composables/useApi.js` |
| 9 | P2 | 报告列表加文件名搜索框(实时过滤、显示匹配数) | `pages/ProjectDetail.vue` |
| 10 | P2 | 上传按钮在空状态时也显示(引导用户上传第一份报告) | `pages/ProjectDetail.vue` |
### 部署相关
| # | 改动 | 文件 |
|---|------|------|
| 1 | **删除**所有 Docker 部署相关文件(项目已改用宝塔面板部署) | `Dockerfile`, `Dockerfile.frontend`, `docker-compose.yml`, `nginx.conf`, `.dockerignore` |
| 2 | 移除 `useApi.js``mockProjects` / `mockReports` / `mockReportContent` 硬编码数据 | `composables/useApi.js` |
---
## 关于 `@vue-office/pptx` 依赖的说明
### 为什么 package.json 里曾经有但代码里没有引用?
`@vue-office/pptx` 是一个**纯前端**的 PPTX 渲染库(基于 Vue 组件在浏览器里把 PPTX 拆开渲染)。最初加入时考虑用它做 PPTX 预览,但后来发现:
1. **前端解析 PPTX 太重**:单文件动辄 10-50 MB,把整个文件传到浏览器用 JS 拆解预览,会显著拖慢首屏、增加带宽占用
2. **后端已有更好的方案**:我们用 Apache POI + PDFBox 在后端**预渲染** PPTX 为 PDF`PptxToPdfService.java`,上传时自动执行并存到 `uploads/{projectId}/pdfs/`),前端直接 `<iframe src="...pdf">` 即可预览
3. **`vue-demi``@vue-office/pptx` 的运行时依赖**,纯粹是因为这个库没用才一起被删除的
### 删除影响
无。生产环境从未使用 `@vue-office/pptx` 渲染任何 PPTX,所有 PPTX 预览都走后端的 PDF 预渲染。`package.json` 移除可减少 ~5 MB 安装体积 + 减少打包时间。
### 为什么不反过来用前端库做预览?
后端预渲染的方案有几个优势:
- PPTX 转 PDF 是耗时操作(数秒到数十秒),放在后端异步做可以**上传完即返回**,前端不卡
- PDF 是**通用格式**,未来支持移动端/iframe 沙箱/打印都更稳定
- 前端只负责展示一个 PDF 文件,不需要解析 PPTX 内部结构
如果未来需要支持 PPT 编辑态预览,再单独评估。
---
## 2026-05-24 之前的变更
历史变更请参考 git log`git log --oneline`