修改上传按钮

main
wuyize 2023-07-05 21:49:04 +08:00
parent f65f9f3dbb
commit 0014cc018a
2 changed files with 70 additions and 67 deletions

View File

@ -1,6 +1,7 @@
import QtQuick 2.15
import QtQuick.Layouts
import FluentUI
import QtQuick.Dialogs
import "qrc:///AicsKnowledgeBase/qml/global"
import SignalFileOperation 1.0
@ -34,14 +35,29 @@ Item {
Component {
id: fileListItemHeader
Item {
RowLayout {
id: fileListItemHeaderItem
width: ListView.view.width
height: 48
RowLayout {
// back to folder button
FluIconButton {
Layout.alignment: Qt.AlignVCenter
id: backButton
width: 24
height: 24
iconSource: FluentIcons.ForwardCall
onClicked: {
if (header.count() > 0) {
header.items = header.items.slice(0, header.count() - 1)
}
fileListItemHeaderItem.update()
}
}
FluBreadcrumbBar {
id: header
width: parent.width
//width: parent.width
height: parent.height
separator: ">"
items: []
@ -54,19 +70,46 @@ Item {
fileListItemHeaderItem.update()
}
}
// back to folder button
FluIconButton {
Layout.alignment: Qt.AlignVCenter
id: backButton
width: 24
height: 24
iconSource: FluentIcons.ChromeBack
onClicked: {
if (header.count() > 0) {
header.items = header.items.slice(
0, header.count() - 1)
FluButton {
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
fileListItemHeaderItem.update()
FileDialog {
id: fileDialog
onAccepted: function () {
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": "test2",
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": 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)
}, function (res, data) {
console.log(res)
})
}
}
}

View File

@ -23,48 +23,8 @@ FluArea {
text: ""
}
FluButton {
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
const size = FileTransferManager.getFileSize(selectedFile)
const md5 = FileTransferManager.getFileMd5(selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": "test2",
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": 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)
}, function (res, data) {
console.log(res)
})
}
}
}
FileList {
autoRequest: true
width: parent.width
}
}