生成多张图片

dev_2022-03-03
yujialong 3 years ago
parent 6f83c68f43
commit 1f2858a065
  1. 36
      src/components/codemirror.vue
  2. 2
      src/config/index.js

@ -18,12 +18,13 @@
</div> </div>
<div class="code-right answer"> <div class="code-right answer">
<p class="text-wrapper">{{ runResult }}</p> <p class="text-wrapper">{{ runResult }}</p>
<div class="pic-wrap" v-if="picSrc"> <div class="pic-wrap" v-if="picSrcList.length">
<div style="margin-bottom: 5px;text-align: center"> <div class="pic-item" v-for="(img, i) in picSrcList" :key="i">
<img class="pic" :src="picSrc" alt=""> <!-- <img class="pic" :src="picSrc" alt=""> -->
<img class="pic" :src="img" alt="">
<el-button class="download-btn btn" type="primary" size="mini" @click="downloadPic(i)">下载图片</el-button>
<a :ref="'picLink' + i" style="display: none;" download="运行结果.png" :href="img">下载图片</a>
</div> </div>
<el-button class="download-btn btn" type="primary" size="mini" @click="$refs.picLink.click()">下载图片</el-button>
<a ref="picLink" style="display: none;" download="运行结果.png" :href="picSrc">下载图片</a>
</div> </div>
<div class="result-right t-color" v-show="isError"> <div class="result-right t-color" v-show="isError">
<img :src="require(`@/assets/images/system/${systemId}/yes.png`)" alt />运行成功 <img :src="require(`@/assets/images/system/${systemId}/yes.png`)" alt />运行成功
@ -109,6 +110,7 @@ export default {
runEnable: false, // runEnable: false, //
tipsVisible: false, // tipsVisible: false, //
picSrc: '', // url picSrc: '', // url
picSrcList: [],
loadIns: null, // loading loadIns: null, // loading
cmOption: { cmOption: {
scrollbarStyle: "native", scrollbarStyle: "native",
@ -306,7 +308,8 @@ export default {
const result = data.runResult const result = data.runResult
this.$emit('cache') // this.$emit('cache') //
this.loadIns.close() this.loadIns.close()
this.picSrc = '' // this.picSrc = ''
if (photo) this.picSrcList = photo.split(',')
this.$emit('update:codeId', res.codeId) // coddeId this.$emit('update:codeId', res.codeId) // coddeId
this.$emit('update:answer', result) // this.$emit('update:answer', result) //
this.$emit('update:retResult', data.retResult) // this.$emit('update:retResult', data.retResult) //
@ -321,7 +324,8 @@ export default {
this.isError = '' // this.isError = '' //
const text = result.replace(photo, '') // const text = result.replace(photo, '') //
this.runResult = text this.runResult = text
this.picSrc = photo // this.picSrc = photo
if (photo) this.picSrcList = photo.split(',')
} 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'))) {
/** /**
* 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来 * 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
@ -351,6 +355,11 @@ export default {
}) })
} }
}, },
//
downloadPic(i) {
console.log(11, this.$refs['picLink' + i][0])
this.$refs['picLink' + i][0].click()
},
// //
getTips() { getTips() {
this.tipsVisible = true this.tipsVisible = true
@ -477,10 +486,19 @@ export default {
left: 0; left: 0;
right: 0; right: 0;
bottom: 5px; bottom: 5px;
display: flex;
// justify-content: center;
max-width: calc(100% - 50px);
margin: 0 auto;
text-align: center; text-align: center;
overflow: auto;
.pic-item {
margin: 0 5px 5px;
}
.pic { .pic {
max-width: 80%; display: block;
vertical-align: middle; width: 100px;
margin: 0 auto 10px;
} }
} }
.code-mask{ .code-mask{

@ -4,7 +4,7 @@ const isHh = location.host.includes('10.196.131.73') //是否是河海版本
const isBeta = process.env.NODE_ENV === 'development' || location.host.includes('39.108.250.202') //是否是职站测试 const isBeta = process.env.NODE_ENV === 'development' || location.host.includes('39.108.250.202') //是否是职站测试
let host = location.origin + ':9000/' let host = location.origin + ':9000/'
if (process.env.NODE_ENV === 'development') host = 'http://192.168.31.151:9000' if (process.env.NODE_ENV === 'development') host = 'http://39.108.250.202:9000'
/** /**
* python8个系统的id和名称 * python8个系统的id和名称
* id即systemId从cookie里取 * id即systemId从cookie里取

Loading…
Cancel
Save