FileList修改样式,上传

main
karlis 2023-07-05 22:31:14 +08:00
parent 0014cc018a
commit 5c1b23421c
4 changed files with 125 additions and 97 deletions

View File

@ -35,7 +35,53 @@ Item {
Component {
id: fileListItemHeader
ColumnLayout {
function add(folderName, uuid) {
console.log(header.items)
header.items = header.items.concat([{
"title": folderName,
"uuid": uuid
}])
}
FluButton {
Layout.alignment: Qt.AlignRight
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": 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)
}, function (res, data) {
console.log(res)
})
}
}
}
RowLayout {
id: fileListItemHeaderItem
width: ListView.view.width
@ -50,14 +96,15 @@ Item {
iconSource: FluentIcons.ForwardCall
onClicked: {
if (header.count() > 0) {
header.items = header.items.slice(0, header.count() - 1)
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: []
@ -71,68 +118,36 @@ Item {
}
}
FluButton {
Layout.alignment: Qt.AlignRight
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)
})
}
}
}
function add(folderName, uuid) {
console.log(header.items)
header.items = header.items.concat([{
"title": folderName,
"uuid": uuid
}])
}
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(uuid, function (response) {
Request.get("/knowledge/" + uuid, function (response) {
var data = JSON.parse(response)
console.log(data.knowledgeFileAttribute)
fileListModel.clear()
@ -143,7 +158,8 @@ Item {
var modelItem = {
"title": file.name,
"uuid": file.id,
"date": file.createTime
"date"// cut time after 'T'
: file.createTime.substring(0, 10)
}
if (file.knowledgeFileAttribute === null) {
modelItem.type = "folder"
@ -174,6 +190,7 @@ Item {
}
}
}
}
Component {
id: fileListItemDelegate
Rectangle {
@ -206,6 +223,7 @@ Item {
function doubleClicked() {
listView.currentIndex = index
if (model.isDir) {
console.log(listView.headerItem)
listView.headerItem.add(model.title, model.uuid)
} else {
emit: SignalFileOperation.open(model.uuid)

View File

@ -39,11 +39,13 @@ FluArea {
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 18
Layout.preferredWidth: 18
Layout.preferredHeight: 32
Layout.preferredWidth: 32
}
FluText {
id: title
font.bold: true
font.pointSize: 15
text: fileItem.title
}
}
@ -52,17 +54,23 @@ FluArea {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
@ -70,10 +78,12 @@ FluArea {
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB