openf12
yujialong 2 years ago
parent 9533280f7e
commit 91342b1d71
  1. 90
      src/components/TestPanel.vue
  2. 41
      src/components/codemirror.vue

@ -1,5 +1,5 @@
<template> <template>
<div class="panel"> <div :class="['panel', {active: pannelVisible}]" id="panel">
<el-container class="scrollbar" v-if="pannelVisible"> <el-container class="scrollbar" v-if="pannelVisible">
<el-header> <el-header>
<div class="panel-header"> <div class="panel-header">
@ -106,7 +106,7 @@
<el-main> <el-main>
<el-tabs v-model="pannelTab" type="card"> <el-tabs v-model="pannelTab" type="card">
<el-tab-pane label="项目背景" name="first"> <el-tab-pane label="项目背景" name="first">
<div class="break-all des" v-html="experimentDescription"></div> <div class="ql-editor" v-html="experimentDescription"></div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="实验要求" name="second"> <el-tab-pane label="实验要求" name="second">
<el-collapse v-model="curReq"> <el-collapse v-model="curReq">
@ -115,12 +115,12 @@
<i class="el-icon-s-ticket"></i> <i class="el-icon-s-ticket"></i>
<div class="break-all des" v-html="item.name"></div> <div class="break-all des" v-html="item.name"></div>
</template> </template>
<div class="break-all des" v-html="item.experimentalRequirements"></div> <div class="ql-editor" v-html="item.experimentalRequirements"></div>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="实验提示" name="fifth" v-if="hintOpen"> <el-tab-pane label="实验提示" name="fifth" v-if="hintOpen">
<div class="break-all des" v-html="experimentHint"></div> <div class="ql-editor" v-html="experimentHint"></div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-main> </el-main>
@ -141,6 +141,9 @@ import newmain from "../util/newMain";
import util from '@/util' import util from '@/util'
import Config from '@/config' import Config from '@/config'
import Cookie from 'js-cookie' import Cookie from 'js-cookie'
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
export default { export default {
data() { data() {
return { return {
@ -213,6 +216,7 @@ export default {
}, 1000) }, 1000)
} }
} }
this.drag()
}, },
methods: { methods: {
// //
@ -648,6 +652,7 @@ export default {
}, },
// //
togglePannel() { togglePannel() {
document.querySelector('#panel').style.left = 0
this.pannelVisible = !this.pannelVisible this.pannelVisible = !this.pannelVisible
}, },
// //
@ -687,6 +692,40 @@ export default {
this.counterTimer = setInterval(() => { this.counterTimer = setInterval(() => {
this.counter(this.projectPermissions ? this.countVal-- : this.countVal++) this.counter(this.projectPermissions ? this.countVal-- : this.countVal++)
}, 1000) }, 1000)
},
//
drag() {
const el = document.querySelector('#panel')
let gap = 10 //
let parent = document.body
el.onmousedown = e => {
var x = e.clientX - el.offsetLeft
var y = e.clientY - el.offsetTop
var left = 0
var top = 0
var boxer = document.querySelector(".boxer")
document.onmousemove = function(eve) {
left = eve.clientX - x
top = eve.clientY - y
//
if (left <= gap) {
left = 0
}
if (left >= parent.offsetWidth - el.offsetWidth - gap - 35) { //-
left = parent.offsetWidth - el.offsetWidth - 35
}
//
if (top <= gap) top = 0
el.style.left = left + 'px'
el.style.top = top + 'px'
}
document.onmouseup = e => {
document.onmousemove = null
document.onmouseup = null
}
}
} }
} }
}; };
@ -703,16 +742,6 @@ export default {
white-space: pre-wrap; white-space: pre-wrap;
overflow: hidden; overflow: hidden;
} }
.toggle-panel {
position: fixed;
top: 50%;
&.active {
left: 85%;
}
img {
height: 150px;
}
}
.panel-header { .panel-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -900,16 +929,35 @@ export default {
white-space: nowrap; white-space: nowrap;
} }
} }
.panel {
position: relative;
top: 200px;
bottom: 20px;
left: 0;
width: 85%;
height: 0;
.toggle-panel {
position: absolute;
top: 60%;
&.active {
left: 100%;
}
img {
height: 150px;
}
}
&.active {
position: fixed;
height: 70%;
.toggle-panel {
top: 38%;
}
}
}
/deep/.el-container { /deep/.el-container {
height: 80%; height: 100%;
&.is-vertical { &.is-vertical {
background-color: #f5f5f5; background-color: #f5f5f5;
width: 85%;
height: 70%;
position: fixed;
top: 200px;
bottom: 20px;
left: 0;
} }
} }
.right { .right {

@ -1,5 +1,5 @@
<template> <template>
<div class="flex"> <div class="code-wrap flex">
<div class="left"> <div class="left">
<codemirror <codemirror
v-model="codeVal" v-model="codeVal"
@ -28,6 +28,7 @@
>运行</el-button> >运行</el-button>
</div> </div>
</div> </div>
<div class="line"></div>
<div class="code-right answer"> <div class="code-right answer">
<p :class="['text-wrapper', 'pic-num' + picSrcList.length]">{{ runResult }}</p> <p :class="['text-wrapper', 'pic-num' + picSrcList.length]">{{ runResult }}</p>
<div :class="['pic-wrap', {wrong: isError === 0}]" v-if="picSrcList.length"> <div :class="['pic-wrap', {wrong: isError === 0}]" v-if="picSrcList.length">
@ -198,6 +199,7 @@ export default {
newmain.$on("isSubmit", isSubmit => { newmain.$on("isSubmit", isSubmit => {
this.isSubmit = isSubmit this.isSubmit = isSubmit
}) })
this.dragSide()
}, },
methods: { methods: {
@ -482,6 +484,7 @@ export default {
downloadPic(i) { downloadPic(i) {
this.$refs['picLink' + i][0].click() this.$refs['picLink' + i][0].click()
}, },
//
exportResult() { exportResult() {
var FileSaver = require('file-saver'); var FileSaver = require('file-saver');
var blob = new Blob([this.runResult], {type: "text/plain;charset=utf-8"}); var blob = new Blob([this.runResult], {type: "text/plain;charset=utf-8"});
@ -495,12 +498,39 @@ export default {
}).then(res => { }).then(res => {
this.answer = res.experimentCode this.answer = res.experimentCode
}).catch(err => {}) }).catch(err => {})
},
//
dragSide() {
const left = document.querySelector('.left')
const line = document.querySelector('.line')
const right = document.querySelector('.code-right')
//
line.onmousedown = e => {
//
const width = document.querySelector('.code-wrap').clientWidth
document.onmousemove = e => {
let x = e.clientX
//
if(x >= width * .1 && x <= width * .9) {
line.style.left = x + 'px'
left.style.width = x +'px'
right.style.width = document.querySelector('.code-wrap').clientWidth - (x + 5) + 'px'
}
}
document.onmouseup = () => {
document.onmousemove = null
document.onmouseup = null
}
}
} }
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.code-wrap {
position: relative;
}
.left{ .left{
position: relative; position: relative;
width: 60%; width: 60%;
@ -605,6 +635,15 @@ export default {
margin-right: 10px; margin-right: 10px;
} }
} }
.line {
z-index: 2;
position: absolute;
left: 60%;
top: 0;
width: 5px;
height: 100%;
cursor: e-resize;
}
.code-right { .code-right {
width: 40%; width: 40%;
color: #fff; color: #fff;

Loading…
Cancel
Save