From b1a6d7e1752e906f0b26bc37980fecf4e11745ca Mon Sep 17 00:00:00 2001 From: jmal Date: Thu, 18 Jun 2020 11:44:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BB=91=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=9B=AE=E5=BD=95=E5=92=8C=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/preview/SimTextPreview.vue | 45 ++++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index a833057..e60ce76 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -25,10 +25,11 @@
-
+
+
{ + this.dragControllerDiv() + this.setTheme() + }) }).catch(() => { this.loading.close() }) @@ -202,6 +209,34 @@ } }, methods:{ + dragControllerDiv() { + let resize = document.querySelector('.el-dialog__body .content .editor-resize'); + let left = document.querySelector('.file-contents'); + if(resize){ + // 鼠标按下事件 + const that = this + resize.onmousedown = function (e) { + let startX = e.clientX; + let contentsStartWidth = left.offsetWidth + 10 + // 鼠标拖动事件 + document.onmousemove = function (e) { + let endX = e.clientX; + // 移动的距离。负数向左移动,正数向右移动 + let moveLen = endX - startX + left.style.width = (contentsStartWidth + moveLen)+'px' + that.editorWidth = document.body.clientWidth * that.dialogWidth - (contentsStartWidth + moveLen) + } + // 鼠标松开事件 + document.onmouseup = function (evt) { + document.onmousemove = null; + document.onmouseup = null; + resize.releaseCapture && resize.releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉 + } + resize.setCapture && resize.setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获 + return false; + } + } + }, treeNodeClick(row) { if(row.isFolder){ return @@ -240,7 +275,7 @@ }) }, containerResize() { - this.editorWidth = document.body.clientWidth * this.dialogWidth - 250 + this.editorWidth = document.body.clientWidth * this.dialogWidth - this.contentsWidth this.editorHieght = document.body.clientHeight * this.dialogWidth - 50 }, handleClose(done) { @@ -294,7 +329,6 @@ }, // 全屏 fullScreen() { - console.log(this.$refs.simTextDialog) this.fullscreen = !this.fullscreen const dragDom = document.querySelector('.simtext-dialog .el-dialog'); if(this.fullscreen){ @@ -480,7 +514,6 @@ } .file-contents{ - width: 300px; overflow-y: scroll; overflow-x: hidden;