消息通知联调完成

master
yujialong 8 months ago
parent e9a49f0a46
commit 46186012d5
  1. 4
      src/api/index.js
  2. 57
      src/components/TestPanel.vue
  3. 4
      src/components/codemirror.vue
  4. 16
      src/views/Home.vue

@ -8,9 +8,7 @@ export default {
queryTestProject: 'occupationlab/occupationlab/projectManage/getProjectBySystemId', queryTestProject: 'occupationlab/occupationlab/projectManage/getProjectBySystemId',
editExperimentalData: 'occupationlab/occupationlab/experimentalReport/editExperimentalData', editExperimentalData: 'occupationlab/occupationlab/experimentalReport/editExperimentalData',
queryBcJudgmentPointByBcId: 'judgment/judgment/bcJudgmentPoint/queryBcJudgmentPointByBcId', queryBcJudgmentPointByBcId: 'judgment/judgment/bcJudgmentPoint/queryBcJudgmentPointByBcId',
saveCache: 'python/python/saveCache', getLastCache: 'python/python/finalRunRecord',
getLastCache: 'python/python/getLastCache',
delCache: 'python/python/delCache',
getTheMostRecentlyRunProject: 'python/python/getTheMostRecentlyRunProject', getTheMostRecentlyRunProject: 'python/python/getTheMostRecentlyRunProject',
getDataProductBoughtByOurSchool: 'data/data/myDate/getDataProductBoughtByOurSchool', getDataProductBoughtByOurSchool: 'data/data/myDate/getDataProductBoughtByOurSchool',
getPurchasedTableByCategory: `data/data/myDate/getPurchasedTableByCategory`, getPurchasedTableByCategory: `data/data/myDate/getPurchasedTableByCategory`,

@ -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" // mqip
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(() => {
// vscodecodeId // vscodecodeId
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)
} }

@ -464,6 +464,7 @@ export default {
this.isSubmit = isSubmit this.isSubmit = isSubmit
}) })
newmain.$on('runCode', data => { newmain.$on('runCode', data => {
this.pid = ''
this.handleRunCode(data) this.handleRunCode(data)
}) })
newmain.$on('setPid', pid => { newmain.$on('setPid', pid => {
@ -701,7 +702,7 @@ export default {
if (data) { if (data) {
const photo = data.photoUrl const photo = data.photoUrl
const result = data.runResult || '' const result = data.runResult || ''
this.$emit('cache') // // this.$emit('cache') //
if (this.loadIns) this.loadIns.close() if (this.loadIns) this.loadIns.close()
this.picSrcList = [] this.picSrcList = []
this.$emit('update:photoUrl', '') this.$emit('update:photoUrl', '')
@ -743,6 +744,7 @@ export default {
}, },
// //
runCode (isWhile) { // isWhiletruewhile runCode (isWhile) { // isWhiletruewhile
this.pid = ''
if (!this.isSubmit) { if (!this.isSubmit) {
let code = this.codeVal let code = this.codeVal
if (!code) { if (!code) {

@ -170,21 +170,7 @@ export default {
judgmentIdList: this.workbench.map(e => e.judgmentId) judgmentIdList: this.workbench.map(e => e.judgmentId)
} }
// //
if (list.some(e => e.code)) { if (!list.some(e => e.code)) {
list.map(e => {
if (e.code) {
let data = {
competitionId: this.competitionId,
assessmentId: this.assessmentId,
code: e.code,
bcId: e.judgmentId,
cid: this.courseId,
projectId: this.projectId
}
this.$post(this.api.saveCache, data).then(res => { }).catch(e => { })
}
})
} else {
cache.empty = true // cache.empty = true //
} }
localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid

Loading…
Cancel
Save