生成图片点击放大

dev_2022-03-03 V2.2.2
yujialong 3 years ago
parent 1f2858a065
commit 4189bdd8e6
  1. 18
      src/components/codemirror.vue

@ -20,8 +20,11 @@
<p class="text-wrapper">{{ runResult }}</p> <p class="text-wrapper">{{ runResult }}</p>
<div class="pic-wrap" v-if="picSrcList.length"> <div class="pic-wrap" v-if="picSrcList.length">
<div class="pic-item" v-for="(img, i) in picSrcList" :key="i"> <div class="pic-item" v-for="(img, i) in picSrcList" :key="i">
<!-- <img class="pic" :src="picSrc" alt=""> --> <el-image
<img class="pic" :src="img" alt=""> class="pic"
:src="img"
:preview-src-list="picSrcList">
</el-image>
<el-button class="download-btn btn" type="primary" size="mini" @click="downloadPic(i)">下载图片</el-button> <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> <a :ref="'picLink' + i" style="display: none;" download="运行结果.png" :href="img">下载图片</a>
</div> </div>
@ -109,7 +112,6 @@ export default {
isSubmit: false, // isSubmit: false, //
runEnable: false, // runEnable: false, //
tipsVisible: false, // tipsVisible: false, //
picSrc: '', // url
picSrcList: [], picSrcList: [],
loadIns: null, // loading loadIns: null, // loading
cmOption: { cmOption: {
@ -308,7 +310,6 @@ export default {
const result = data.runResult const result = data.runResult
this.$emit('cache') // this.$emit('cache') //
this.loadIns.close() this.loadIns.close()
// this.picSrc = ''
if (photo) this.picSrcList = photo.split(',') 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) //
@ -324,8 +325,7 @@ 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.picSrcList = photo.split(',')
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'))) {
/** /**
* 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来 * 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
@ -487,13 +487,17 @@ export default {
right: 0; right: 0;
bottom: 5px; bottom: 5px;
display: flex; display: flex;
// justify-content: center;
max-width: calc(100% - 50px); max-width: calc(100% - 50px);
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
overflow: auto; overflow: auto;
.pic-item { .pic-item {
margin: 0 5px 5px; margin: 0 5px 5px;
&:only-child {
.pic {
width: 80%;
}
}
} }
.pic { .pic {
display: block; display: block;

Loading…
Cancel
Save