|
|
@@ -1000,10 +1000,12 @@ const handleHistoryItem = async (historyItem) => {
|
|
|
});
|
|
|
console.log(response.data)
|
|
|
if (response.statusCode === 200 && response.data && response.data.length > 0) {
|
|
|
- const latestRecord = response.data[response.data.length - 1];
|
|
|
+ const latestRecord = [...response.data].reverse().find(record => record.type === 'ai' && record.content)
|
|
|
+ || [...response.data].reverse().find(record => record.content)
|
|
|
+ || response.data[response.data.length - 1];
|
|
|
console.log('获取到的试卷数据:', latestRecord);
|
|
|
console.log('试卷数据结构:', JSON.stringify(latestRecord, null, 2));
|
|
|
- currentTime.value = formatTime(latestRecord.created_at)
|
|
|
+ currentTime.value = latestRecord?.created_at ? formatTime(latestRecord.created_at) : historyItem.time
|
|
|
if (latestRecord && latestRecord.content) {
|
|
|
try {
|
|
|
const examData = extractExamDataFromContent(latestRecord.content);
|
|
|
@@ -1011,22 +1013,18 @@ const handleHistoryItem = async (historyItem) => {
|
|
|
showExamDetail.value = true;
|
|
|
} catch (error) {
|
|
|
console.error('解析试卷数据失败:', error);
|
|
|
- showExamDetail.value = true;
|
|
|
- currentTime.value = historyItem.time;
|
|
|
+ ElMessage.error('恢复试卷失败,请稍后重试');
|
|
|
}
|
|
|
} else {
|
|
|
- showExamDetail.value = true;
|
|
|
- currentTime.value = historyItem.time;
|
|
|
+ ElMessage.error('暂无可恢复的试卷内容');
|
|
|
}
|
|
|
} else {
|
|
|
console.error('获取历史记录详情失败:', response);
|
|
|
- showExamDetail.value = true;
|
|
|
- currentTime.value = historyItem.time;
|
|
|
+ ElMessage.error('获取历史记录详情失败,请稍后重试');
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('获取历史记录详情失败:', error);
|
|
|
- showExamDetail.value = true;
|
|
|
- currentTime.value = historyItem.time;
|
|
|
+ ElMessage.error('获取历史记录详情失败,请稍后重试');
|
|
|
} finally {
|
|
|
isLoadingHistoryItem.value = false;
|
|
|
}
|