消息通知联调完成

master
yujialong 8 months ago
parent e9a49f0a46
commit 46186012d5
  1. 4
      src/api/index.js
  2. 47
      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',
editExperimentalData: 'occupationlab/occupationlab/experimentalReport/editExperimentalData',
queryBcJudgmentPointByBcId: 'judgment/judgment/bcJudgmentPoint/queryBcJudgmentPointByBcId',
saveCache: 'python/python/saveCache',
getLastCache: 'python/python/getLastCache',
delCache: 'python/python/delCache',
getLastCache: 'python/python/finalRunRecord',
getTheMostRecentlyRunProject: 'python/python/getTheMostRecentlyRunProject',
getDataProductBoughtByOurSchool: 'data/data/myDate/getDataProductBoughtByOurSchool',
getPurchasedTableByCategory: `data/data/myDate/getPurchasedTableByCategory`,

@ -320,10 +320,8 @@ import "codemirror/theme/base16-light.css";
import { mavonEditor } from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import Stomp from 'stompjs'
export const IP = "x.108.x.33" // mqip
export const MQTT_USERNAME = 'huoran' // , todo: read from database
export const MQTT_PASSWORD = 'huoran2024' // , todo: read from database
export const VIRTUAL_HOST = '15674' //
export default {
data () {
@ -406,6 +404,7 @@ export default {
client: '',
accountId: '',
runCodeType: '',
finishVscodeItem: 0,
};
},
components: {
@ -441,6 +440,7 @@ export default {
Cookie.remove('doneProjectId')
//
this.getList().then(() => {
if (!this.isSubmit) {
let cache = localStorage.getItem('codeCache') //
//
if (cache) {
@ -448,6 +448,9 @@ export default {
} else {
this.getCache()
}
} else {
this.closeLoad()
}
}).catch(res => { })
}
this.competitionId && this.getCompetitionStatus() //
@ -619,6 +622,10 @@ export default {
},
//
async getCache (cache) {
if (this.isSubmit) {
this.closeLoad()
return false
}
const pId = cache ? cache.projectId : ''
const projectId = Number(pId || this.projectId)
const cid = this.courseId
@ -663,7 +670,7 @@ export default {
cid // id
}).then(res => {
this.closeLoad()
const result = res.runningResult
const result = res.runRecord
//
if (result) {
hasCache = 1
@ -722,16 +729,6 @@ export default {
}).catch(() => {
//
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) {
// this.$parent.workbench[i].codeId = data.codeId
// this.$parent.workbench[i].retResult = 1
console.log("🚀 ~ vscodeRunCode ~ data:", data, this.$parent.workbench)
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) {
this.$parent.workbench[0].codeId = data.codeId
@ -877,7 +878,7 @@ export default {
} else {
if (!taskList.find(e => e.code || e.codeResult)) msg = '实验报告未填写,实验成绩为零,是否确认提交?'
}
this.finishVscodeItem = 0
this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -887,9 +888,8 @@ export default {
}).then(() => {
// vscodecodeId
if (isVscode) {
const promises = []
taskList.map(async (e, i) => {
(e.code || e.codeResult) && promises.push(new Promise(async (resolve, reject) => {
if (e.code || e.codeResult) {
this.runCodeType = 'vscodeRunCode'
await this.$post(this.api.runPythonCode, {
code: e.code,
@ -901,11 +901,7 @@ export default {
sort: i
})
this.$parent.workbench[i].answer = e.codeResult
resolve()
}))
})
Promise.all(promises).then(_ => {
this.submit()
}
})
} else {
//
@ -1220,7 +1216,8 @@ export default {
//
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);
//
const headers = {
@ -1251,7 +1248,7 @@ export default {
} else {
newmain.$emit('runCode', data)
}
this.runCodeType = ''
if (this.runCodeType !== 'vscodeRunCode') this.runCodeType = ''
} else if (typeof data === 'string') {
newmain.$emit('setPid', data)
}

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

@ -170,21 +170,7 @@ export default {
judgmentIdList: this.workbench.map(e => e.judgmentId)
}
//
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 {
if (!list.some(e => e.code)) {
cache.empty = true //
}
localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid

Loading…
Cancel
Save