From daf196b81cc44fbecda6f431bb31bb838c4191a4 Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 1 Jun 2020 11:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E5=8E=8B=E3=80=81?= =?UTF-8?q?=E9=A2=84=E8=A7=88zip=E6=96=87=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FileTree/index.vue | 21 +++++--- src/components/ShowFile/ShowFile.vue | 76 +++++++++++++++++----------- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/components/FileTree/index.vue b/src/components/FileTree/index.vue index 87cfdf1..a0bc616 100644 --- a/src/components/FileTree/index.vue +++ b/src/components/FileTree/index.vue @@ -72,7 +72,6 @@ loadOfLocalFileMode(node, resolve) { if (node.level === 0) { let elDialogWrapper = document.querySelector('.compressed-file-dialog') - console.log('elDialogWrapper', elDialogWrapper.style.zIndex) elDialogWrapper.style.zIndex += 5 return resolve(this.directoryTreeData) } @@ -91,11 +90,13 @@ directoryTreeLoadNode(node, resolve) { let fileId = null if (node.level === 0) { + let data = [{'id':"0",'name':'全部文件'}] const that = this setTimeout(function () { that.$refs.fileTree.setCurrentKey('0') + that.$emit('treeNodeClick',data[0]) },0) - return resolve([{'id':"0",'name':'全部文件'}]) + return resolve(data) } if (node.level > 1){ fileId = node.data.id @@ -111,12 +112,13 @@ }, // 点击文件树 treeNodeClick(row) { - if(suffix.simText.includes(row.suffix)){ - // 文本文件 - this.textPreviewRow = row - this.textPreviewVisible = true - this.filepath = row.path - } + this.$emit('treeNodeClick',row) + // if(suffix.simText.includes(row.suffix)){ + // // 文本文件 + // this.textPreviewRow = row + // this.textPreviewVisible = true + // this.filepath = row.path + // } }, // 节点被展开时触发 treeNodeExpand(row,node,event) { @@ -171,6 +173,9 @@ ); }else{ let iconClass = this.findIconClass(node.data) + if(!this.localFileMode && node.data.id === '0'){ + iconClass = 'folder' + } return ( diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 74f2d2c..540bb7d 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -109,7 +109,7 @@ :visible.sync="openCompressionVisible"> 查看压缩文件 - 解压到... + 解压到... 解压到当前目录 预览 @@ -122,7 +122,7 @@ :visible.sync="notPreviewDialogVisible"> 此文件不支持预览, 是否下载该文件? - 强行使用文本编辑器打开 + 强行使用文本编辑器打开 取 消 确 定 @@ -133,9 +133,14 @@ + + + + + @@ -155,10 +160,11 @@ > @@ -613,11 +619,14 @@ menuTriangle: '', // 三角菜单 cellMouseIndex: -1, editingIndex: -1, + titlePrefix: '', + unzipOperating: false, dialogMoveOrCopyVisible: false, - compressedFileVisible: false, directoryTreeData: [], + compressedFileVisible: false, compressedFileData: [], compressedFileName: '', + compressedFileTempDir: false, selectTreeNode: {}, directoryTreeProps: { label: 'name', @@ -659,7 +668,6 @@ notPreviewDialogVisible: false, openingFile: '', openCompressionVisible: false, - compressedFileTempDir: false, } }, computed: { @@ -2014,7 +2022,6 @@ let rootNode = this.$refs.directoryTree.getNode('0') rootNode.loaded = false rootNode.expanded = false - console.log(rootNode) }, // 加载下一级文件树 directoryTreeLoadNode(node, resolve) { @@ -2041,7 +2048,6 @@ }, // 点击文件树 treeNodeClick(row,node,event) { - console.log('treeNodeClick',node) this.selectTreeNode = row this.selectTreeNode.showName = ' "' + row.name + '"' }, @@ -2084,8 +2090,13 @@ copyFileTree() { this.copyOrMove('copy'); }, + // 解压文件 + confirmUnzip() { + this.unzip(this.openingFile,this.selectTreeNode.id,false) + }, moveOrCopy(){ this.dialogMoveOrCopyVisible = true + this.titlePrefix = '移动或复制到: ' const that = this setTimeout(function () { that.selectTreeNode = that.$refs.directoryTree.getCurrentNode() @@ -2402,6 +2413,17 @@ compressionFilePreview(file){ this.unzip(file,undefined,true) }, + unzipTo(file){ + this.dialogMoveOrCopyVisible = true + this.titlePrefix = '解压到: ' + this.unzipOperating = true + const that = this + setTimeout(function () { + that.openCompressionVisible = false + that.selectTreeNode = that.$refs.directoryTree.getCurrentNode() + that.selectTreeNode.showName = ' "' + that.selectTreeNode.name + '"' + },100) + }, // 解压文件 unzip(file, destFileId, tempDir) { let status = '解压' @@ -2420,13 +2442,23 @@ decompressing.type = 'success' decompressing.message = status+'成功' - this.compressedFileData = res.data - this.compressedFileVisible = true - this.compressedFileName = file.name - this.compressedFileTempDir = tempDir + if(tempDir){ + this.compressedFileData = res.data + this.compressedFileVisible = true + this.compressedFileName = file.name + this.compressedFileTempDir = tempDir + } + const that = this setTimeout(function () { decompressing.close() + that.openCompressionVisible = false + if(file.id === destFileId){ + that.getFileList() + } + if(destFileId && file.id !== destFileId && !tempDir){ + that.dialogMoveOrCopyVisible = false + } },1000) }).catch(() => { decompressing.close() @@ -2499,21 +2531,7 @@ } // 打开文件 let fileIds = [row.id] - this.notPreviewDialogVisible = true - - // this.$confirm('此文件不支持预览, 是否下载该文件?', '提示', { - // confirmButtonText: '确定', - // cancelButtonText: '强行使用文本编辑器打开', - // type: 'warning', - // distinguishCancelAndClose: true - // }).then(() => { - // let url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + row.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + fileIds - // window.open(url, '_self') - // }).catch(() => { - // this.textPreviewRow = row - // this.textPreviewVisible = true - // }) } }, // 强行使用文本编辑器打开