优化复制操作

This commit is contained in:
jmal 2023-04-13 18:05:26 +08:00
parent 7bc3335c8e
commit e8e07a3725
4 changed files with 35 additions and 13 deletions

View File

@ -180,7 +180,7 @@ export default {
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {
data.newFolder = false data.newFolder = false
data.id = res.data.id data.id = res.data
}).catch(() => { }).catch(() => {
window.event.preventDefault() window.event.preventDefault()
window.event.stopPropagation() window.event.stopPropagation()

View File

@ -141,7 +141,7 @@
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {
data.newFolder = false data.newFolder = false
data.id = res.data.id data.id = res.data
}).catch(() => { }).catch(() => {
window.event.preventDefault() window.event.preventDefault()
window.event.stopPropagation() window.event.stopPropagation()

View File

@ -465,6 +465,7 @@
@close="clearTreeNode" @close="clearTreeNode"
> >
<el-tree <el-tree
v-if="dialogMoveOrCopyVisible"
ref="directoryTree" ref="directoryTree"
:data="directoryTreeData" :data="directoryTreeData"
node-key="id" node-key="id"
@ -523,7 +524,6 @@ import api from '@/api/file-api'
import BreadcrumbFilePath from "@/components/Breadcrumb/BreadcrumbFilePath"; import BreadcrumbFilePath from "@/components/Breadcrumb/BreadcrumbFilePath";
import IconFile from "@/components/Icon/IconFile"; import IconFile from "@/components/Icon/IconFile";
import EmptyFile from "@/components/EmptyFile"; import EmptyFile from "@/components/EmptyFile";
import Clipboard from 'clipboard';
import SimTextPreview from "@/components/preview/SimTextPreview"; import SimTextPreview from "@/components/preview/SimTextPreview";
import ImageViewer from "@/components/preview/ImageViewer"; import ImageViewer from "@/components/preview/ImageViewer";
import VideoPreview from "@/components/preview/VideoPreview"; import VideoPreview from "@/components/preview/VideoPreview";
@ -2704,9 +2704,7 @@ export default {
this.$refs.contextShow.hideMenu() this.$refs.contextShow.hideMenu()
}, },
clearTreeNode() { clearTreeNode() {
let rootNode = this.$refs.directoryTree.getNode('0') // 清空文件树
rootNode.loaded = false
rootNode.expanded = false
}, },
// 加载下一级文件树 // 加载下一级文件树
directoryTreeLoadNode(node, resolve) { directoryTreeLoadNode(node, resolve) {
@ -2779,8 +2777,12 @@ export default {
confirmUnzip() { confirmUnzip() {
this.unzip(this.openingFile, this.selectTreeNode.id, false) this.unzip(this.openingFile, this.selectTreeNode.id, false)
}, },
moveOrCopy() { showDialogMoveOrCopyVisible() {
this.dialogMoveOrCopyVisible = true this.dialogMoveOrCopyVisible = true
},
moveOrCopy() {
this.showDialogMoveOrCopyVisible()
this.titlePrefix = '移动或复制到: ' this.titlePrefix = '移动或复制到: '
this.unzipOperating = false this.unzipOperating = false
const that = this const that = this
@ -2834,7 +2836,7 @@ export default {
type: 'info', type: 'info',
duration: 0, duration: 0,
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
message: '<span>&nbsp;&nbsp;正在' + operation + '</span>' message: operation + '中...'
}); });
this.dialogMoveOrCopyVisible = false this.dialogMoveOrCopyVisible = false
api[operating]({ api[operating]({
@ -2845,7 +2847,7 @@ export default {
}).then(() => { }).then(() => {
copying.iconClass = null copying.iconClass = null
copying.type = 'success' copying.type = 'success'
copying.message = operation + '成功' copying.message = operation + '中...'
if (this.rowContextData.isFolder) { if (this.rowContextData.isFolder) {
this.$refs.directoryTree.append(this.rowContextData, to) this.$refs.directoryTree.append(this.rowContextData, to)
} }
@ -2875,15 +2877,17 @@ export default {
if (parentData.path) { if (parentData.path) {
path = parentData.path + parentData.name + path path = parentData.path + parentData.name + path
} }
let newFolderName = document.getElementById("treeInput").value
api.newFolder({ api.newFolder({
isFolder: true, isFolder: true,
filename: encodeURI(data.name), filename: encodeURI(newFolderName),
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: encodeURI(path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {
data.newFolder = false data.newFolder = false
data.id = res.data.id data.name = newFolderName
data.id = res.data
}).catch(() => { }).catch(() => {
window.event.preventDefault() window.event.preventDefault()
window.event.stopPropagation() window.event.stopPropagation()
@ -3070,7 +3074,7 @@ export default {
this.unzip(file, undefined, true) this.unzip(file, undefined, true)
}, },
unzipTo(file) { unzipTo(file) {
this.dialogMoveOrCopyVisible = true this.showDialogMoveOrCopyVisible()
this.titlePrefix = '解压到: ' this.titlePrefix = '解压到: '
this.unzipOperating = true this.unzipOperating = true
const that = this const that = this

View File

@ -38,6 +38,24 @@ function connect(username,token){
Bus.$emit('msg/synced', msg) Bus.$emit('msg/synced', msg)
} else { } else {
Bus.$emit('msg/file/change', msg) Bus.$emit('msg/file/change', msg)
if ('copyFile' === url) {
let doc = JSON.parse(msg.body)
if (doc.code === 0) {
Bus.$notify({
title: '操作成功',
dangerouslyUseHTMLString: true,
message: `<div><p>form:</p><span>${doc.from}</span></div><div><p>to:</p><span>${doc.to}</span></div>`,
type: 'success'
});
} else {
Bus.$notify({
title: '操作失败',
dangerouslyUseHTMLString: true,
message: `<span>${doc.msg}</span>`,
type: 'error'
});
}
}
} }
}, ws.headers); }, ws.headers);
}, (err) => { }, (err) => {