init: AI Grading Assistant MVP

This commit is contained in:
2026-07-15 21:54:21 +08:00
commit 3b1dc16489
34 changed files with 10266 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
export interface GradeResult {
score: number
confidence: number
deductions: string[]
comment: string
commit?: string
}
export interface ApiConfig {
apiKey: string
baseUrl: string
model: string
}
export interface AppSettings {
apiKey: string
baseUrl: string
model: string
shortcut: string
theme: string
fontSize: number
proxy: string
timeout: number
screenshotSavePath: string
}
export interface HistoryRecord {
id: number
question_id: number
image_path: string
student_answer: string
ai_score: number
teacher_score: number
confidence: number
created_at: string
}
export interface ElectronAPI {
window: {
dragMove: (deltaX: number, deltaY: number) => Promise<void>
dragEnd: (x: number, y: number) => Promise<void>
}
screenshot: {
start: () => Promise<void>
capture: (region: { x: number; y: number; width: number; height: number }) => Promise<string | null>
cancel: () => Promise<void>
getLastImage: () => Promise<string | null>
onCompleted: (callback: (base64: string) => void) => () => void
}
ai: {
grade: (data: { imageBase64: string; rubric: string; apiConfig: ApiConfig; maxScore?: number; referenceAnswer?: string; questionTitle?: string }) => Promise<GradeResult>
}
settings: {
get: () => Promise<AppSettings>
set: (settings: Record<string, unknown>) => Promise<boolean>
selectDirectory: () => Promise<string | null>
}
history: {
list: () => Promise<HistoryRecord[]>
delete: (id: number) => Promise<boolean>
}
grading: {
submit: (data: {
questionId: number
imagePath: string
aiScore: number
teacherScore: number
confidence: number
studentAnswer?: string
}) => Promise<boolean>,
storeData: (data: any) => Promise<void>,
getData: () => Promise<any>
}
rubric: {
storeData: (data: any) => Promise<void>
getData: () => Promise<any>
}
template: {
list: () => Promise<unknown[]>
save: (data: { name: string; course: string }) => Promise<number | null>
}
dialog: {
open: (type: string, data?: any) => Promise<void>
close: () => void
getPayload: (type: string) => Promise<any>
openImage: () => Promise<{ base64: string; mime: string; filePath: string } | null>
}
}
declare global {
interface Window {
electronAPI: ElectronAPI
}
}