feat: 新增重置控制端的功能;前端可以显示提交记录 fix: 修复资源数据库sha256计算问题;修复资源数据库无法上传的问题

This commit is contained in:
2025-08-20 10:20:30 +08:00
parent c8444d1d4e
commit ec84eeeaa4
9 changed files with 4143 additions and 56 deletions

View File

@@ -1,9 +1,12 @@
<script setup lang="ts">
import { useRequiredInjection } from "@/utils/Common";
import { templateRef } from "@vueuse/core";
import { File, UploadIcon, XIcon } from "lucide-vue-next";
import { isNull } from "mathjs";
import { useSlots } from "vue";
import { useAlertStore } from "./Alert";
const alert = useRequiredInjection(useAlertStore);
const slots = useSlots();
interface Props {
@@ -17,6 +20,10 @@ const props = withDefaults(defineProps<Props>(), {
closeAfterUpload: false,
});
const emits = defineEmits<{
finishedUpload: [];
}>();
const inputFiles = defineModel<File[] | null>("inputFiles", { default: null });
const isShowModal = defineModel<boolean>("isShowModal", { default: false });
@@ -42,6 +49,8 @@ function handleUpload() {
if (!inputFiles.value) return;
props.callback(inputFiles.value);
if (props.closeAfterUpload) close();
alert.info("上传成功");
emits("finishedUpload");
}
function show() {

View File

@@ -161,17 +161,17 @@
>
暂无提交记录
</div>
<div v-else class="overflow-y-auto">
<div v-else class="overflow-y-auto fit-content max-h-50">
<ul class="steps steps-vertical">
<li
class="step"
:class="{ 'step-primary': _idx === 1 }"
v-for="(commit, _idx) in commitsList.slice(0, 3)"
:class="{
'step-primary': _idx === commitsList.length - 1,
}"
v-for="(commit, _idx) in commitsList"
>
{{ commit.id }} ---
{{ commit.uploadTime.toDateString() }}
{{ commit.uploadTime.toTimeString() }}
</li>
<li class="step" v-if="commitsList.length > 3">......</li>
</ul>
</div>
</div>
@@ -214,7 +214,9 @@
ref="uploadModal"
class="fixed z-auto"
:auto-upload="true"
:close-after-upload="true"
:callback="submitExam"
@finished-upload="handleSubmitFinished"
/>
</div>
</template>
@@ -234,11 +236,12 @@ import { useRouter } from "vue-router";
import { formatDate } from "@/utils/Common";
import { computed } from "vue";
import { watch } from "vue";
import { isNull, isUndefined } from "lodash";
import { delay, isNull, isUndefined } from "lodash";
import { Download, GitGraph, Smile, Upload, XIcon } from "lucide-vue-next";
import UploadModal from "@/components/UploadModal.vue";
import { templateRef } from "@vueuse/core";
import { toFileParameter } from "@/utils/Common";
import { onMounted } from "vue";
const alertStore = useRequiredInjection(useAlertStore);
const router = useRouter();
@@ -259,11 +262,23 @@ async function updateCommits() {
const list = await client.getCommitsByExamId(props.selectedExam.id);
commitsList.value = list;
}
watch(() => props.selectedExam, updateCommits);
watch(
() => show.value,
() => {
if (show.value) {
updateCommits();
}
},
);
onMounted(() => {
if (show.value) {
updateCommits();
}
});
// Download resources
const downloadingResources = ref(false);
const downloadResources = async () => {
async function downloadResources() {
if (!props.selectedExam || downloadingResources.value) return;
downloadingResources.value = true;
@@ -311,10 +326,10 @@ const downloadResources = async () => {
} finally {
downloadingResources.value = false;
}
};
}
// 开始实验
const startExam = () => {
function startExam() {
if (props.selectedExam) {
// 跳转到项目页面传递实验ID
console.log("开始实验:", props.selectedExam.id);
@@ -323,9 +338,9 @@ const startExam = () => {
query: { examId: props.selectedExam.id },
});
}
};
}
const submitExam = (files: File[]) => {
function submitExam(files: File[]) {
try {
const client = AuthManager.createClient(ResourceClient);
@@ -341,11 +356,17 @@ const submitExam = (files: File[]) => {
alertStore.error(err.message || "上传资料失败");
console.error("上传资料失败:", err);
}
};
}
const closeExamDetail = () => {
async function handleSubmitFinished() {
delay(async () => {
await updateCommits();
}, 1000);
}
function closeExamDetail() {
show.value = false;
};
}
</script>
<style lang="postcss" scoped></style>