添加输入文件简介对话框
parent
c1e2eba4d1
commit
1c6aba5baf
|
@ -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 {
|
||||
|
|
|
@ -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": [],
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue