接入下载
parent
afe96c5c2d
commit
c1e2eba4d1
|
@ -81,42 +81,43 @@ FluArea {
|
||||||
property string brief: "这是一个简介"
|
property string brief: "这是一个简介"
|
||||||
|
|
||||||
function getType(suffix) {
|
function getType(suffix) {
|
||||||
if(suffix === "md")
|
if (suffix === "md")
|
||||||
return "MD"
|
return "MD"
|
||||||
else if(suffix === "mp4" || suffix === "avi"
|
else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb"
|
||||||
|| suffix === "rmvb" || suffix === "rm"
|
|| suffix === "rm" || suffix === "wmv" || suffix === "mkv")
|
||||||
|| suffix === "wmv" || suffix === "mkv")
|
|
||||||
return "VIDEO"
|
return "VIDEO"
|
||||||
else return "OTHER"
|
else
|
||||||
|
return "OTHER"
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFile(knowledgeFileId) {
|
function loadFile(knowledgeFileId) {
|
||||||
content_area.knowledgeFileId = knowledgeFileId
|
content_area.knowledgeFileId = knowledgeFileId
|
||||||
console.log(knowledgeFileId)
|
console.log(knowledgeFileId)
|
||||||
Request.get("knowledge/" + knowledgeFileId, function (response, data) {
|
Request.get("knowledge/" + knowledgeFileId,
|
||||||
content_page.publishTime = data.createTime
|
function (response, data) {
|
||||||
content_page.title = data.name
|
content_page.publishTime = data.createTime
|
||||||
content_page.fileId = data.knowledgeFileAttribute.id
|
content_page.title = data.name
|
||||||
|
content_page.fileId = data.knowledgeFileAttribute.id
|
||||||
|
|
||||||
content_area.type = data.knowledgeFileAttribute.suffix
|
content_area.type = data.knowledgeFileAttribute.suffix
|
||||||
|
|
||||||
var tagString = ""
|
var tagString = ""
|
||||||
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
|
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
|
||||||
if (j != 0)
|
if (j != 0)
|
||||||
tagString = tagString + ","
|
tagString = tagString + ","
|
||||||
tagString = tagString + data.knowledgeFileAttribute.tags[j].name
|
tagString = tagString + data.knowledgeFileAttribute.tags[j].name
|
||||||
}
|
}
|
||||||
content_page.tags = tagString.split(",")
|
content_page.tags = tagString.split(",")
|
||||||
|
|
||||||
content_page.brief = data.knowledgeFileAttribute.brief
|
content_page.brief = data.knowledgeFileAttribute.brief
|
||||||
content_page.browsCount = data.knowledgeFileAttribute.pageView
|
content_page.browsCount = data.knowledgeFileAttribute.pageView
|
||||||
|
|
||||||
var starers = data.knowledgeFileAttribute.starers
|
var starers = data.knowledgeFileAttribute.starers
|
||||||
for(var i=0; i<starers.length; i++) {
|
for (var i = 0; i < starers.length; i++) {
|
||||||
|
|
||||||
}
|
}
|
||||||
content_page.favoriteCount = starers.length
|
content_page.favoriteCount = starers.length
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -208,7 +209,8 @@ FluArea {
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
emit: content_area.download(content_area.knowledgeFileId)
|
emit: content_area.download(content_area.knowledgeFileId)
|
||||||
FileTransferManager.download(content_area.knowledgeFileId)
|
FileTransferManager.download(content_page.fileId,
|
||||||
|
content_page.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,8 +304,7 @@ bool httpDownload(const std::string &url, const std::string &savePath, const Fil
|
||||||
if (!obj.curlHandle)
|
if (!obj.curlHandle)
|
||||||
return false;
|
return false;
|
||||||
obj.totalSize = item.totalSize;//原始文件大小
|
obj.totalSize = item.totalSize;//原始文件大小
|
||||||
obj.file = std::ofstream(savePath, std::ios::binary | std::ios::app);
|
obj.file = std::ofstream(savePath, std::ios::binary);
|
||||||
|
|
||||||
if (!obj.file.is_open()) {
|
if (!obj.file.is_open()) {
|
||||||
qDebug() << "Open File Failed";
|
qDebug() << "Open File Failed";
|
||||||
curl_easy_cleanup(obj.curlHandle);
|
curl_easy_cleanup(obj.curlHandle);
|
||||||
|
@ -348,7 +347,8 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam
|
||||||
}
|
}
|
||||||
|
|
||||||
auto size = resJson["size"].toInteger();
|
auto size = resJson["size"].toInteger();
|
||||||
std::string savePath = "D:\\Downloads\\" + fileName.toStdString();
|
std::string savePath = "D:\\Downloads\\" + fileName.toLocal8Bit().toStdString();
|
||||||
|
qDebug() << savePath.c_str();
|
||||||
QFileInfo fileInfo(savePath.c_str());
|
QFileInfo fileInfo(savePath.c_str());
|
||||||
int64_t completedSize = fileInfo.exists() ? fileInfo.size() : 0;
|
int64_t completedSize = fileInfo.exists() ? fileInfo.size() : 0;
|
||||||
FileItem item{true, fileId, fileName, completedSize, size};
|
FileItem item{true, fileId, fileName, completedSize, size};
|
||||||
|
|
Loading…
Reference in New Issue