fix: 上一题/下一题不再调 AI API,改为保存后关闭并推进索引

This commit is contained in:
2026-07-16 07:30:51 +08:00
parent 8ea2dd38d7
commit cfe906bb60
6 changed files with 40 additions and 9 deletions
+22 -5
View File
@@ -9,9 +9,9 @@
<div class="drawer-body" v-if="gradingStore.currentResult">
<div class="error-message" v-if="errorMsg">{{ errorMsg }}</div>
<div class="question-nav" v-if="questions.length > 1">
<el-button size="small" @click="prevQuestion" :disabled="isGrading">上一题</el-button>
<el-button size="small" @click="prevQuestion">上一题</el-button>
<span class="question-indicator">{{ currentIdx + 1 }} / {{ questions.length }}</span>
<el-button size="small" @click="nextQuestion" :disabled="isGrading">{{ currentIdx === questions.length - 1 ? '回到首题' : '下一题' }}</el-button>
<el-button size="small" @click="nextQuestion">{{ currentIdx === questions.length - 1 ? '回到首题' : '下一题' }}</el-button>
</div>
<div class="question-title" v-if="currentQuestion.questionTitle">
@@ -153,7 +153,6 @@ async function gradeAt(idx: number) {
gradingStore.setResult(result)
currentIdx.value = idx
gradingStore.setCurrentQuestionIndex(idx)
// update grading bridge
await window.electronAPI?.grading.storeData({
result,
image: gradingStore.currentImage,
@@ -170,12 +169,30 @@ async function gradeAt(idx: number) {
async function nextQuestion() {
const next = (currentIdx.value + 1) % questions.value.length
await gradeAt(next)
await saveAndAdvance(next)
}
async function prevQuestion() {
const prev = (currentIdx.value - 1 + questions.value.length) % questions.value.length
await gradeAt(prev)
await saveAndAdvance(prev)
}
async function saveAndAdvance(targetIdx: number) {
try {
await window.electronAPI.grading.submit({
questionId: 0,
imagePath: '',
aiScore: gradingStore.currentResult?.score ?? 0,
teacherScore: teacherScore.value,
confidence: gradingStore.currentResult?.confidence ?? 0,
studentAnswer: ''
})
await window.electronAPI?.rubric.setNextIndex(targetIdx)
gradingStore.reset()
closeDrawer()
} catch (err) {
ElMessage.error('保存失败:' + (err as Error).message)
}
}
async function reGrade() {