From e7f809a973b74aed19c6fa92f61a3e108d8ba497 Mon Sep 17 00:00:00 2001 From: wuyize Date: Thu, 6 Jul 2023 15:58:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=AD=E7=82=B9?= =?UTF-8?q?=E7=BB=AD=E4=BC=A0=EF=BC=8C=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qml/component/TransferListPopup.qml | 3 + AicsKnowledgeBase/src/FileTransferManager.cpp | 110 +++++------------- AicsKnowledgeBase/src/FileTransferManager.h | 3 +- 3 files changed, 30 insertions(+), 86 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/TransferListPopup.qml b/AicsKnowledgeBase/qml/component/TransferListPopup.qml index bd3c66e..7c13c78 100644 --- a/AicsKnowledgeBase/qml/component/TransferListPopup.qml +++ b/AicsKnowledgeBase/qml/component/TransferListPopup.qml @@ -112,6 +112,9 @@ Popup { if (!paused) { console.log("pause") FileTransferManager.pause(fileId) + } else { + FileTransferManager.download(fileId, + name, true) } } } diff --git a/AicsKnowledgeBase/src/FileTransferManager.cpp b/AicsKnowledgeBase/src/FileTransferManager.cpp index 35888fc..7c45f0e 100644 --- a/AicsKnowledgeBase/src/FileTransferManager.cpp +++ b/AicsKnowledgeBase/src/FileTransferManager.cpp @@ -278,7 +278,7 @@ curl_off_t getHttpFileSize(const std::string &url) curl_off_t fileLength = 0; CURL *handle = initCurlWithCommonOptions(); - curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); + curl_easy_setopt(handle, CURLOPT_URL, (baseUrl + url).c_str()); curl_easy_setopt(handle, CURLOPT_HEADER, 0); //只需要header头 curl_easy_setopt(handle, CURLOPT_NOBODY, 1); //不需要body @@ -292,14 +292,8 @@ curl_off_t getHttpFileSize(const std::string &url) return fileLength; } -bool httpDownload(const std::string &url, const FileItem &item) +bool httpDownload(const std::string &url, const std::string &savePath, const FileItem &item) { - auto fileSize = getHttpFileSize(url);//获得文件大小。 - if (fileSize == -1) - return false; - - qDebug() << "FileSize: " << fileSize; - downloadingMapMutex.lock(); auto [iter, _] = downloadingMap.emplace(item.id, (FileDownloading) item); downloadingMapMutex.unlock(); @@ -309,8 +303,8 @@ bool httpDownload(const std::string &url, const FileItem &item) obj.curlHandle = initCurlWithCommonOptions(); if (!obj.curlHandle) return false; - obj.totalSize = fileSize;//原始文件大小 - obj.file = std::ofstream("D:\\Downloads\\" + obj.name.toStdString() + ".zip", std::ios::binary); + obj.totalSize = item.totalSize;//原始文件大小 + obj.file = std::ofstream(savePath, std::ios::binary | std::ios::app); if (!obj.file.is_open()) { qDebug() << "Open File Failed"; @@ -320,7 +314,7 @@ bool httpDownload(const std::string &url, const FileItem &item) curl_easy_setopt(obj.curlHandle, CURLOPT_HEADER, 0); curl_easy_setopt(obj.curlHandle, CURLOPT_NOSIGNAL, 1L); - curl_easy_setopt(obj.curlHandle, CURLOPT_URL, url.c_str()); + curl_easy_setopt(obj.curlHandle, CURLOPT_URL, (baseUrl + url).c_str()); curl_easy_setopt(obj.curlHandle, CURLOPT_WRITEDATA, (void *) &obj); curl_easy_setopt(obj.curlHandle, CURLOPT_WRITEFUNCTION, writeDataFunc); curl_easy_setopt(obj.curlHandle, CURLOPT_NOPROGRESS, false);//设为false 下面才能设置进度响应函数 @@ -339,42 +333,36 @@ bool httpDownload(const std::string &url, const FileItem &item) return res == CURLE_OK; } -void FileTransferManager::download(const QString& fileId) +void FileTransferManager::download(const QString &fileId, const QString &fileName, bool resume) { - QtConcurrent::run([fileId, this] { + QtConcurrent::run([fileId, fileName, resume, this] { qDebug() << "Start Get"; - std::string resData; if (CURLE_OK != httpGet("File/" + fileId.toStdString() + "/status", resData)) return; - qDebug() << resData.c_str(); auto resJson = QJsonDocument::fromJson(resData.c_str()); - //if(!resJson["isCompleted"].toBool()) - return; - - - -/* int size = resJson["size"].toInt(); - FileItem item{fileId, resJson["md5"].toString(), 0, size}; - QTimer::singleShot(0, qApp, [this, item]() { - FileTransferListModel::instance().insertItem(item); - });*/ - - auto fileUrl = "File/" + fileId.toStdString(); - - -/* curl_slist *headers = nullptr; - headers = curl_slist_append(headers, "Range: bytes=0-"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);*/ - - - int64_t size = getHttpFileSize(fileUrl); - FileItem item{true, fileId, fileId, 0, size}; - - auto res = httpDownload(fileUrl, item); + if (!resJson["isCompleted"].toBool()) { + qDebug() << "File Not Completed"; + return; + } + auto size = resJson["size"].toInteger(); + std::string savePath = "D:\\Downloads\\" + fileName.toStdString(); + QFileInfo fileInfo(savePath.c_str()); + int64_t completedSize = fileInfo.exists() ? fileInfo.size() : 0; + FileItem item{true, fileId, fileName, completedSize, size}; + if (!resume) + QTimer::singleShot(0, qApp, [item]() { + FileTransferListModel::instance().insertItem(item); + }); + auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), completedSize, size); + auto res = httpDownload(fileUrl, savePath, item); + /*auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), 0, size / 2); + auto res = httpDownload(fileUrl, savePath, item); + fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), size / 2, size); + res = httpDownload(fileUrl, savePath, item);*/ qDebug() << "End Get" << res; }); @@ -410,52 +398,6 @@ int64_t FileTransferManager::getFileSize(const QUrl &fileUrl) return QFile(fileUrl.toLocalFile()).size(); } -void FileTransferManager::resume(const QString &fileId) -{ - - QtConcurrent::run([fileId, this] { - qDebug() << "Start Get"; - - std::string resData; - if (CURLE_OK != httpGet("File/" + fileId.toStdString() + "/status", resData)) - return; - - qDebug() << resData.c_str(); - return; - auto resJson = QJsonDocument::fromJson(resData.c_str()); - //if(!resJson["isCompleted"].toBool()) - // return; - - - -/* int size = resJson["size"].toInt(); - FileItem item{fileId, resJson["md5"].toString(), 0, size}; - QTimer::singleShot(0, qApp, [this, item]() { - FileTransferListModel::instance().insertItem(item); - });*/ - - auto fileUrl = "https://curl.se/download/curl-8.1.2.zip"; - - -/* curl_slist *headers = nullptr; - headers = curl_slist_append(headers, "Range: bytes=0-"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);*/ - - - int64_t size = getHttpFileSize(fileUrl); - FileItem item{true, fileId, fileId, 0, size}; - QTimer::singleShot(0, qApp, [this, item]() { - FileTransferListModel::instance().insertItem(item); - }); - - auto res = httpDownload(fileUrl, item); - - - qDebug() << "End Get" << res; - }); - -} - QString FileTransferManager::getFileName(const QUrl &fileUrl) { return fileUrl.fileName(); diff --git a/AicsKnowledgeBase/src/FileTransferManager.h b/AicsKnowledgeBase/src/FileTransferManager.h index 2f2406a..94a357f 100644 --- a/AicsKnowledgeBase/src/FileTransferManager.h +++ b/AicsKnowledgeBase/src/FileTransferManager.h @@ -24,9 +24,8 @@ public: Q_INVOKABLE QString getFileMd5(const QUrl& fileUrl); Q_INVOKABLE void upload(const QUrl& fileUrl, const QString& fileId, const QString& ticket, const QString &fileName); - Q_INVOKABLE void download(const QString& fileId); + Q_INVOKABLE void download(const QString& fileId, const QString& fileName, bool resume = false); Q_INVOKABLE void pause(const QString& fileId); - Q_INVOKABLE void resume(const QString& fileId); private: From 42b9ecf2ffd6048bb5bda2d3a1fbf35493d54be9 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Thu, 6 Jul 2023 16:09:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FileListItem=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E5=92=8C=E9=83=A8=E5=88=86=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 174 ++++++++++-------- .../qml/component/FileListItem.qml | 47 +++++ 2 files changed, 141 insertions(+), 80 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index 5ea92ec..78cfd61 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -38,6 +38,7 @@ Item { Component { id: fileListItemHeader ColumnLayout { + id: topColumnLayout function add(folderName, uuid) { console.log(header.items) header.items = header.items.concat([{ @@ -45,6 +46,77 @@ Item { "uuid": uuid }]) } + function update() { + var uuid = header.items.length + === 0 ? "null" : header.items[header.items.length - 1].uuid + Request.get("/knowledge/" + uuid, function (response) { + var data = JSON.parse(response) + console.log(response) + console.log(data.knowledgeFileAttribute) + fileListModel.clear() + var files = data.children + for (var i = 0; i < files.length; i++) { + var file = files[i] + console.log(file.name) + var modelItem = { + "title": file.name, + "uuid": file.id, + "date"// cut time after 'T' + : file.createTime.substring(0, 10), + "fuuid": uuid + } + if (file.knowledgeFileAttribute === null) { + modelItem.type = "folder" + modelItem.isDir = true + modelItem.size = 0 + } else { + modelItem.isDir = false + modelItem.type = getType( + file.knowledgeFileAttribute.suffix) + modelItem.size = file.knowledgeFileAttribute.size + modelItem.brief = file.knowledgeFileAttribute.brief + modelItem.pageView = file.knowledgeFileAttribute.pageView + modelItem.stars = 0 + // merge file.knowledgeFileAttribute.tags array to a string + var tagString = "" + for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + file.knowledgeFileAttribute.tags[j].name + } + modelItem.tags = tagString + } + fileListModel.append(modelItem) + } + console.log(fileListModel.count) + listView.currentIndex = -1 + }) + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" + || suffix === "jpeg" || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" + || suffix === "rmvb" || suffix === "rm" + || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } RowLayout { Layout.preferredWidth: parent.width Item { @@ -53,14 +125,21 @@ Item { width: 28 InputDialog { id: dialog - title: "½ļ" + title: "新建文件夹" buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton - negativeText: "ȡ" - positiveText: "ȷ" - message: "ļ" + negativeText: "取消" + positiveText: "确定" + message: "请输入文件夹名称" onPositiveClicked: text => { - console.log(text) + var param = { + "name": text, + "parentId": header.items[header.items.length + - 1].uuid + } + Request.post( + "/knowledge", + JSON.stringify(param)) } } @@ -77,7 +156,7 @@ Item { } FluButton { Layout.alignment: Qt.AlignRight - text: "ϴ" + text: "上传" onClicked: function () { console.log("click") fileDialog.open() @@ -135,7 +214,7 @@ Item { header.items = header.items.slice( 0, header.count() - 1) } - fileListItemHeaderItem.update() + topColumnLayout.update() } } FluBreadcrumbBar { @@ -150,81 +229,9 @@ Item { } } onItemsChanged: { - fileListItemHeaderItem.update() + topColumnLayout.update() } } - - function getType(suffix) { - if (suffix === "ppt" || suffix === "pptx") - return "PPT" - else if (suffix === "doc" || suffix === "docx") - return "WORD" - else if (suffix === "pdf") - return "PDF" - else if (suffix === "txt") - return "TXT" - else if (suffix === "xls" || suffix === "xlsx") - return "EXCEL" - else if (suffix === "zip" || suffix === "rar") - return "ZIP" - else if (suffix === "png" || suffix === "jpg" - || suffix === "jpeg" || suffix === "gif") - return "IMAGE" - else if (suffix === "mp3" || suffix === "wav") - return "AUDIO" - else if (suffix === "mp4" || suffix === "avi" - || suffix === "rmvb" || suffix === "rm" - || suffix === "wmv" || suffix === "mkv") - return "VIDEO" - else - return "OTHER" - } - - function update() { - var uuid = header.items.length - === 0 ? "null" : header.items[header.items.length - 1].uuid - Request.get("/knowledge/" + uuid, function (response) { - var data = JSON.parse(response) - console.log(response) - console.log(data.knowledgeFileAttribute) - fileListModel.clear() - var files = data.children - for (var i = 0; i < files.length; i++) { - var file = files[i] - console.log(file.name) - var modelItem = { - "title": file.name, - "uuid": file.id, - "date"// cut time after 'T' - : file.createTime.substring(0, 10) - } - if (file.knowledgeFileAttribute === null) { - modelItem.type = "folder" - modelItem.isDir = true - modelItem.size = 0 - } else { - modelItem.isDir = false - modelItem.type = getType( - file.knowledgeFileAttribute.suffix) - modelItem.size = file.knowledgeFileAttribute.size - modelItem.brief = file.knowledgeFileAttribute.brief - modelItem.pageView = file.knowledgeFileAttribute.pageView - modelItem.stars = 0 - // merge file.knowledgeFileAttribute.tags array to a string - var tagString = "" - for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { - if (j != 0) - tagString = tagString + "," - tagString = tagString + file.knowledgeFileAttribute.tags[j].name - } - modelItem.tags = tagString - } - fileListModel.append(modelItem) - } - console.log(fileListModel.count) - listView.currentIndex = -1 - }) - } } } } @@ -238,6 +245,7 @@ Item { FileListItem { id: fileListItem uuid: model.uuid + fuuid: model.fuuid width: parent.width height: parent.height title: model.title @@ -256,6 +264,9 @@ Item { emit: search(tag) console.log(tag) } + onRefresh: { + listView.headerItem.update() + } } function doubleClicked() { listView.currentIndex = index @@ -275,6 +286,7 @@ Item { isDir: true brief: "This is a test file" type: "FOLDER" + fuuid: "1" } ListElement { uuid: "2" @@ -286,6 +298,7 @@ Item { date: "2020-09-09" pageView: 100 stars: 10 + fuuid: "1" } ListElement { uuid: "3" @@ -297,6 +310,7 @@ Item { pageView: 100 size: 10200000022 stars: 10 + fuuid: "1" } } } diff --git a/AicsKnowledgeBase/qml/component/FileListItem.qml b/AicsKnowledgeBase/qml/component/FileListItem.qml index 2eaab06..c7383b3 100644 --- a/AicsKnowledgeBase/qml/component/FileListItem.qml +++ b/AicsKnowledgeBase/qml/component/FileListItem.qml @@ -5,6 +5,7 @@ import QtQuick.Layouts FluArea { id: fileItem property string uuid + property string fuuid: null property string title property string brief property string date @@ -18,6 +19,46 @@ FluArea { property int stars property var colorList: ["blue", "green", "orange", "red", "yellow", "purple", "pink", "brown", "teal", "cyan", "gray", "darkgray"] signal tagClicked(string tag) + signal refresh + FluMenu { + id: menu + FluMenuItem { + text: "重命名" + onClicked: { + dialog.open() + } + InputDialog { + id: dialog + title: "重命名" + buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton + negativeText: "取消" + positiveText: "确定" + message: fileItem.title + onPositiveClicked: text => { + var param = { + "name": text, + "parentId": fuuid + } + Request.post("/knowledge", + JSON.stringify(param)) + refresh() + } + } + } + FluMenuItem { + text: "移动至" + onClicked: { + refresh() + } + } + FluMenuItem { + text: "删除" + onClicked: { + Request.delete("/knowledge/" + uuid) + refresh() + } + } + } ColumnLayout { id: row @@ -30,9 +71,15 @@ FluArea { anchors.fill: parent MouseArea { anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton onDoubleClicked: { fileItem.parent.doubleClicked() } + onClicked: { + if (mouse.button === Qt.RightButton) { + menu.popup() + } + } } RowLayout { id: titleRow From c1e2eba4d19e77597b67777532c546bc53951cc7 Mon Sep 17 00:00:00 2001 From: wuyize Date: Thu, 6 Jul 2023 16:18:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/page/ContentPage.qml | 52 ++++++++++--------- AicsKnowledgeBase/src/FileTransferManager.cpp | 6 +-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index be13e9b..6025060 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -81,42 +81,43 @@ FluArea { property string brief: "这是一个简介" function getType(suffix) { - if(suffix === "md") + if (suffix === "md") return "MD" - else if(suffix === "mp4" || suffix === "avi" - || suffix === "rmvb" || suffix === "rm" - || suffix === "wmv" || suffix === "mkv") + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") return "VIDEO" - else return "OTHER" + else + return "OTHER" } function loadFile(knowledgeFileId) { content_area.knowledgeFileId = knowledgeFileId console.log(knowledgeFileId) - Request.get("knowledge/" + knowledgeFileId, function (response, data) { - content_page.publishTime = data.createTime - content_page.title = data.name - content_page.fileId = data.knowledgeFileAttribute.id + Request.get("knowledge/" + knowledgeFileId, + function (response, data) { + content_page.publishTime = data.createTime + 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 = "" - for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { - if (j != 0) - tagString = tagString + "," - tagString = tagString + data.knowledgeFileAttribute.tags[j].name - } - content_page.tags = tagString.split(",") + var tagString = "" + for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + data.knowledgeFileAttribute.tags[j].name + } + content_page.tags = tagString.split(",") - content_page.brief = data.knowledgeFileAttribute.brief - content_page.browsCount = data.knowledgeFileAttribute.pageView + content_page.brief = data.knowledgeFileAttribute.brief + content_page.browsCount = data.knowledgeFileAttribute.pageView - var starers = data.knowledgeFileAttribute.starers - for(var i=0; i Date: Thu, 6 Jul 2023 17:15:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=AE=80=E4=BB=8B=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 43 +------------------ .../qml/component/UploadButton.qml | 22 ++++++---- AicsKnowledgeBase/src/FileTransferManager.cpp | 8 +--- 3 files changed, 17 insertions(+), 56 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index 78cfd61..1bcb5b7 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -154,47 +154,8 @@ Item { } } } - FluButton { - Layout.alignment: Qt.AlignRight - text: "上传" - onClicked: function () { - console.log("click") - fileDialog.open() - } - FileDialog { - id: fileDialog - onAccepted: function () { - let name = FileTransferManager.getFileName( - selectedFile) - const size = FileTransferManager.getFileSize( - selectedFile) - const md5 = FileTransferManager.getFileMd5( - selectedFile) - if (size <= 0 || md5 === '') - return - var body = { - "name": name, - "brief": "brief", - "size": size, - "md5": md5, - "tags": [], - "parentId": header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null - } - console.log("begin") - console.log(JSON.stringify(body)) - Request.post("knowledge/file", - JSON.stringify(body), - function (res, data) { - console.log(res) - console.log(data) - FileTransferManager.upload( - selectedFile, data.id, - data.ticket, name) - }, function (res, data) { - console.log(res) - }) - } - } + UploadButton { + header: header } } RowLayout { diff --git a/AicsKnowledgeBase/qml/component/UploadButton.qml b/AicsKnowledgeBase/qml/component/UploadButton.qml index 200c825..3b3da65 100644 --- a/AicsKnowledgeBase/qml/component/UploadButton.qml +++ b/AicsKnowledgeBase/qml/component/UploadButton.qml @@ -34,12 +34,12 @@ FluButton { implicitWidth: Window.window == null ? 400 : Math.min( Window.window.width, 400) - implicitHeight: text_title.height + text_message.height + layout_actions.height + implicitHeight: text_title.height + content.height + layout_actions.height color: 'transparent' radius: 5 FluText { id: text_title - font: FluTextStyle.TitleLarge + font: FluTextStyle.Title text: "上传知识文件" topPadding: 20 leftPadding: 20 @@ -51,11 +51,9 @@ FluButton { right: parent.right } } - FluText { - id: text_message - font: FluTextStyle.Body - wrapMode: Text.WrapAnywhere - text: "content" + + Row { + id: content topPadding: 14 leftPadding: 20 rightPadding: 20 @@ -65,7 +63,13 @@ FluButton { left: parent.left right: parent.right } + FluMultilineTextBox { + id: brief_textbox + width: parent.width - parent.leftPadding - parent.rightPadding + placeholderText: "请输入简介" + } } + Rectangle { id: layout_actions height: 68 @@ -76,7 +80,7 @@ FluButton { 243 / 255, 243 / 255, 243 / 255, blurBackground ? blurOpacity - 0.4 : 1) anchors { - top: text_message.bottom + top: content.bottom left: parent.left right: parent.right } @@ -113,7 +117,7 @@ FluButton { return var body = { "name": name, - "brief": "brief", + "brief": brief_textbox.text, "size": size, "md5": md5, "tags": [], diff --git a/AicsKnowledgeBase/src/FileTransferManager.cpp b/AicsKnowledgeBase/src/FileTransferManager.cpp index e7f8308..9e1ed6d 100644 --- a/AicsKnowledgeBase/src/FileTransferManager.cpp +++ b/AicsKnowledgeBase/src/FileTransferManager.cpp @@ -304,7 +304,7 @@ bool httpDownload(const std::string &url, const std::string &savePath, const Fil if (!obj.curlHandle) return false; obj.totalSize = item.totalSize;//原始文件大小 - obj.file = std::ofstream(savePath, std::ios::binary); + obj.file = std::ofstream(savePath, std::ios::binary | std::ios::app); if (!obj.file.is_open()) { qDebug() << "Open File Failed"; curl_easy_cleanup(obj.curlHandle); @@ -349,7 +349,7 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam auto size = resJson["size"].toInteger(); std::string savePath = "D:\\Downloads\\" + fileName.toLocal8Bit().toStdString(); qDebug() << savePath.c_str(); - QFileInfo fileInfo(savePath.c_str()); + QFileInfo fileInfo(QString::fromLocal8Bit(savePath.c_str())); int64_t completedSize = fileInfo.exists() ? fileInfo.size() : 0; FileItem item{true, fileId, fileName, completedSize, size}; if (!resume) @@ -359,10 +359,6 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), completedSize, size); auto res = httpDownload(fileUrl, savePath, item); - /*auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), 0, size / 2); - auto res = httpDownload(fileUrl, savePath, item); - fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), size / 2, size); - res = httpDownload(fileUrl, savePath, item);*/ qDebug() << "End Get" << res; });