diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 3d0ecf7..31549c3 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -1,5 +1,5 @@ -
+
-
+
@@ -141,6 +141,9 @@ import newmain from "../util/newMain"; import util from '@/util' import Config from '@/config' 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 { data() { return { @@ -213,6 +216,7 @@ export default { }, 1000) } } + this.drag() }, methods: { // 获取项目列表 @@ -648,6 +652,7 @@ export default { }, // 实验面板显示隐藏 togglePannel() { + document.querySelector('#panel').style.left = 0 this.pannelVisible = !this.pannelVisible }, // 倒计时 @@ -687,6 +692,40 @@ export default { this.counterTimer = setInterval(() => { this.counter(this.projectPermissions ? this.countVal-- : this.countVal++) }, 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; overflow: hidden; } -.toggle-panel { - position: fixed; - top: 50%; - &.active { - left: 85%; - } - img { - height: 150px; - } -} .panel-header { display: flex; justify-content: space-between; @@ -900,16 +929,35 @@ export default { 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 { - height: 80%; + height: 100%; &.is-vertical { background-color: #f5f5f5; - width: 85%; - height: 70%; - position: fixed; - top: 200px; - bottom: 20px; - left: 0; } } .right { diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 1d1e392..81e917f 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -1,5 +1,5 @@