feat: improve report generation workflow
This commit is contained in:
@@ -3,9 +3,11 @@ import { ipcMain } from 'electron'
|
||||
import {
|
||||
deleteClassWithProfiles,
|
||||
deleteStudentProfile,
|
||||
getStudentProfile,
|
||||
generateStudentComment,
|
||||
listStudentProfiles,
|
||||
loadStudentData,
|
||||
migrateStoredImagesToFiles,
|
||||
migrateLocalStudentData,
|
||||
replaceProfilesForClass,
|
||||
saveClasses,
|
||||
@@ -18,6 +20,8 @@ import type {
|
||||
DeleteStudentProfileResponse,
|
||||
GenerateStudentCommentInput,
|
||||
GenerateStudentCommentResponse,
|
||||
GetStudentProfileResponse,
|
||||
LoadStudentDataInput,
|
||||
ListStudentProfilesInput,
|
||||
ListStudentProfilesResponse,
|
||||
LoadStudentDataResponse,
|
||||
@@ -32,9 +36,13 @@ function getErrorMessage(error: unknown): string {
|
||||
}
|
||||
|
||||
export function registerStudentIpc(): void {
|
||||
ipcMain.handle('student:load', async (): Promise<LoadStudentDataResponse> => {
|
||||
void migrateStoredImagesToFiles().catch((error) => {
|
||||
console.error('[图片迁移] 迁移 SQLite 内图片到文件失败', error)
|
||||
})
|
||||
|
||||
ipcMain.handle('student:load', async (_, payload?: LoadStudentDataInput): Promise<LoadStudentDataResponse> => {
|
||||
try {
|
||||
const studentData = await loadStudentData()
|
||||
const studentData = await loadStudentData(payload)
|
||||
return {
|
||||
ok: true,
|
||||
...studentData
|
||||
@@ -64,6 +72,23 @@ export function registerStudentIpc(): void {
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
'student:get-profile',
|
||||
async (_, profileId: string): Promise<GetStudentProfileResponse> => {
|
||||
try {
|
||||
return {
|
||||
ok: true,
|
||||
profile: await getStudentProfile(profileId)
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
ok: false,
|
||||
message: getErrorMessage(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
'student:update-profile',
|
||||
async (_, payload: UpdateStudentProfileInput): Promise<UpdateStudentProfileResponse> => {
|
||||
|
||||
Reference in New Issue
Block a user