From 13c75433ec4ffb37a2ba502a29980908bb0593ab Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 3 Jul 2024 15:19:40 +0800 Subject: [PATCH] =?UTF-8?q?vscode=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E5=85=81=E8=AE=B8=E7=B2=98=E8=B4=B4=EF=BC=8C?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=90=8E=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=B8=80=E6=AC=A1=E8=BF=90=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TestPanel.vue | 66 ++++++++++++++++++++++-------------- src/views/Home.vue | 25 -------------- 2 files changed, 41 insertions(+), 50 deletions(-) diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 02962ad..0f62c3f 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -214,10 +214,6 @@ import "codemirror/theme/base16-light.css"; import { mavonEditor } from 'mavon-editor' import 'mavon-editor/dist/css/index.css' import Stomp from 'stompjs' -// export const MQTT_USERNAME = 'huoran' // 连接用户名, todo: read from database -// export const MQTT_PASSWORD = 'huoran2024' // 连接密码, todo: read from database -export const MQTT_USERNAME = 'huorantest' // 连接用户名, todo: read from database -export const MQTT_PASSWORD = 'huorantest2024' // 连接密码, todo: read from database export default { data () { @@ -331,18 +327,27 @@ export default { if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) this.getAssList() } else { // 练习 - if (Cookie.get('doneProjectId')) { + if (Cookie.get('doneProjectId')) { // 已经做完了实验,则直接恢复项目id this.projectId = +Cookie.get('doneProjectId') + } else { + // 没有初次加载的标识,说明不是第一次进来,而是当前页面刷新后进来这个方法,这时候则查最近一次跑的项目是哪个 + if (Cookie.get('admin-loaded')) { + const { data } = await this.$get(`${this.api.getTheMostRecentlyRunProject}`, { + cid: this.courseId + }) + if (data.length) this.projectId = data[0].projectId + } else { + Cookie.set('admin-loaded', 1) // 初次加载的标识 + } } Cookie.remove('doneProjectId') // 获取项目列表 - this.getList().then(() => { - if (!this.isSubmit) { - this.getCache() - } else { - this.closeLoad() - } - }).catch(res => { }) + await this.getList() + if (!this.isSubmit) { + this.getCache() + } else { + this.closeLoad() + } } this.competitionId && this.getCompetitionStatus() // 查询竞赛信息 this.getUserDetail() @@ -585,8 +590,8 @@ export default { competitionId: this.competitionId, assessmentId: assessmentId ? Number(assessmentId) : '', bcId: e.judgmentId, - projectId, // 项目id,同上 - cid // 课程id + projectId, + cid }) }) }) @@ -694,6 +699,17 @@ export default { this.startCount() this.clearReport() this.entryTime = await this.getNow() + + // 清除代码缓存 + this.points.map(async (e) => { + await this.$post(this.api.deleteTheLastUncommittedRecord, { + competitionId: this.competitionId, + assessmentId: this.assessmentId, + bcId: e.judgmentId, + projectId: this.projectId, + cid: this.courseId, + }) + }) }, //重新开始 async reloadConfirm () { @@ -715,14 +731,14 @@ export default { }, // 页面加载完后重置编辑框大小 ready (i) { - if (this.$refs['codemirror' + i]) { - const code = this.$refs['codemirror' + i].codemirror - if (code) { - code.on('beforeChange', (istance, change) => { - change.origin === 'paste' && change.cancel() - }) - } - } + // if (this.$refs['codemirror' + i]) { + // const code = this.$refs['codemirror' + i].codemirror + // if (code) { + // code.on('beforeChange', (istance, change) => { + // change.origin === 'paste' && change.cancel() + // }) + // } + // } }, vscodeRunCode (data) { const i = +data.sort @@ -1092,15 +1108,15 @@ export default { // 消息队列获取 connect () { - let ws = new WebSocket(`ws://139.159.153.48:15674/ws`); + let ws = new WebSocket(this.$config.isTest ? `ws://139.159.153.48:15674/ws` : `wss://python.occupationlab.com/ws`); // let ws = new WebSocket(`wss://python.occupationlab.com/ws`); this.client = Stomp.over(ws); this.client.heartbeat.outgoing = 0 this.client.heartbeat.incoming = 0 //初始化连接 const headers = { - login: MQTT_USERNAME, - passcode: MQTT_PASSWORD + login: this.$config.isTest ? 'huorantest' : 'huoran', + passcode: this.$config.isTest ? 'huorantest2024' : 'huoran2024' }; //进行连接 this.client.connect(headers.login, headers.passcode, this.onConnected, this.onFailed, 'pyhost'); diff --git a/src/views/Home.vue b/src/views/Home.vue index 09995ed..6f390a6 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -95,31 +95,6 @@ export default { testPanel }, mounted () { - // 保证同一个浏览器只有一个当前系统能打开 - const opened = +localStorage.getItem('opened') - if (opened) { - localStorage.setItem('opened', opened + 1) - this.notAllowed = 1 - this.$alert('我们注意到您当前已尝试打开多个实验页面。为保证实验的公平性和诚信,系统仅允许单个实验页面处于活跃状态。', '提示', { - confirmButtonText: '退出当前页面', - showClose: false, - callback: action => { - this.back() - } - }) - } else { - localStorage.setItem('opened', 1) - } - - // 页面离开后当前活跃的标识处理 - window.addEventListener('unload', function () { - const opened = +localStorage.getItem('opened') - if (opened) { - localStorage.setItem('opened', opened - 1) - } else { - localStorage.removeItem('opened') - } - }) document.onkeydown = function (event) { var e = event || window.event || arguments.callee.caller.arguments[0];