feat: improve report generation workflow

This commit is contained in:
2026-06-26 00:11:29 +08:00
parent 1c5841833f
commit 0b2a8b0190
27 changed files with 2662 additions and 717 deletions
+43 -2
View File
@@ -8,13 +8,15 @@ const api = {
ipcRenderer.invoke('student:delete-profile', profileId),
exportEmptyClassFolder: (payload: { className: string; classId: string; childNames: string[] }) =>
ipcRenderer.invoke('classes:export-empty-folder', payload),
loadStudentData: () => ipcRenderer.invoke('student:load'),
loadStudentData: (payload?: { includeProfiles?: boolean; includeImages?: boolean }) =>
ipcRenderer.invoke('student:load', payload),
listStudentProfiles: (payload: {
page: number
pageSize: number
query?: string
classId?: string
}) => ipcRenderer.invoke('student:list', payload),
getStudentProfile: (profileId: string) => ipcRenderer.invoke('student:get-profile', profileId),
updateStudentProfile: (profile: {
id: string
classId: string
@@ -31,6 +33,10 @@ const api = {
traits: string
comment: string
commentGeneratedAt: string
reportGenerated: boolean
meImage: string
workImage1: string
workImage2: string
importedAt: string
}) => ipcRenderer.invoke('student:update-profile', profile),
generateStudentComment: (payload: { profileId: string }) =>
@@ -51,6 +57,7 @@ const api = {
id: string
name: string
type: 'cheap' | 'noble'
teacherNames: string[]
familyPhoto?: string
}
profiles: Array<{
@@ -67,6 +74,12 @@ const api = {
favoriteGames: string[]
favoriteFoods: string[]
traits: string
comment?: string
commentGeneratedAt?: string
reportGenerated?: boolean
meImage?: string
workImage1?: string
workImage2?: string
importedAt: string
}>
}) => ipcRenderer.invoke('student:replace-class-profiles', payload),
@@ -75,6 +88,7 @@ const api = {
id: string
name: string
type: 'cheap' | 'noble'
teacherNames: string[]
familyPhoto?: string
}>
profiles: Array<{
@@ -91,6 +105,12 @@ const api = {
favoriteGames: string[]
favoriteFoods: string[]
traits: string
comment?: string
commentGeneratedAt?: string
reportGenerated?: boolean
meImage?: string
workImage1?: string
workImage2?: string
importedAt: string
}>
}) => ipcRenderer.invoke('student:migrate-local', payload),
@@ -99,6 +119,7 @@ const api = {
id: string
name: string
type: 'cheap' | 'noble'
teacherNames: string[]
familyPhoto?: string
}>
) => ipcRenderer.invoke('student:save-classes', classes),
@@ -124,7 +145,6 @@ const api = {
semester: 'first' | 'second'
type: 'portrait' | 'landscape'
sourceFilePath: string
fieldMappings?: Record<string, string>
}) => ipcRenderer.invoke('templates:save', template),
openTemplate: (filePath: string) => ipcRenderer.invoke('templates:open', filePath),
deleteTemplate: (id: string) => ipcRenderer.invoke('templates:delete', id),
@@ -132,6 +152,27 @@ const api = {
generateReports: (payload: { templateId: string; classId: string; studentIds?: string[] }) =>
ipcRenderer.invoke('reports:generate', payload),
openReport: (filePath: string) => ipcRenderer.invoke('reports:open', filePath),
downloadReport: (id: string) => ipcRenderer.invoke('reports:download', id),
downloadClassReports: (payload: { classId: string }) =>
ipcRenderer.invoke('reports:download-class', payload),
onReportGenerationProgress: (callback: (progress: {
batchId: string
status: 'started' | 'student-started' | 'student-finished' | 'student-failed' | 'finished'
classId: string
className: string
studentId?: string
studentName?: string
current: number
total: number
report?: unknown
error?: string
}) => void) => {
const listener = (_: Electron.IpcRendererEvent, progress: Parameters<typeof callback>[0]) =>
callback(progress)
ipcRenderer.on('reports:generation-progress', listener)
return () => ipcRenderer.removeListener('reports:generation-progress', listener)
},
deleteReport: (id: string) => ipcRenderer.invoke('reports:delete', id)
}