2023-06-21 21:33:52 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Window
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Controls.Basic
|
|
|
|
import FluentUI
|
2023-07-07 04:22:36 +08:00
|
|
|
import "qrc:///AicsKnowledgeBase/qml/component"
|
|
|
|
import "qrc:///AicsKnowledgeBase/qml/global"
|
2023-06-21 21:33:52 +08:00
|
|
|
|
2023-07-01 08:56:14 +08:00
|
|
|
FluArea {
|
2023-06-21 21:33:52 +08:00
|
|
|
property string url: ''
|
2023-07-02 15:58:02 +08:00
|
|
|
backgroundColor: "#f9f9f9"
|
2023-06-21 21:33:52 +08:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
2023-07-01 08:56:14 +08:00
|
|
|
FluText {
|
2023-07-07 04:22:36 +08:00
|
|
|
id: title
|
2023-06-21 21:33:52 +08:00
|
|
|
Layout.topMargin: 20
|
2023-07-07 04:22:36 +08:00
|
|
|
text: "Favourite"
|
|
|
|
}
|
|
|
|
FileList {
|
|
|
|
anchors.top: title.bottom
|
|
|
|
disableHeader: true
|
|
|
|
width: parent.width
|
|
|
|
dataModel: listModel
|
|
|
|
}
|
|
|
|
ListModel {
|
|
|
|
id: listModel
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
Request.get("/user", response => {
|
|
|
|
var files = JSON.parse(response).starredKnowledge
|
|
|
|
listModel.clear()
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
var file = files[i]
|
|
|
|
console.log(file.name)
|
|
|
|
var modelItem = {
|
|
|
|
"title": file.knowledge.name,
|
|
|
|
"uuid": file.knowledge.id,
|
|
|
|
"date"// cut time after 'T'
|
|
|
|
: file.knowledge.createTime.substring(0, 10),
|
|
|
|
"fuuid": "0"
|
|
|
|
}
|
|
|
|
modelItem.isDir = false
|
|
|
|
modelItem.type = getType(file.suffix)
|
|
|
|
modelItem.size = file.size
|
|
|
|
modelItem.brief = file.brief
|
|
|
|
modelItem.pageView = file.pageView
|
|
|
|
modelItem.stars = 0
|
|
|
|
var tagString = ""
|
|
|
|
for (var j = 0; j < file.tags.length; j++) {
|
|
|
|
if (j != 0)
|
|
|
|
tagString = tagString + ","
|
|
|
|
tagString = tagString + file.tags[j].name
|
|
|
|
}
|
|
|
|
modelItem.tags = tagString
|
|
|
|
listModel.append(modelItem)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
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"
|
2023-06-21 21:33:52 +08:00
|
|
|
}
|
|
|
|
}
|