main
karlis 2023-07-07 00:24:17 +08:00
parent eb09b43ee8
commit d27ed8ede0
6 changed files with 329 additions and 100 deletions

View File

@ -37,12 +37,15 @@ FluArea {
message: fileItem.title message: fileItem.title
onPositiveClicked: text => { onPositiveClicked: text => {
var param = { var param = {
"name": text, "parentId": fileItem.fuuid,
"parentId": fuuid "name": text
} }
Request.post("/knowledge", console.log(JSON.stringify(param))
JSON.stringify(param)) Request.put(
"/knowledge/" + fileItem.uuid,
JSON.stringify(param), () => {
refresh() refresh()
})
} }
} }
} }
@ -63,6 +66,7 @@ FluArea {
"parentId": uuid, "parentId": uuid,
"name": fileItem.title "name": fileItem.title
} }
console.log(JSON.stringify(param))
Request.put( Request.put(
"/knowledge/" + fileItem.uuid, "/knowledge/" + fileItem.uuid,
JSON.stringify(param), () => { JSON.stringify(param), () => {
@ -114,6 +118,7 @@ FluArea {
font.bold: true font.bold: true
font.pointSize: 12 font.pointSize: 12
text: fileItem.title text: fileItem.title
textFormat: Text.RichText
} }
} }

View File

@ -4,18 +4,91 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import "qrc:///AicsKnowledgeBase/qml/component"
import "qrc:///AicsKnowledgeBase/qml/global"
FluArea { FluArea {
property string url: '' property string url: ''
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
paddings: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluText { FluText {
id: title
Layout.topMargin: 20 Layout.topMargin: 20
text: "Audio" text: "Audio"
} }
FileList {
anchors.top: title.bottom
disableHeader: true
width: parent.width
dataModel: listModel
}
ListModel {
id: listModel
}
Component.onCompleted: {
Request.get("/knowledge?type=AUDIO", response => {
var files = JSON.parse(response)
listModel.clear()
for (var i = 0; i < files.length; i++) {
var file = files[i]
console.log(file.name)
var modelItem = {
"title": file.name,
"uuid": file.id,
"date"// cut time after 'T'
: file.createTime.substring(0, 10),
"fuuid": "0"
}
if (file.knowledgeFileAttribute === null) {
modelItem.type = "folder"
modelItem.isDir = true
modelItem.size = 0
} else {
modelItem.isDir = false
modelItem.type = getType(
file.knowledgeFileAttribute.suffix)
modelItem.size = file.knowledgeFileAttribute.size
modelItem.brief = file.knowledgeFileAttribute.brief
modelItem.pageView = file.knowledgeFileAttribute.pageView
modelItem.stars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.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"
}
} }

View File

@ -4,6 +4,8 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import "qrc:///AicsKnowledgeBase/qml/component"
import "qrc:///AicsKnowledgeBase/qml/global"
FluArea { FluArea {
property string url: '' property string url: ''
@ -14,7 +16,79 @@ FluArea {
Layout.topMargin: 20 Layout.topMargin: 20
FluText { FluText {
id: title
Layout.topMargin: 20 Layout.topMargin: 20
text: "Document" text: "Document"
} }
FileList {
anchors.top: title.bottom
disableHeader: true
width: parent.width
dataModel: listModel
}
ListModel {
id: listModel
}
Component.onCompleted: {
Request.get("/knowledge?type=DOCUMENT", response => {
var files = JSON.parse(response)
listModel.clear()
for (var i = 0; i < files.length; i++) {
var file = files[i]
console.log(file.name)
var modelItem = {
"title": file.name,
"uuid": file.id,
"date"// cut time after 'T'
: file.createTime.substring(0, 10),
"fuuid": "0"
}
if (file.knowledgeFileAttribute === null) {
modelItem.type = "folder"
modelItem.isDir = true
modelItem.size = 0
} else {
modelItem.isDir = false
modelItem.type = getType(
file.knowledgeFileAttribute.suffix)
modelItem.size = file.knowledgeFileAttribute.size
modelItem.brief = file.knowledgeFileAttribute.brief
modelItem.pageView = file.knowledgeFileAttribute.pageView
modelItem.stars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.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"
}
} }

View File

@ -46,7 +46,6 @@ FluArea {
property list<string> tags: ["tag 1", "tag 2", "tag 3"] property list<string> tags: ["tag 1", "tag 2", "tag 3"]
property string publishTime: "2020-01-01" property string publishTime: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
property var fromFile
function getType(suffix) { function getType(suffix) {
if (suffix === "md") if (suffix === "md")
@ -63,29 +62,7 @@ FluArea {
} }
Component.onCompleted: { Component.onCompleted: {
Request.get("knowledge/", function (response, data) {
fromFile = {
"uuid": data.id,
"fuuid": data.knowledgeFileAttribute.id,
"title": data.name,
"date": data.createTime,
"brief": data.knowledgeFileAttribute.brief,
"suffix": data.knowledgeFileAttribute.suffix,
"type": getType(data.knowledgeFileAttribute.suffix),
"pageView": data.knowledgeFileAttribute.pageView,
"size": data.knowledgeFileAttribute.size
}
fromFile.stars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
}
fromFile.tags = tagString
})
} }
FluIconButton { FluIconButton {
@ -222,19 +199,5 @@ FluArea {
width: parent.width width: parent.width
implicitHeight: 400 implicitHeight: 400
} }
// FistListItem {
// id: fileListItem
// uuid: fromFile.uuid
// fuuid: fromFile.fuuid
// title: fromFile.title
// date: fromFile.date
// brief: fromFile.brief
// type: fromFile.type
// pageView: fromFile.pageView
// size: fromFile.size
// stars: fromFile.stars
// tags: fromFile.tags === null || fromFile.tags === undefined
// || fromFile.tags === "" ? [] : fromFile.tags.split(",")
// }
} }
} }

View File

@ -8,6 +8,7 @@ import "qrc:///AicsKnowledgeBase/qml/global"
import "qrc:///AicsKnowledgeBase/qml/component" import "qrc:///AicsKnowledgeBase/qml/component"
FluArea { FluArea {
id: searchPage
property string url: '' property string url: ''
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
Layout.fillHeight: true Layout.fillHeight: true
@ -19,14 +20,17 @@ FluArea {
// Layout.topMargin: 20 // Layout.topMargin: 20
// text: "Search" // text: "Search"
// } // }
/* /*
*/ */
ColumnLayout{ ColumnLayout {
width: parent.width width: parent.width
RowLayout{ RowLayout {
width:parent.width width: parent.width
// FluDropDownButton{ // FluDropDownButton{
// id:select_model // id:select_model
// Layout.alignment: Qt.AlignLeft // Layout.alignment: Qt.AlignLeft
@ -52,105 +56,100 @@ FluArea {
// } // }
// ] // ]
// } // }
FluTextBox {
FluTextBox{ placeholderText: "对标题进行搜索……"
placeholderText:"对标题进行搜索……"
Layout.fillWidth: true Layout.fillWidth: true
} }
FluIconButton{ FluIconButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
iconSource:FluentIcons.Search iconSource: FluentIcons.Search
onClicked:{ onClicked: {
var allTags = inputTags.getAllTags(tags.tagList) var allTags = inputTags.getAllTags(tags.tagList)
var allTagId =[] var allTagId = []
console.log(allTags) console.log(allTags)
for (var i = 0; i < allTags.length; i++) { for (var i = 0; i < allTags.length; i++) {
var url = "?name=" var url = "?name="
url = url + allTags[i] url = url + allTags[i]
console.log(url) console.log(url)
Request.get(url, Request.get(url, function (result, data) {
function(result, data){
allTagId.push() allTagId.push()
} })
)
} }
} }
} }
} }
FluCheckBox{ FluCheckBox {
id:searchTitleAndContent id: searchTitleAndContent
text:"同时搜索简介和内容" text: "同时搜索简介和内容"
} }
// //
RowLayout{ RowLayout {
id:selectFormat id: selectFormat
width:parent.width width: parent.width
FluText{ FluText {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text:"类型: " text: "类型: "
} }
FluCheckBox{ FluCheckBox {
id:selectAllFormat id: selectAllFormat
text:"all" text: "all"
Component.onCompleted:{ Component.onCompleted: {
clicked() clicked()
} }
onClicked:{ onClicked: {
selectVideo.checked=true selectVideo.checked = true
selectDoc.checked=true selectDoc.checked = true
selectAudio.checked=true selectAudio.checked = true
} }
} }
FluCheckBox{ FluCheckBox {
id:selectVideo id: selectVideo
text:"Video" text: "Video"
onClicked:{ onClicked: {
selectFormat.setAllStatus() selectFormat.setAllStatus()
} }
} }
FluCheckBox{ FluCheckBox {
id:selectDoc id: selectDoc
text:"Doc" text: "Doc"
onClicked:{ onClicked: {
selectFormat.setAllStatus() selectFormat.setAllStatus()
} }
} }
FluCheckBox{ FluCheckBox {
id:selectAudio id: selectAudio
text:"Audio" text: "Audio"
onClicked:{ onClicked: {
selectFormat.setAllStatus() selectFormat.setAllStatus()
} }
} }
function setAllStatus() { function setAllStatus() {
selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked selectAllFormat.checked = selectVideo.checked
&& selectDoc.checked && selectAudio.checked
} }
} }
RowLayout{ RowLayout {
id:inputTags id: inputTags
width:parent.width width: parent.width
height: 32 height: 32
FluText{ FluText {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text:"标签: " text: "标签: "
} }
Tag{ Tag {
id:tags id: tags
width: 290 width: 290
} }
function getAllTags(tagList){ function getAllTags(tagList) {
var allTags=[]; var allTags = []
for (var i = 0; i < tagList.count; i++) { for (var i = 0; i < tagList.count; i++) {
var item = tagList.get(i); var item = tagList.get(i)
allTags.push(item.tag) allTags.push(item.tag)
} }
return allTags return allTags
@ -200,4 +199,45 @@ FluArea {
} }
} }
} }
function getKnowledgeDetail(uuid, title, brief, tags) {
var raw = Request.getAwait("/knowledget/" + uuid)
var data = JSON.parse(raw)
var item = {
"uuid": uuid,
"title": title,
"brief": brief,
"isDir": false,
"date": data.createTime,
"fuuid": data.parent.id,
"pageView": data.knowledgeFileAttribute.pageView,
"stars": data.knowledgeFileAttribute.stars,
"size": data.knowledgeFileAttribute.size,
"type": getType(data.knowledgeFileAttribute.suffix),
"tags": tags
}
}
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"
}
} }

View File

@ -4,6 +4,8 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import "qrc:///AicsKnowledgeBase/qml/component"
import "qrc:///AicsKnowledgeBase/qml/global"
FluArea { FluArea {
property string url: '' property string url: ''
@ -14,7 +16,79 @@ FluArea {
Layout.topMargin: 20 Layout.topMargin: 20
FluText { FluText {
id: title
Layout.topMargin: 20 Layout.topMargin: 20
text: "Video" text: "Video"
} }
FileList {
anchors.top: title.bottom
disableHeader: true
width: parent.width
dataModel: listModel
}
ListModel {
id: listModel
}
Component.onCompleted: {
Request.get("/knowledge?type=VIDEO", response => {
var files = JSON.parse(response)
listModel.clear()
for (var i = 0; i < files.length; i++) {
var file = files[i]
console.log(file.name)
var modelItem = {
"title": file.name,
"uuid": file.id,
"date"// cut time after 'T'
: file.createTime.substring(0, 10),
"fuuid": "0"
}
if (file.knowledgeFileAttribute === null) {
modelItem.type = "folder"
modelItem.isDir = true
modelItem.size = 0
} else {
modelItem.isDir = false
modelItem.type = getType(
file.knowledgeFileAttribute.suffix)
modelItem.size = file.knowledgeFileAttribute.size
modelItem.brief = file.knowledgeFileAttribute.brief
modelItem.pageView = file.knowledgeFileAttribute.pageView
modelItem.stars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.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"
}
} }