From 82822d6c92eb4851ceecba695c78b5017454e394 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 6 Dec 2023 17:14:31 +0800 Subject: [PATCH] fix --- src/api/index.js | 1 + src/components/TestPanel.vue | 125 ++++++++++++++++++++------------ src/components/codemirror.vue | 3 + src/components/upload/index.vue | 2 +- src/components/upload/upload.js | 2 +- src/config/index.js | 2 +- src/views/Home.vue | 1 + 7 files changed, 88 insertions(+), 48 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 410614f..35f7b86 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,5 +1,6 @@ import config from '@/config' export default { + getCurrentTime : `competition/competition/management/getCurrentTime`, getProjectDetail: 'occupationlab/occupationlab/projectManage/getProjectDetail', submit: 'python/python/submit', runPythonCode: 'python/python/runPythonCode', diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index bda2883..4458c95 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -351,6 +351,7 @@ export default { seconds: 0, // 秒数 minutes: 0, // 分钟数 hour: 0, // 小时数 + now: '', projectList: [], // 项目列表 pd: {}, experimentTarget: '', //实验目标 @@ -404,34 +405,37 @@ export default { mavonEditor }, mounted () { - // 2:竞赛,1:考核,0:练习 - this.projectPermissions = this.assessmentId ? - 1 : - this.competitionId ? - 2 : - 0 - if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) - this.getAssList() - } else { // 练习 - if (Cookie.get('doneProjectId')) { - this.projectId = +Cookie.get('doneProjectId') - } - Cookie.remove('doneProjectId') - // 获取项目列表 - this.getList().then(() => { - let cache = localStorage.getItem('codeCache') // 获取本地缓存 - // 如果有缓存,再调接口取上次运行的代码 - if (cache) { - this.getCache(JSON.parse(cache)) - } else { - this.getCache() + this.getNow().then(now => { + this.entryTime = now + // 2:竞赛,1:考核,0:练习 + this.projectPermissions = this.assessmentId ? + 1 : + this.competitionId ? + 2 : + 0 + if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) + this.getAssList() + } else { // 练习 + if (Cookie.get('doneProjectId')) { + this.projectId = +Cookie.get('doneProjectId') } - }).catch(res => { }) - } - this.competitionId && this.getCompetitionStatus() // 查询竞赛信息 - this.getUserDetail() - // this.drag() - this.tableHeight = window.innerHeight - 360 + Cookie.remove('doneProjectId') + // 获取项目列表 + this.getList().then(() => { + let cache = localStorage.getItem('codeCache') // 获取本地缓存 + // 如果有缓存,再调接口取上次运行的代码 + if (cache) { + this.getCache(JSON.parse(cache)) + } else { + this.getCache() + } + }).catch(res => { }) + } + this.competitionId && this.getCompetitionStatus() // 查询竞赛信息 + this.getUserDetail() + // this.drag() + this.tableHeight = window.innerHeight - 360 + }) }, methods: { // 获取项目列表 @@ -515,8 +519,10 @@ export default { this.text = isPrac ? '已用' : '剩余' // 竞赛不需要 if (!this.competitionId) { - this.countVal = isPrac ? 0 : (new Date(this.endTime).getTime() - Date.now()) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 - this.startCount() + this.getNow().then(now => { + this.countVal = isPrac ? 0 : (new Date(this.endTime) - now) / 1000 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时 + this.startCount() + }) } resolve() }).catch(err => { @@ -524,6 +530,13 @@ export default { }) }) }, + // 获取当前时间 + getNow () { + return new Promise(async (resolve, reject) => { + const res = await this.$get(this.api.getCurrentTime) + resolve(new Date(res.currentTime)) + }) + }, // 关闭父页面的loading,并置加载完成状态为true closeLoad () { this.$parent.loadIns.close() @@ -603,6 +616,7 @@ export default { const judgmentId = e.judgmentId promiseList.push(new Promise((resolve, reject) => { this.$post(this.api.getLastCache, { + competitionId: this.competitionId, assessmentId: assessmentId ? Number(assessmentId) : '', bcId: judgmentId, projectId, // 项目id,同上 @@ -656,6 +670,7 @@ export default { // 删除该项目下所有判分规则的缓存代码 points.map(e => { e.code && this.$post(this.api.delCache, { + competitionId: this.competitionId, assessmentId, bcId: e.judgmentId, projectId, @@ -685,20 +700,22 @@ export default { // 查询竞赛状态(查到竞赛如果结束后,直接提交竞赛) getCompetitionStatus () { // 未提交才需要查询状态 - this.isSubmit || this.$post(`${this.api.getCompetition}?competitionId=${this.competitionId}`).then(({ competition }) => { + this.isSubmit || this.$post(`${this.api.getCompetition}?competitionId=${this.competitionId}`).then(async ({ competition }) => { const stages = competition.competitionStage if (stages) { const stage = stages.find(e => e.stageId == this.stageId) - const endTime = new Date(stage.endTime).getTime() - const now = Date.now() + const endTime = new Date(stage.endTime) + + const res = await this.$get(this.api.getCurrentTime) + const now = new Date(res.currentTime) // 如果已经结束 - if (now >= new Date(stage.endTime)) { + if (now >= endTime) { this.$alert('竞赛时间已到,系统已自动交卷', '提示', { confirmButtonText: '确定' }) this.submit() } else { // 没结束,则显示倒计时 - this.countVal = (endTime - Date.now()) / 1000 + this.countVal = (endTime - now) / 1000 this.startCount() } } @@ -747,7 +764,7 @@ export default { } }, //重新开始 - reload () { + async reload () { this.reloadCount() this.grade = '00' localStorage.removeItem('codeCache') @@ -764,6 +781,7 @@ export default { this.$emit('recoveryCode') this.startCount() this.clearReport() + this.entryTime = await this.getNow() }, // 页面加载完后重置编辑框大小 ready () { @@ -831,7 +849,9 @@ export default { }).then(({ codeId }) => { this.$parent.workbench[0].codeId = codeId this.submit() - }).catch(err => { }) + }).catch(err => { + this.submiting = false + }) } else { this.submit() } @@ -841,12 +861,12 @@ export default { }) }, // 提交 - submit () { + async submit () { if (this.isSubmit) return false const pointList = this.$parent.workbench - const date = new Date() + const date = await this.getNow() const entryTime = this.entryTime - const timeSum = Math.ceil((date.getTime() - entryTime.getTime()) / 60000) // 计算实验用时(分钟),向上取整 + const timeSum = Math.ceil((date - entryTime) / 60000) // 计算实验用时(分钟),向上取整 const submitTime = util.formatDate('yyyy-MM-dd hh:mm:ss', date) const projectId = this.projectId const pro = this.projectList.find(e => e.projectId == projectId) @@ -909,12 +929,16 @@ export default { this.editReport(reportId) this.submiting = false // 如果是竞赛,并且勾选了公布成绩详情的选项,则弹框提示 - // this.competitionId && this.resultsDetails == 0 && this.$alert(`提交成功${this.resultAnnouncementTime != 0 ? ',成绩将在' + this.resultAnnouncementTime + '小时后发布,请去参赛信息模块查看' : ''}`, '提示', { - // confirmButtonText: '确定', - // callback: action => { - // this.$parent.back() - // } - // }) + if (this.competitionId) { + this.$alert(`提交成功!${this.resultsDetails == 0 && this.resultAnnouncementTime != 0 ? '成绩将在' + this.resultAnnouncementTime + '小时后发布,请去参赛信息模块查看' : ''}`, '提示', { + confirmButtonText: '确定', + callback: action => { + this.$parent.back() + } + }) + } else { + this.$message.success('提交成功!') + } }).catch(err => { this.submiting = false }) @@ -1188,7 +1212,11 @@ export default { } } /deep/.ql-editor { + font-family: 'Microsoft Yahei'; font-size: 13px; + .ql-syntax { + font-family: 'Microsoft Yahei'; + } } /deep/.el-collapse-item__wrap { border-bottom: none; @@ -1395,11 +1423,18 @@ export default { /deep/.v-note-wrapper { min-height: 0; height: auto; + font-family: 'Microsoft Yahei'; .v-note-panel .v-note-show { + font-family: 'Microsoft Yahei'; overflow: visible; .v-show-content { + font-family: 'Microsoft Yahei'; overflow: visible; } + pre, + code { + font-family: 'Microsoft Yahei'; + } } } \ No newline at end of file diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 08b41d5..d029023 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -628,6 +628,9 @@ export default { .text-wrapper { white-space: pre-wrap; } +/deep/.CodeMirror-code { + font-family: 'Microsoft Yahei'; +} /deep/.answer { .el-tab-pane { padding: 0 10px; diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue index 6f7bfe1..49c0617 100644 --- a/src/components/upload/index.vue +++ b/src/components/upload/index.vue @@ -102,7 +102,7 @@ export default { this.uploading = true this.showFiles = false // 上传到阿里云oss - const { name } = await this.client.multipartUpload(file.name, file, { + const { name } = await this.client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file, { progress: this.handleProgress }); diff --git a/src/components/upload/upload.js b/src/components/upload/upload.js index 0f49a25..e485aa8 100644 --- a/src/components/upload/upload.js +++ b/src/components/upload/upload.js @@ -17,7 +17,7 @@ export default { return new Promise(async (resolve, reject) => { try { // 上传到阿里云oss - const res = await client.multipartUpload(file.name, file); + const res = await client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file); resolve({ format: Util.getFileExt(file.name), name: file.name, diff --git a/src/config/index.js b/src/config/index.js index c7a01f0..cdcc0f2 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -66,5 +66,5 @@ export default { /** * @description 长时间未操作,自动退出登录时间 */ - autoLogoutTime: 1000 * 60 * 60 + autoLogoutTime: 1000 * 60 * 60 * 3 } \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index 3e4f055..b095c43 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -148,6 +148,7 @@ export default { list.map(e => { if (e.code) { let data = { + competitionId: this.competitionId, assessmentId: this.assessmentId, code: e.code, bcId: e.judgmentId,