修改上传按钮

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 2.15
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import QtQuick.Dialogs
import "qrc:///AicsKnowledgeBase/qml/global" import "qrc:///AicsKnowledgeBase/qml/global"
import SignalFileOperation 1.0 import SignalFileOperation 1.0
@ -34,39 +35,81 @@ Item {
Component { Component {
id: fileListItemHeader id: fileListItemHeader
Item {
RowLayout {
id: fileListItemHeaderItem id: fileListItemHeaderItem
width: ListView.view.width width: ListView.view.width
height: 48 height: 48
RowLayout {
FluBreadcrumbBar { // back to folder button
id: header FluIconButton {
width: parent.width Layout.alignment: Qt.AlignVCenter
height: parent.height id: backButton
separator: ">" width: 24
items: [] height: 24
onClickItem: function (model) { iconSource: FluentIcons.ForwardCall
if (model.index + 1 !== count()) { onClicked: {
items = items.slice(0, model.index + 1) if (header.count() > 0) {
} header.items = header.items.slice(0, header.count() - 1)
} }
onItemsChanged: { fileListItemHeaderItem.update()
fileListItemHeaderItem.update() }
}
FluBreadcrumbBar {
id: header
//width: parent.width
height: parent.height
separator: ">"
items: []
onClickItem: function (model) {
if (model.index + 1 !== count()) {
items = items.slice(0, model.index + 1)
} }
} }
// back to folder button onItemsChanged: {
FluIconButton { fileListItemHeaderItem.update()
Layout.alignment: Qt.AlignVCenter }
id: backButton }
width: 24
height: 24 FluButton {
iconSource: FluentIcons.ChromeBack Layout.alignment: Qt.AlignRight
onClicked: { text: "上传"
if (header.count() > 0) { onClicked: function () {
header.items = header.items.slice( console.log("click")
0, header.count() - 1) 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
} }
fileListItemHeaderItem.update() 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: "" 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 { FileList {
autoRequest: true autoRequest: true
width: parent.width
} }
} }