缓存运行结果

master
yujialong 9 months ago
parent 8198ae9034
commit 2d4ad84aa6
  1. 32
      src/components/TestPanel.vue
  2. 42
      src/components/codemirror.vue
  3. 2
      src/config/index.js

@ -119,7 +119,7 @@
:subfield="false"
:editable="false"
:toolbarsFlag="false"
:boxShadowStyle="none" />
boxShadowStyle="none" />
</div>
</div>
<div class="aside-footer">
@ -194,7 +194,7 @@
:subfield="false"
:editable="false"
:toolbarsFlag="false"
:boxShadowStyle="none" />
boxShadowStyle="none" />
</el-tab-pane>
<el-tab-pane label="实验要求"
name="second">
@ -221,7 +221,7 @@
:subfield="false"
:editable="false"
:toolbarsFlag="false"
:boxShadowStyle="none" />
boxShadowStyle="none" />
</el-collapse-item>
</el-collapse>
</el-tab-pane>
@ -242,7 +242,7 @@
:subfield="false"
:editable="false"
:toolbarsFlag="false"
:boxShadowStyle="none" />
boxShadowStyle="none" />
</el-tab-pane>
</el-tabs>
</el-main>
@ -649,12 +649,16 @@ export default {
cid // id
}).then(res => {
this.closeLoad()
const code = res.getLastCache
const result = res.runningResult
//
if (code) {
if (result) {
hasCache = 1
if (newJudgmentId === '') newJudgmentId = i
e.code = code
e.code = result.code
e.codeId = result.id
e.answer = result.runResult
e.retResult = result.retResult
e.photoUrl = result.runPhotoUrl
}
resolve()
}).catch(res => {
@ -677,7 +681,13 @@ export default {
this.getProDetail().then(() => {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
if (item && item.code) this.$set(e, 'code', item.code)
if (item) {
item.code && this.$set(e, 'code', item.code)
item.codeId && this.$set(e, 'codeId', item.codeId)
item.answer && this.$set(e, 'answer', item.answer)
item.photoUrl && this.$set(e, 'photoUrl', item.photoUrl)
this.$set(e, 'retResult', isNaN(item.retResult) ? '' : item.retResult)
}
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode', newJudgmentId + '') // tab
@ -685,7 +695,11 @@ export default {
} else {
this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId)
if (item && item.code) this.$set(e, 'code', item.code)
item.code && this.$set(e, 'code', item.code)
item.codeId && this.$set(e, 'codeId', item.codeId)
item.answer && this.$set(e, 'answer', item.answer)
item.photoUrl && this.$set(e, 'photoUrl', item.photoUrl)
this.$set(e, 'retResult', isNaN(item.retResult) ? '' : item.retResult)
})
this.$emit('tell', projectId, this.curSystemId, this.points)
this.$emit('recoveryCode')

@ -71,7 +71,7 @@
<el-tabs>
<el-tab-pane label="参考答案">
<div :class="['answer-wrap', {client: !fromManager}]"
v-html="answer"></div>
v-html="correctAnswer"></div>
</el-tab-pane>
</el-tabs>
</el-dialog>
@ -142,6 +142,12 @@
width="1200px"
:close-on-click-modal="false"
custom-class="code-dia">
<el-tooltip class="item"
content="列表中展示当前课程已提交的实验代码"
placement="right">
<i class="info el-icon-warning"
style="margin-right: 10px"></i>
</el-tooltip>
<div class="tool">
<el-input style="width: 250px"
placeholder="请输入项目名称、判分点名称"
@ -308,7 +314,7 @@ import config from '@/config'
import { saveAs } from 'file-saver'
const CANCEL_TOKEN = axios.CancelToken // input
export default {
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl'],
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl', 'answer'],
data () {
return {
token: Cookie.get('admin-token'),
@ -318,10 +324,10 @@ export default {
courseId: Cookie.get('admin-courseId'), // id
mallId: Cookie.get('admin-mallId'),
isPrac: false, //
answer: '', //
correctAnswer: '', //
codeVal: this.code,
runResult: '', //
isError: false, //
runResult: this.answer, //
isError: this.retResult, //
errLine: '', //
isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, //
runEnable: false, //
@ -431,6 +437,12 @@ export default {
},
},
mounted () {
//
if (this.runResult && this.isError === 0) this.errLine = this.getErrLine(this.runResult)
//
if (this.photoUrl) this.picSrcList = this.photoUrl.split(',')
if (!this.assessmentId && !this.competitionId) this.isPrac = true
//
newmain.$on("isSubmit", isSubmit => {
@ -587,7 +599,7 @@ export default {
const result = data.runResult
if (result.includes('File ')) {
this.runResult = result
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length))
this.errLine = this.getErrLine(result)
this.isError = data.retResult
} else if (result.includes('validing:')) {
this.isError = 1
@ -608,6 +620,10 @@ export default {
}).catch(err => { })
},
//
getErrLine (result) {
return parseInt(result.substring(result.indexOf('line') + 4, result.length)) || 1
},
//
runCode (isWhile) { // isWhiletruewhile
if (!this.isSubmit) {
@ -652,7 +668,7 @@ export default {
} else {
this.runResult = result
}
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length))
this.errLine = this.getErrLine(result)
this.isError = data.retResult
} else if (result.includes('validing:')) {
this.isError = 1
@ -709,7 +725,7 @@ export default {
const text = result.replace(photo, '') //
this.runResult = text
this.picSrcList = photo.split(',')
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length))
this.errLine = this.getErrLine(result)
} else if (imgList instanceof Array && imgList.length && typeof firtImg === 'string' && (firtImg.includes('.jpg') || firtImg.includes('.png') || firtImg.includes('img'))) {
/**
* 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
@ -722,7 +738,7 @@ export default {
} else {
this.isError = data.retResult
this.runResult = result
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length))
this.errLine = this.getErrLine(result)
}
} else if (res.data && res.data.current) {
//
@ -763,7 +779,7 @@ export default {
this.$get(this.api.queryBcJudgmentByBcId, {
bcId: this.judgmentId
}).then(res => {
this.answer = res.experimentCode
this.correctAnswer = res.experimentCode
}).catch(err => { })
},
//
@ -1104,6 +1120,12 @@ export default {
.el-dialog__body {
padding: 0 20px;
}
.info {
position: absolute;
top: 18px;
left: 100px;
color: #88aef5;
}
.code-tab {
.el-tabs__item.is-active {
color: #333 !important;

@ -14,7 +14,7 @@ let bankPath = `${location.origin}/banksystem` // 银行系统
// 121.37.12.51 | 192.168.31.151
if (isDev) {
host = 'http://192.168.31.217:9000/'
host = 'http://121.37.12.51:9000/'
// host = 'http://121.37.12.51:9000/'
// host = 'https://occupationlab.com/'
bankPath = `http://${location.hostname}:8093`
} else if (isPro) {

Loading…
Cancel
Save