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;