diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index c62ce10..7a25ba4 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 @@ -1334,8 +1338,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) @@ -1357,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]; @@ -1366,6 +1374,7 @@ export default { } // 开始拖拽 container.ondragstart = (e) => { + e.target.style.cursor = 'no-drop' // 正在选区获取按住关键键时禁止拖拽 if (_this.drawFlag || _this.isCmd || _this.selectPin) { e.preventDefault() @@ -1376,6 +1385,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, 拖拽过程中移除, 拖拽完后还原 @@ -1437,7 +1450,6 @@ export default { draggedIndex = dragged.rowIndex // 只有选中的才能拖拽 _this.cellMouseIndex = -1 - // dragged.style.cursor = 'not-allowed' dragBackCorlor = dragged.style.backgroundColor } } @@ -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 @@ -2977,6 +2994,9 @@ export default { }, // 点击文件或文件夹 fileClick(row) { + if (this.editingIndex === row.index){ + return + } this.openingFile = row if (row.isFolder) { 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;