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
+137 -73
View File
@@ -3,42 +3,23 @@ import { ref } from 'vue'
const api = axios.create({
baseURL: '/api',
timeout: 10000
timeout: 30000
})
// Mock data for development
const mockProjects = [
{ id: 1, name: '项目一', description: '主要产品线', reportCount: 15, todayNewReports: 2 },
{ id: 2, name: '项目二', description: '内部工具', reportCount: 8, todayNewReports: 1 },
{ id: 3, name: '项目三', description: '客户定制', reportCount: 12, todayNewReports: 0 }
]
const mockReports = {
1: [
{ id: 101, fileName: '2026-05-22 日报.html', fileType: 'html', reportDate: '2026-05-22', size: '15KB' },
{ id: 102, fileName: '2026-05-21 日报.md', fileType: 'md', reportDate: '2026-05-21', size: '8KB' },
{ id: 103, fileName: '2026-05-20 周报.pptx', fileType: 'pptx', reportDate: '2026-05-20', size: '256KB' }
],
2: [
{ id: 201, fileName: '2026-05-22 开发日报.html', fileType: 'html', reportDate: '2026-05-22', size: '12KB' },
{ id: 202, fileName: '2026-05-21 开发日报.html', fileType: 'html', reportDate: '2026-05-21', size: '11KB' }
],
3: [
{ id: 301, fileName: '2026-05-22 进度报告.md', fileType: 'md', reportDate: '2026-05-22', size: '10KB' },
{ id: 302, fileName: '2026-05-21 进度报告.md', fileType: 'md', reportDate: '2026-05-21', size: '9KB' }
]
}
const mockReportContent = {
html: '<html><body><h1>日报内容</h1><p>这是一份HTML格式的日报。</p></body></html>',
md: '# 日报标题\n\n## 工作内容\n\n1. 完成功能A\n2. 进行代码审查\n3. 修复Bug\n\n## 明日计划\n\n- 继续开发功能B\n- 优化性能',
pptx: null
}
export function useApi() {
const loading = ref(false)
const error = ref(null)
const handleError = (e, fallback = null) => {
const status = e?.response?.status
const message = e?.response?.data?.error || e?.message || 'Request failed'
error.value = { status, message }
console.error(`API error [${status}]:`, message)
if (fallback !== null) return fallback
throw e
}
// ============== Projects ==============
const fetchProjects = async () => {
loading.value = true
error.value = null
@@ -46,70 +27,41 @@ export function useApi() {
const response = await api.get('/projects')
return response.data
} catch (e) {
// Use mock data if API fails
console.warn('API not available, using mock data')
return mockProjects
handleError(e, [])
return []
} finally {
loading.value = false
}
}
const fetchReports = async (projectId) => {
const fetchProject = async (id) => {
loading.value = true
error.value = null
try {
const response = await api.get(`/reports?projectId=${projectId}`)
const response = await api.get(`/projects/${id}`)
return response.data
} catch (e) {
console.warn('API not available, using mock data')
return mockReports[projectId] || []
handleError(e, null)
return null
} finally {
loading.value = false
}
}
const fetchReportContent = async (reportId) => {
const createProject = async (data) => {
loading.value = true
error.value = null
try {
// Backend GET /api/reports/{id} returns ReportResponse with fileContent field
const response = await api.get(`/reports/${reportId}`)
return { content: response.data.fileContent, type: response.data.fileType }
const response = await api.post('/projects', data)
return response.data
} catch (e) {
console.warn('API not available, using mock data')
// Find the report type from mock data
for (const reports of Object.values(mockReports)) {
const report = reports.find(r => r.id === reportId)
if (report) {
return { content: mockReportContent[report.fileType], type: report.fileType }
}
}
handleError(e, null)
return null
} finally {
loading.value = false
}
}
const fetchReportBytes = async (reportId) => {
try {
const response = await api.get(`/reports/${reportId}/download`, { responseType: 'arraybuffer' })
return response.data
} catch (e) {
console.warn('Failed to fetch report bytes:', e)
return null
}
}
const fetchReportPdf = async (reportId) => {
try {
const response = await api.get(`/reports/${reportId}/pdf`, { responseType: 'arraybuffer' })
return new Blob([response.data], { type: 'application/pdf' })
} catch (e) {
console.warn('Failed to fetch report PDF:', e)
return null
}
}
const updateProject = async (id, data) => {
loading.value = true
error.value = null
@@ -120,25 +72,137 @@ export function useApi() {
headers: { 'Content-Type': 'multipart/form-data' }
})
} else {
response = await api.put(`/projects/${id}`, data)
// Wrap in FormData for multipart backend endpoint
const formData = new FormData()
if (data.name != null) formData.append('name', data.name)
if (data.description != null) formData.append('description', data.description)
response = await api.put(`/projects/${id}`, formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
return response.data
} catch (e) {
console.warn('API not available, failed to update project:', e)
handleError(e, null)
return null
} finally {
loading.value = false
}
}
const deleteProject = async (id) => {
loading.value = true
error.value = null
try {
await api.delete(`/projects/${id}`)
return true
} catch (e) {
handleError(e, false)
return false
} finally {
loading.value = false
}
}
// ============== Reports ==============
const fetchReports = async (projectId) => {
loading.value = true
error.value = null
try {
const response = await api.get(`/reports`, {
params: projectId ? { projectId } : {}
})
return response.data
} catch (e) {
handleError(e, [])
return []
} finally {
loading.value = false
}
}
const fetchReportContent = async (reportId) => {
loading.value = true
error.value = null
try {
const response = await api.get(`/reports/${reportId}`)
return { content: response.data.fileContent, type: response.data.fileType }
} catch (e) {
handleError(e, null)
return null
} finally {
loading.value = false
}
}
const fetchReportBytes = async (reportId) => {
try {
const response = await api.get(`/reports/${reportId}/download`, { responseType: 'arraybuffer' })
return response.data
} catch (e) {
handleError(e, null)
return null
}
}
const fetchReportPdf = async (reportId) => {
try {
const response = await api.get(`/reports/${reportId}/pdf`, { responseType: 'arraybuffer' })
return new Blob([response.data], { type: 'application/pdf' })
} catch (e) {
handleError(e, null)
return null
}
}
const uploadReport = async (file, projectId, fileType) => {
loading.value = true
error.value = null
try {
const formData = new FormData()
formData.append('file', file)
formData.append('projectId', projectId)
formData.append('fileType', fileType)
const response = await api.post('/reports', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
return response.data
} catch (e) {
handleError(e, null)
return null
} finally {
loading.value = false
}
}
const deleteReport = async (id) => {
loading.value = true
error.value = null
try {
await api.delete(`/reports/${id}`)
return true
} catch (e) {
handleError(e, false)
return false
} finally {
loading.value = false
}
}
return {
loading,
error,
// projects
fetchProjects,
fetchProject,
createProject,
updateProject,
deleteProject,
// reports
fetchReports,
fetchReportContent,
fetchReportBytes,
fetchReportPdf,
updateProject
uploadReport,
deleteReport
}
}
}