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; });