From a8a7df41e2f11b62f7d090a09cc64e1e7d1a440f Mon Sep 17 00:00:00 2001 From: jmal Date: Sun, 11 Apr 2021 16:09:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E8=BE=93=E5=85=A5=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 73 +++++++++++++++++----------- src/styles/home-index.scss | 6 ++- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index c62ce10..aeda901 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -228,28 +228,12 @@ :sortable="item.sortable ? (orderCustom ?'custom':true) : false" > @@ -345,7 +329,18 @@
-
{{ item.name }}
+ + +
{{ item.name }}
@@ -538,17 +533,19 @@ import FileTree from "@/components/FileTree" import '@/utils/directives.js' import fileConfig from '@/utils/file-config' +import EditElement from "@/views/markdown/EditElement"; var rowStyleExecuting = false export default { name: 'ShowFile', components: { + EditElement, MessageDialog, AudioPreview, VideoPreview, ImageViewer, SimTextPreview, IconFile, BreadcrumbFilePath, EmptyFile, ButtonUpload, FileTree }, props: { - selectFile: { + selectFile: { // 是否为选择文件模式 type: Boolean, defalut: false }, @@ -884,7 +881,11 @@ export default { // 指令的定义 inserted: function (el) { // 聚焦元素 - el.querySelector('input').focus() + let input = el.querySelector('input') + if (!input){ + input = el.querySelector('textarea') + } + input.focus() } }, resize: { // 指令的名称 @@ -1038,12 +1039,15 @@ export default { if (throughRow) { // 鼠标按下时就选中文件 if (!_this.selectRowData.includes(_this.fileList[throughRow.rowIndex])){ + _this.editingIndex = -1 if (!_this.isCmd && !_this.selectPin) { _this.$refs.fileListTable.clearSelection() _this.$refs.fileListTable.toggleRowSelection([{row: _this.fileList[throughRow.rowIndex], selected: true}]) } } return + } else { + _this.editingIndex = -1 } if (evt.button !== 0) { return @@ -1073,6 +1077,7 @@ export default { div.style.overflow = 'hidden' draw.appendChild(div) document.onmousemove = function (e) { + console.log('onmousemove') let evt = window.event || e let scrollTop = document.body.scrollTop || document.documentElement.scrollTop let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft @@ -1334,8 +1339,11 @@ export default { } } - // 复原拖拽的dom - let recover = function (animation) { + /*** + * 复原拖拽的dom + * @param animation 是否显示动画 + */ + let recoverDragDom = function (animation) { if (animation) { _this.selectRowData.forEach(row => { let dragingDiv = document.getElementById('dragingDiv' + row.index) @@ -1376,6 +1384,10 @@ export default { if (!e.target.slot || e.target.slot !== 'jmal'){ return true } + // 该文件正在重命名 + if (e.target.rowIndex === _this.editingIndex){ + return + } // 当滚动条滚动后禁止拖拽 if (_this.fileListScrollTop === 0) { // 复制被拖拽dom的title, 拖拽过程中移除, 拖拽完后还原 @@ -1540,12 +1552,12 @@ export default { type: 'info' }).then(() => { _this.copyOrMoveApi('move', forms, to.id) - recover(false) + recoverDragDom(false) }).catch(() => { - recover(true) + recoverDragDom(true) }) } else { - recover(true) + recoverDragDom(true) } } // 清除之前的样式 @@ -1809,6 +1821,7 @@ export default { if (!this.path) { this.path = '' } + this.editingIndex = -1 this.$router.push(`?vmode=${this.vmode}&path=${this.path}`) // 改变拖拽目标 this.rowDrop() @@ -2254,7 +2267,10 @@ export default { // 选取输入框部分内容 renameInputFocus(event, suffix) { event.currentTarget.selectionStart = 0 - event.currentTarget.selectionEnd = event.currentTarget.value.length - suffix.length === 0 ? 0 : suffix.length - 1 + event.currentTarget.selectionEnd = event.currentTarget.value.length + if (suffix){ + event.currentTarget.selectionEnd -= suffix.length + 1 + } }, // 重命名 rowRename(newFileName, row) { @@ -2329,6 +2345,7 @@ export default { } }).then(() => { this.$refs.fileListTable.clearSelection() + this.$message.success("重命名成功") }).catch(() => { this.renameLoading = false this.editingIndex = -1 diff --git a/src/styles/home-index.scss b/src/styles/home-index.scss index 9ead7ea..f56b654 100644 --- a/src/styles/home-index.scss +++ b/src/styles/home-index.scss @@ -86,7 +86,7 @@ /deep/ .cell { .el-button { padding: 6px 10px; - margin-left: 20px; + margin-left: 10px; } } /deep/ .el-checkbox { @@ -300,6 +300,10 @@ position: absolute; padding: 0 5px 0 5px; bottom: 5px; + textarea { + overflow: hidden; + resize:none; + } } /deep/ .grid-item-text-image { position: absolute; From 6b48d5d05a5e5329163d4bfbbbaee6bd67ff87bf Mon Sep 17 00:00:00 2001 From: jmal Date: Sun, 11 Apr 2021 16:45:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E6=96=87=E4=BB=B6=E6=97=B6=E9=BC=A0=E6=A0=87=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index aeda901..71cd5f4 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -1077,7 +1077,6 @@ export default { div.style.overflow = 'hidden' draw.appendChild(div) document.onmousemove = function (e) { - console.log('onmousemove') let evt = window.event || e let scrollTop = document.body.scrollTop || document.documentElement.scrollTop let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft @@ -1365,6 +1364,7 @@ export default { container.ondragend = function (e) { Bus.$emit('onDragStart', false) + e.dataTransfer.effectAllowed = 'none' // console.log('child'+dragIndex+'拖拽结束'); // 清除上次进入的容器的状态 const last = target.children[dragIndex]; @@ -1374,6 +1374,7 @@ export default { } // 开始拖拽 container.ondragstart = (e) => { + e.target.style.cursor = 'no-drop' // 正在选区获取按住关键键时禁止拖拽 if (_this.drawFlag || _this.isCmd || _this.selectPin) { e.preventDefault() @@ -1449,7 +1450,6 @@ export default { draggedIndex = dragged.rowIndex // 只有选中的才能拖拽 _this.cellMouseIndex = -1 - // dragged.style.cursor = 'not-allowed' dragBackCorlor = dragged.style.backgroundColor } } From 6ea2928e4731b479e93d1f9032e6464ee7ac93bd Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 12 Apr 2021 22:56:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E6=97=B6=E7=A6=81=E6=AD=A2=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 71cd5f4..7a25ba4 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -2994,6 +2994,9 @@ export default { }, // 点击文件或文件夹 fileClick(row) { + if (this.editingIndex === row.index){ + return + } this.openingFile = row if (row.isFolder) { this.editingIndex = -1