提交 2d105ddf authored 作者: 王鹏飞's avatar 王鹏飞

feat: 更新依赖项,提升性能和稳定性;优化AI评分逻辑,确保评分数据的准确性

上级 4f5ee120
差异被折叠。
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
"sass-embedded": "^1.93.3", "sass-embedded": "^1.93.3",
"typescript": "~5.6.3", "typescript": "~5.6.3",
"unplugin-auto-import": "^20.2.0", "unplugin-auto-import": "^20.2.0",
"vite": "^7.1.12", "vite": "^7.3.6",
"vite-plugin-checker": "^0.11.0", "vite-plugin-checker": "^0.11.0",
"vite-plugin-mkcert": "^1.17.9", "vite-plugin-mkcert": "^1.17.9",
"vue-tsc": "^2.1.10" "vue-tsc": "^2.1.10"
......
...@@ -30,7 +30,11 @@ export function useLiveRecord({ id = '', immediate = false }: { id?: string; imm ...@@ -30,7 +30,11 @@ export function useLiveRecord({ id = '', immediate = false }: { id?: string; imm
{ role: 'system', content: systemPrompt }, { role: 'system', content: systemPrompt },
{ role: 'user', content: getUserPrompt(liveRecord.value) }, { role: 'user', content: getUserPrompt(liveRecord.value) },
] ]
const result = await generateText({ messages, response_format: { type: 'json_object' } } as any) const result = await generateText({
model: 'deepseek-v4-flash-260425',
messages,
response_format: { type: 'json_object' },
} as any)
if (!result) return if (!result) return
const aiAnalyze = result.content const aiAnalyze = result.content
.replaceAll('卖点讲解覆盖情况', '') .replaceAll('卖点讲解覆盖情况', '')
......
...@@ -193,7 +193,8 @@ ${JSON.stringify(outputExample, null, 2)}` ...@@ -193,7 +193,8 @@ ${JSON.stringify(outputExample, null, 2)}`
total_score: totalScore, total_score: totalScore,
updated_at: new Date().toLocaleString(), updated_at: new Date().toLocaleString(),
} }
const scores = [...detail.scores.filter((item: any) => item.checker_id != userStore.user?.id), myScore] // AI 评分全局唯一:清掉所有旧 AI 评分(含其他评分人的),并去掉本人历史评分,只保留最后一个人操作的 AI 评分
const scores = [...detail.scores.filter((item: any) => !item.is_ai && item.checker_id != userStore.user?.id), myScore]
const scoresForTotal = includeAIScore ? scores : scores.filter((item) => !item.is_ai) const scoresForTotal = includeAIScore ? scores : scores.filter((item) => !item.is_ai)
const totalAverageScore = scoresForTotal.length const totalAverageScore = scoresForTotal.length
? scoresForTotal.reduce((acc, curr) => acc + (curr.total_score || 0), 0) / scoresForTotal.length ? scoresForTotal.reduce((acc, curr) => acc + (curr.total_score || 0), 0) / scoresForTotal.length
......
...@@ -4,6 +4,9 @@ import { ElMessage } from 'element-plus' ...@@ -4,6 +4,9 @@ import { ElMessage } from 'element-plus'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useEventListener } from '@vueuse/core' import { useEventListener } from '@vueuse/core'
import { useScore } from '../composables/useScore'
const { isLoading, handleAIScore } = useScore()
const router = useRouter() const router = useRouter()
const userStore = useUserStore() const userStore = useUserStore()
...@@ -48,7 +51,12 @@ const fetchDetail = async () => { ...@@ -48,7 +51,12 @@ const fetchDetail = async () => {
scores = [] scores = []
} }
const myScore = scores.find((item) => item.checker_id == userStore.user.id && !item.is_ai)?.scores const myScore = scores.find((item) => item.checker_id == userStore.user.id && !item.is_ai)?.scores
const aiScore = scores.find((item) => item.is_ai)?.scores // 优先取当前评分人的 AI 评分,其次取最新的 AI 评分(避免命中历史数据生成的旧 AI 评分)
const myAIScore = scores.find((item) => item.checker_id == userStore.user.id && item.is_ai)?.scores
const latestAIScore = scores
.filter((item) => item.is_ai)
.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime())[0]?.scores
const aiScore = myAIScore || latestAIScore
Object.assign(scoreDetails, cloneDeep(myScore || aiScore || {})) Object.assign(scoreDetails, cloneDeep(myScore || aiScore || {}))
} }
...@@ -86,6 +94,21 @@ const commitScore = (status = 1, isAI = false) => { ...@@ -86,6 +94,21 @@ const commitScore = (status = 1, isAI = false) => {
score_details: JSON.stringify(scores), score_details: JSON.stringify(scores),
}) })
} }
const handleAIScoreBtn = async () => {
isLoading.value = true
try {
// 页面已加载详情数据,直接复用本地数据(detail 无 scores 字段,补充解析好的 scores)
await handleAIScore({ ...detail.value, scores })
ElMessage.success('AI评分完成')
// 刷新详情,将 AI 评分回填到当前页面
await fetchDetail()
} catch (error) {
console.error('AI评分失败:', error)
ElMessage.error('AI评分失败')
} finally {
isLoading.value = false
}
}
const handlePublishScore = async () => { const handlePublishScore = async () => {
await commitScore(2) await commitScore(2)
ElMessage.success('提交成绩成功') ElMessage.success('提交成绩成功')
...@@ -119,6 +142,7 @@ useEventListener(window, 'pagehide', () => { ...@@ -119,6 +142,7 @@ useEventListener(window, 'pagehide', () => {
<el-form-item label="状态">{{ detail.check_status_name }}</el-form-item> <el-form-item label="状态">{{ detail.check_status_name }}</el-form-item>
<el-form-item label="提交时间">{{ detail.commit_time }}</el-form-item> <el-form-item label="提交时间">{{ detail.commit_time }}</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" :loading="isLoading" @click="handleAIScoreBtn">AI一键评分</el-button>
<el-button type="primary" @click="handlePublishScore">提交成绩</el-button> <el-button type="primary" @click="handlePublishScore">提交成绩</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论