|
|
@ -320,10 +320,8 @@ import "codemirror/theme/base16-light.css"; |
|
|
|
import { mavonEditor } from 'mavon-editor' |
|
|
|
import { mavonEditor } from 'mavon-editor' |
|
|
|
import 'mavon-editor/dist/css/index.css' |
|
|
|
import 'mavon-editor/dist/css/index.css' |
|
|
|
import Stomp from 'stompjs' |
|
|
|
import Stomp from 'stompjs' |
|
|
|
export const IP = "x.108.x.33" // 自己的mq服务ip |
|
|
|
|
|
|
|
export const MQTT_USERNAME = 'huoran' // 连接用户名, todo: read from database |
|
|
|
export const MQTT_USERNAME = 'huoran' // 连接用户名, todo: read from database |
|
|
|
export const MQTT_PASSWORD = 'huoran2024' // 连接密码, todo: read from database |
|
|
|
export const MQTT_PASSWORD = 'huoran2024' // 连接密码, todo: read from database |
|
|
|
export const VIRTUAL_HOST = '15674' // 侦听器端口 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data () { |
|
|
|
data () { |
|
|
@ -406,6 +404,7 @@ export default { |
|
|
|
client: '', |
|
|
|
client: '', |
|
|
|
accountId: '', |
|
|
|
accountId: '', |
|
|
|
runCodeType: '', |
|
|
|
runCodeType: '', |
|
|
|
|
|
|
|
finishVscodeItem: 0, |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
components: { |
|
|
|
components: { |
|
|
@ -441,12 +440,16 @@ export default { |
|
|
|
Cookie.remove('doneProjectId') |
|
|
|
Cookie.remove('doneProjectId') |
|
|
|
// 获取项目列表 |
|
|
|
// 获取项目列表 |
|
|
|
this.getList().then(() => { |
|
|
|
this.getList().then(() => { |
|
|
|
let cache = localStorage.getItem('codeCache') // 获取本地缓存 |
|
|
|
if (!this.isSubmit) { |
|
|
|
// 如果有缓存,再调接口取上次运行的代码 |
|
|
|
let cache = localStorage.getItem('codeCache') // 获取本地缓存 |
|
|
|
if (cache) { |
|
|
|
// 如果有缓存,再调接口取上次运行的代码 |
|
|
|
this.getCache(JSON.parse(cache)) |
|
|
|
if (cache) { |
|
|
|
|
|
|
|
this.getCache(JSON.parse(cache)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.getCache() |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.getCache() |
|
|
|
this.closeLoad() |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(res => { }) |
|
|
|
}).catch(res => { }) |
|
|
|
} |
|
|
|
} |
|
|
@ -619,6 +622,10 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取上次缓存记录 |
|
|
|
// 获取上次缓存记录 |
|
|
|
async getCache (cache) { |
|
|
|
async getCache (cache) { |
|
|
|
|
|
|
|
if (this.isSubmit) { |
|
|
|
|
|
|
|
this.closeLoad() |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
const pId = cache ? cache.projectId : '' |
|
|
|
const pId = cache ? cache.projectId : '' |
|
|
|
const projectId = Number(pId || this.projectId) |
|
|
|
const projectId = Number(pId || this.projectId) |
|
|
|
const cid = this.courseId |
|
|
|
const cid = this.courseId |
|
|
@ -663,7 +670,7 @@ export default { |
|
|
|
cid // 课程id |
|
|
|
cid // 课程id |
|
|
|
}).then(res => { |
|
|
|
}).then(res => { |
|
|
|
this.closeLoad() |
|
|
|
this.closeLoad() |
|
|
|
const result = res.runningResult |
|
|
|
const result = res.runRecord |
|
|
|
// 如果有缓存代码 |
|
|
|
// 如果有缓存代码 |
|
|
|
if (result) { |
|
|
|
if (result) { |
|
|
|
hasCache = 1 |
|
|
|
hasCache = 1 |
|
|
@ -722,16 +729,6 @@ export default { |
|
|
|
}).catch(() => { |
|
|
|
}).catch(() => { |
|
|
|
// 选择了不继续上次的实验,则清除本地缓存,并删除服务器里缓存的代码 |
|
|
|
// 选择了不继续上次的实验,则清除本地缓存,并删除服务器里缓存的代码 |
|
|
|
localStorage.removeItem('codeCache') |
|
|
|
localStorage.removeItem('codeCache') |
|
|
|
// 删除该项目下所有判分规则的缓存代码 |
|
|
|
|
|
|
|
points.map(e => { |
|
|
|
|
|
|
|
e.code && this.$post(this.api.delCache, { |
|
|
|
|
|
|
|
competitionId: this.competitionId, |
|
|
|
|
|
|
|
assessmentId, |
|
|
|
|
|
|
|
bcId: e.judgmentId, |
|
|
|
|
|
|
|
projectId, |
|
|
|
|
|
|
|
cid |
|
|
|
|
|
|
|
}).then(res => { }).catch(() => { }) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -854,8 +851,12 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
vscodeRunCode (data) { |
|
|
|
vscodeRunCode (data) { |
|
|
|
// this.$parent.workbench[i].codeId = data.codeId |
|
|
|
console.log("🚀 ~ vscodeRunCode ~ data:", data, this.$parent.workbench) |
|
|
|
// this.$parent.workbench[i].retResult = 1 |
|
|
|
const i = +data.sort |
|
|
|
|
|
|
|
this.$parent.workbench[i].codeId = data.codeId |
|
|
|
|
|
|
|
this.$parent.workbench[i].retResult = 1 |
|
|
|
|
|
|
|
this.finishVscodeItem++ |
|
|
|
|
|
|
|
this.finishVscodeItem === this.$parent.workbench.length && this.submit() |
|
|
|
}, |
|
|
|
}, |
|
|
|
emptyRunCode (data) { |
|
|
|
emptyRunCode (data) { |
|
|
|
this.$parent.workbench[0].codeId = data.codeId |
|
|
|
this.$parent.workbench[0].codeId = data.codeId |
|
|
@ -877,7 +878,7 @@ export default { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!taskList.find(e => e.code || e.codeResult)) msg = '实验报告未填写,实验成绩为零,是否确认提交?' |
|
|
|
if (!taskList.find(e => e.code || e.codeResult)) msg = '实验报告未填写,实验成绩为零,是否确认提交?' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.finishVscodeItem = 0 |
|
|
|
this.$confirm(msg, '提示', { |
|
|
|
this.$confirm(msg, '提示', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
cancelButtonText: '取消', |
|
|
@ -887,9 +888,8 @@ export default { |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
|
// vscode类型的产品提交前需要自动运行每个判分点的代码以获取codeId |
|
|
|
// vscode类型的产品提交前需要自动运行每个判分点的代码以获取codeId |
|
|
|
if (isVscode) { |
|
|
|
if (isVscode) { |
|
|
|
const promises = [] |
|
|
|
|
|
|
|
taskList.map(async (e, i) => { |
|
|
|
taskList.map(async (e, i) => { |
|
|
|
(e.code || e.codeResult) && promises.push(new Promise(async (resolve, reject) => { |
|
|
|
if (e.code || e.codeResult) { |
|
|
|
this.runCodeType = 'vscodeRunCode' |
|
|
|
this.runCodeType = 'vscodeRunCode' |
|
|
|
await this.$post(this.api.runPythonCode, { |
|
|
|
await this.$post(this.api.runPythonCode, { |
|
|
|
code: e.code, |
|
|
|
code: e.code, |
|
|
@ -901,11 +901,7 @@ export default { |
|
|
|
sort: i |
|
|
|
sort: i |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.$parent.workbench[i].answer = e.codeResult |
|
|
|
this.$parent.workbench[i].answer = e.codeResult |
|
|
|
resolve() |
|
|
|
} |
|
|
|
})) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
Promise.all(promises).then(_ => { |
|
|
|
|
|
|
|
this.submit() |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 如果全部都没运行直接点提交,则主动运行一个空代码。(不然会造成上次运行的结果,这次进来不运行直接提交的话,会无法取到运行结果) |
|
|
|
// 如果全部都没运行直接点提交,则主动运行一个空代码。(不然会造成上次运行的结果,这次进来不运行直接提交的话,会无法取到运行结果) |
|
|
@ -1220,7 +1216,8 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
// 消息队列获取 |
|
|
|
// 消息队列获取 |
|
|
|
connect () { |
|
|
|
connect () { |
|
|
|
let ws = new WebSocket(`ws://124.71.74.9:15674/ws`); |
|
|
|
// let ws = new WebSocket(`ws://124.71.74.9:15674/ws`); |
|
|
|
|
|
|
|
let ws = new WebSocket(`wss://python.occupationlab.com/ws`); |
|
|
|
this.client = Stomp.over(ws); |
|
|
|
this.client = Stomp.over(ws); |
|
|
|
//初始化连接 |
|
|
|
//初始化连接 |
|
|
|
const headers = { |
|
|
|
const headers = { |
|
|
@ -1251,7 +1248,7 @@ export default { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newmain.$emit('runCode', data) |
|
|
|
newmain.$emit('runCode', data) |
|
|
|
} |
|
|
|
} |
|
|
|
this.runCodeType = '' |
|
|
|
if (this.runCodeType !== 'vscodeRunCode') this.runCodeType = '' |
|
|
|
} else if (typeof data === 'string') { |
|
|
|
} else if (typeof data === 'string') { |
|
|
|
newmain.$emit('setPid', data) |
|
|
|
newmain.$emit('setPid', data) |
|
|
|
} |
|
|
|
} |
|
|
|