缓存运行结果

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

@ -71,7 +71,7 @@
<el-tabs> <el-tabs>
<el-tab-pane label="参考答案"> <el-tab-pane label="参考答案">
<div :class="['answer-wrap', {client: !fromManager}]" <div :class="['answer-wrap', {client: !fromManager}]"
v-html="answer"></div> v-html="correctAnswer"></div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-dialog> </el-dialog>
@ -142,6 +142,12 @@
width="1200px" width="1200px"
:close-on-click-modal="false" :close-on-click-modal="false"
custom-class="code-dia"> 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"> <div class="tool">
<el-input style="width: 250px" <el-input style="width: 250px"
placeholder="请输入项目名称、判分点名称" placeholder="请输入项目名称、判分点名称"
@ -308,7 +314,7 @@ import config from '@/config'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
const CANCEL_TOKEN = axios.CancelToken // input const CANCEL_TOKEN = axios.CancelToken // input
export default { export default {
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl'], props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl', 'answer'],
data () { data () {
return { return {
token: Cookie.get('admin-token'), token: Cookie.get('admin-token'),
@ -318,10 +324,10 @@ export default {
courseId: Cookie.get('admin-courseId'), // id courseId: Cookie.get('admin-courseId'), // id
mallId: Cookie.get('admin-mallId'), mallId: Cookie.get('admin-mallId'),
isPrac: false, // isPrac: false, //
answer: '', // correctAnswer: '', //
codeVal: this.code, codeVal: this.code,
runResult: '', // runResult: this.answer, //
isError: false, // isError: this.retResult, //
errLine: '', // errLine: '', //
isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, // isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, //
runEnable: false, // runEnable: false, //
@ -431,6 +437,12 @@ export default {
}, },
}, },
mounted () { 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 if (!this.assessmentId && !this.competitionId) this.isPrac = true
// //
newmain.$on("isSubmit", isSubmit => { newmain.$on("isSubmit", isSubmit => {
@ -587,7 +599,7 @@ export default {
const result = data.runResult const result = data.runResult
if (result.includes('File ')) { if (result.includes('File ')) {
this.runResult = result this.runResult = result
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length)) this.errLine = this.getErrLine(result)
this.isError = data.retResult this.isError = data.retResult
} else if (result.includes('validing:')) { } else if (result.includes('validing:')) {
this.isError = 1 this.isError = 1
@ -608,6 +620,10 @@ export default {
}).catch(err => { }) }).catch(err => { })
}, },
//
getErrLine (result) {
return parseInt(result.substring(result.indexOf('line') + 4, result.length)) || 1
},
// //
runCode (isWhile) { // isWhiletruewhile runCode (isWhile) { // isWhiletruewhile
if (!this.isSubmit) { if (!this.isSubmit) {
@ -652,7 +668,7 @@ export default {
} else { } else {
this.runResult = result this.runResult = result
} }
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length)) this.errLine = this.getErrLine(result)
this.isError = data.retResult this.isError = data.retResult
} else if (result.includes('validing:')) { } else if (result.includes('validing:')) {
this.isError = 1 this.isError = 1
@ -709,7 +725,7 @@ export default {
const text = result.replace(photo, '') // const text = result.replace(photo, '') //
this.runResult = text this.runResult = text
this.picSrcList = photo.split(',') 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'))) { } 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 { } else {
this.isError = data.retResult this.isError = data.retResult
this.runResult = result 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) { } else if (res.data && res.data.current) {
// //
@ -763,7 +779,7 @@ export default {
this.$get(this.api.queryBcJudgmentByBcId, { this.$get(this.api.queryBcJudgmentByBcId, {
bcId: this.judgmentId bcId: this.judgmentId
}).then(res => { }).then(res => {
this.answer = res.experimentCode this.correctAnswer = res.experimentCode
}).catch(err => { }) }).catch(err => { })
}, },
// //
@ -1104,6 +1120,12 @@ export default {
.el-dialog__body { .el-dialog__body {
padding: 0 20px; padding: 0 20px;
} }
.info {
position: absolute;
top: 18px;
left: 100px;
color: #88aef5;
}
.code-tab { .code-tab {
.el-tabs__item.is-active { .el-tabs__item.is-active {
color: #333 !important; color: #333 !important;

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

Loading…
Cancel
Save