|
|
@@ -4571,78 +4571,93 @@ export default { |
|
|
|
* type :1 为文件,2位协作文件 |
|
|
|
*/ |
|
|
|
clientDownLoad: function (file, type) { |
|
|
|
var thisApp = this; |
|
|
|
if (this.isClient) { |
|
|
|
this.$axios({ |
|
|
|
method: "put", |
|
|
|
url: encodeURI( |
|
|
|
process.env.API_HOST + |
|
|
|
"projects/download/" + |
|
|
|
file.archID + |
|
|
|
"/" + |
|
|
|
sessionStorage.userId + |
|
|
|
"/" + |
|
|
|
type |
|
|
|
), |
|
|
|
}) |
|
|
|
.then((response) => { |
|
|
|
if (response.data.state == 1) { |
|
|
|
file.downloadStatus = 1; |
|
|
|
file.isDownload = true; |
|
|
|
var archid = file.archID; |
|
|
|
var alias = file.alias; |
|
|
|
var filename = file.archName + "." + file.extension; |
|
|
|
if (file.version > 1) { |
|
|
|
filename = file.archName + file.version + "." + file.extension; |
|
|
|
} |
|
|
|
var folderID = file.folderID; |
|
|
|
const folderName = |
|
|
|
thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; |
|
|
|
var projID = file.projID; |
|
|
|
if (type == 1) { |
|
|
|
system.downloadFile( |
|
|
|
archid, |
|
|
|
filename, |
|
|
|
folderID, |
|
|
|
sessionStorage.userId, |
|
|
|
sessionStorage.companyId, |
|
|
|
alias |
|
|
|
); |
|
|
|
} else { |
|
|
|
const folderName = |
|
|
|
thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; |
|
|
|
system.downloadFile( |
|
|
|
archid, |
|
|
|
filename, |
|
|
|
folderID, |
|
|
|
sessionStorage.userId, |
|
|
|
sessionStorage.companyId, |
|
|
|
alias, |
|
|
|
sessionStorage.projName, |
|
|
|
folderName, |
|
|
|
sessionStorage.projId |
|
|
|
); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.$notify({ |
|
|
|
title: "温馨提示", |
|
|
|
message: response.data.message, |
|
|
|
type: "error", |
|
|
|
offset: 30, |
|
|
|
duration: 2000, |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
this.$notify({ |
|
|
|
title: "温馨提示", |
|
|
|
message: "下载失败", |
|
|
|
type: "error", |
|
|
|
offset: 30, |
|
|
|
duration: 2000, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
if(!this.isClient) return; |
|
|
|
const { ipfsCid, archName: fileName, } = file; |
|
|
|
const { folderName, levelId, id: folderId } = this.nowFolder; |
|
|
|
system.downloadFile(ipfsCid, sessionStorage.projName, fileName, folderName, (resMessage, socketIns) => { |
|
|
|
console.log('receive download file message:', resMessage, socketIns); |
|
|
|
// {"size":"11","currentSize":"11","unit":"B","process":100,"hash":""} |
|
|
|
try { |
|
|
|
const out = JSON.parse(resMessage.data); |
|
|
|
if(out.process !== 100) return; |
|
|
|
socketIns.close(); |
|
|
|
file.downloadStatus = 1; |
|
|
|
file.isDownload = true; |
|
|
|
this.$forceUpdate(); |
|
|
|
} catch (e) { |
|
|
|
console.error('socket-download-file parse data have error:', e); |
|
|
|
} |
|
|
|
}); |
|
|
|
// var thisApp = this; |
|
|
|
// this.$axios({ |
|
|
|
// method: "put", |
|
|
|
// url: encodeURI( |
|
|
|
// process.env.API_HOST + |
|
|
|
// "projects/download/" + |
|
|
|
// file.archID + |
|
|
|
// "/" + |
|
|
|
// sessionStorage.userId + |
|
|
|
// "/" + |
|
|
|
// type |
|
|
|
// ), |
|
|
|
// }) |
|
|
|
// .then((response) => { |
|
|
|
// if (response.data.state == 1) { |
|
|
|
// file.downloadStatus = 1; |
|
|
|
// file.isDownload = true; |
|
|
|
// var archid = file.archID; |
|
|
|
// var alias = file.alias; |
|
|
|
// var filename = file.archName + "." + file.extension; |
|
|
|
// if (file.version > 1) { |
|
|
|
// filename = file.archName + file.version + "." + file.extension; |
|
|
|
// } |
|
|
|
// var folderID = file.folderID; |
|
|
|
// const folderName = |
|
|
|
// thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; |
|
|
|
// var projID = file.projID; |
|
|
|
// if (type == 1) { |
|
|
|
// system.downloadFile( |
|
|
|
// archid, |
|
|
|
// filename, |
|
|
|
// folderID, |
|
|
|
// sessionStorage.userId, |
|
|
|
// sessionStorage.companyId, |
|
|
|
// alias |
|
|
|
// ); |
|
|
|
// } else { |
|
|
|
// const folderName = |
|
|
|
// thisApp.listUserFolders[thisApp.nowFolderIndex].folderName; |
|
|
|
// system.downloadFile( |
|
|
|
// archid, |
|
|
|
// filename, |
|
|
|
// folderID, |
|
|
|
// sessionStorage.userId, |
|
|
|
// sessionStorage.companyId, |
|
|
|
// alias, |
|
|
|
// sessionStorage.projName, |
|
|
|
// folderName, |
|
|
|
// sessionStorage.projId |
|
|
|
// ); |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// this.$notify({ |
|
|
|
// title: "温馨提示", |
|
|
|
// message: response.data.message, |
|
|
|
// type: "error", |
|
|
|
// offset: 30, |
|
|
|
// duration: 2000, |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// .catch((error) => { |
|
|
|
// this.$notify({ |
|
|
|
// title: "温馨提示", |
|
|
|
// message: "下载失败", |
|
|
|
// type: "error", |
|
|
|
// offset: 30, |
|
|
|
// duration: 2000, |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 客户端上传文件 |
|
|
|