init: AI Grading Assistant MVP
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="历史记录" width="800px" fullscreen :modal="false" @close="handleClose">
|
||||
<el-table :data="records" style="width: 100%" size="small" v-loading="loading">
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column prop="ai_score" label="AI分数" width="80" />
|
||||
<el-table-column prop="teacher_score" label="教师分数" width="80" />
|
||||
<el-table-column prop="confidence" label="可信度" width="80">
|
||||
<template #default="{ row }">
|
||||
{{ Math.round(row.confidence * 100) }}%
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="student_answer" label="答案摘要" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="created_at" label="时间" width="160" />
|
||||
<el-table-column label="操作" width="80" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button text size="small" type="danger" @click="deleteRecord(row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClose">关闭</el-button>
|
||||
<el-button size="small" @click="refresh">刷新</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { HistoryRecord } from '@/types'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const records = ref<HistoryRecord[]>([])
|
||||
|
||||
watch(() => appStore.isHistoryDialogOpen, (val) => {
|
||||
visible.value = val
|
||||
if (val) refresh()
|
||||
})
|
||||
|
||||
async function refresh() {
|
||||
loading.value = true
|
||||
try {
|
||||
if (window.electronAPI) {
|
||||
records.value = await window.electronAPI.history.list()
|
||||
}
|
||||
} catch {
|
||||
records.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRecord(id: number) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定删除该记录?', '提示')
|
||||
if (window.electronAPI) {
|
||||
await window.electronAPI.history.delete(id)
|
||||
ElMessage.success('已删除')
|
||||
refresh()
|
||||
}
|
||||
} catch { /* cancelled */ }
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
window.electronAPI?.dialog.close()
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="评分模板管理" width="600px" :modal="false" @close="handleClose">
|
||||
<div class="template-section">
|
||||
<el-form :model="form" size="small" inline>
|
||||
<el-form-item label="考试名称">
|
||||
<el-input v-model="form.name" placeholder="如:期末考试" />
|
||||
</el-form-item>
|
||||
<el-form-item label="课程">
|
||||
<el-input v-model="form.course" placeholder="如:Java" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="small" @click="saveTemplate">保存模板</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<el-table :data="templates" size="small" style="width: 100%">
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column prop="name" label="考试名称" min-width="150" />
|
||||
<el-table-column prop="course" label="课程" min-width="120" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="160" />
|
||||
<el-table-column label="操作" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button text size="small" @click="selectTemplate(row)">使用</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClose">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { useGradingStore } from '@/stores/grading'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const gradingStore = useGradingStore()
|
||||
const visible = ref(false)
|
||||
const templates = ref<any[]>([])
|
||||
const form = ref({ name: '', course: '' })
|
||||
|
||||
watch(() => appStore.isTemplateDialogOpen, (val) => {
|
||||
visible.value = val
|
||||
if (val) loadTemplates()
|
||||
})
|
||||
|
||||
async function loadTemplates() {
|
||||
if (window.electronAPI) {
|
||||
templates.value = await window.electronAPI.template.list()
|
||||
}
|
||||
}
|
||||
|
||||
async function saveTemplate() {
|
||||
if (!form.value.name || !form.value.course) {
|
||||
ElMessage.warning('请填写考试名称和课程')
|
||||
return
|
||||
}
|
||||
if (window.electronAPI) {
|
||||
await window.electronAPI.template.save(form.value)
|
||||
ElMessage.success('模板已保存')
|
||||
form.value = { name: '', course: '' }
|
||||
loadTemplates()
|
||||
}
|
||||
}
|
||||
|
||||
function selectTemplate(tpl: any) {
|
||||
gradingStore.setRubric(`考试: ${tpl.name}\n课程: ${tpl.course}\n请根据标准答案评分。`)
|
||||
ElMessage.success('已选择模板:' + tpl.name)
|
||||
handleClose()
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
window.electronAPI?.dialog.close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.template-section {
|
||||
padding: 8px 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user