完成了学生端点击提交后开启算法,设置算法为异步操作,其中使用了longRequest来避免超时警告。

剩余一些细节调整,大体已经全部完成。
This commit is contained in:
musteven 2025-04-20 14:57:14 +08:00
parent 621b40fb5e
commit 0e2ce0008a
1 changed files with 23 additions and 10 deletions

View File

@ -11,11 +11,14 @@ import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import api from '@/api/user'; import api from '@/api/user';
import {ElMessage, ElMessageBox} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
import {longRequest} from "@/utils";
const route = useRoute(); const route = useRoute();
const isClicked = ref(false); const isClicked = ref(false);
const ProblemId = route.params.examId; const ProblemId = route.params.examId;
const isCheckingPlagiarism = ref(false); // 查重状态
const props = defineProps({ const props = defineProps({
fileUrls: Array, fileUrls: Array,
adminuserId: [String], adminuserId: [String],
@ -89,13 +92,12 @@ const onSaveAndSubmit = async () => {//保存并提交
adminuserId adminuserId
}; };
const res = await api.submitInfoToProps(submitReport1); const res = await api.submitInfoToProps(submitReport1);
// 提交成功后,调用查重函数
await checkPlagiarism(); // 提交成功后,调用查重函数并后台挂起
checkPlagiarismInBackground();
emit('clickSaveAndSubmit'); emit('clickSaveAndSubmit');
emit('refreshAttachment'); emit('refreshAttachment');
ElMessage.success('提交成功!'); ElMessage.success('提交成功!正在后台进行查重...');
} catch (error) { } catch (error) {
} }
@ -130,7 +132,8 @@ const onWithdraw = () => { //撤回提交
}; };
// 查重函数 // 查重函数
const checkPlagiarism = async () => { const checkPlagiarismInBackground = async () => {
isCheckingPlagiarism.value = true; // 开始查重,更新状态
try{ try{
// 获取文件名 // 获取文件名
const attachment = props.attachment; const attachment = props.attachment;
@ -142,16 +145,26 @@ const checkPlagiarism = async () => {
attachment attachment
}; };
// 调用查重接口 // 调用查重接口,使用永不超时longRequest
const res = await api.runPlagiarism(submitReport); const res = await longRequest.post('/plagiarism/runPlagiarism', submitReport);
console.log('查重结果:', res); console.log('查重结果:', res);
ElMessage.success('查重成功!');
// 查重完成,更新状态
isCheckingPlagiarism.value = false;
} catch (error) { } catch (error) {
ElMessage.error('查重过程中发生错误!'); ElMessage.error('查重过程中发生错误!');
isCheckingPlagiarism.value = false; // 查重失败,也要更新状态
} }
}; };
// 监听查重状态变化,用于通知用户
watch(isCheckingPlagiarism, (newValue) => {
if (!newValue) {
// 查重完成,可以在这里通知用户
ElMessage.success('查重操作已完成!');
}
});
</script> </script>
<style scoped> <style scoped>