Compare commits

..

No commits in common. "2ceb74b86297f36c61f2cdc951fda9acf25d1fe7" and "ecff8e709ca5babace419a45c5a07db0b47cadb1" have entirely different histories.

4 changed files with 127 additions and 147 deletions

View File

@ -211,9 +211,7 @@ Item {
Rectangle { Rectangle {
id: fileListItemRect id: fileListItemRect
width: ListView.view.width width: ListView.view.width
//set the height to fit model.brief height: model.isDir ? 50 : 120
height: model.isDir ? 50 : Math.max(120,
model.brief.length / 3 + 80)
//color: !ListView.isCurrentItem ? "white" : "red" //color: !ListView.isCurrentItem ? "white" : "red"
FileListItem { FileListItem {
id: fileListItem id: fileListItem

View File

@ -124,11 +124,10 @@ FluArea {
visible: !fileItem.isDir visible: !fileItem.isDir
text: fileItem.brief text: fileItem.brief
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.WordWrap wrapMode: Text.WrapAnywhere
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 4 maximumLineCount: 2
textFormat: Text.RichText textFormat: Text.RichText
fontSizeMode: Text.Fit
} }
RowLayout { RowLayout {
id: infoRow id: infoRow
@ -159,6 +158,13 @@ FluArea {
} }
} }
} }
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
RowLayout { RowLayout {
visible: !fileItem.isDir visible: !fileItem.isDir
Repeater { Repeater {

View File

@ -6,7 +6,7 @@ QtObject {
id: request id: request
property string baseUrl: "https://api.hammer-hfut.tk:233/aics/main/" property string baseUrl: "https://api.hammer-hfut.tk:233/aics/main/"
property string searchUrl: "https://api.hammer-hfut.tk:233/aics/query/" property string searchUrl: "https://api.hammer-hfut.tk:233/aics/query"
//property string baseUrl: "http://192.168.156.74:8080/" //property string baseUrl: "http://192.168.156.74:8080/"
// GET // GET

View File

@ -10,8 +10,6 @@ import "qrc:///AicsKnowledgeBase/qml/component"
FluArea { FluArea {
id: searchPage id: searchPage
property string url: '' property string url: ''
property var tags: []
property ListModel listModel: ListModel {}
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
@ -32,105 +30,55 @@ FluArea {
width: parent.width width: parent.width
RowLayout { RowLayout {
width: parent.width width: parent.width
// FluDropDownButton{
// id:select_model
// Layout.alignment: Qt.AlignLeft
// text:""
// items:[
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// }
// ]
// }
FluTextBox { FluTextBox {
placeholderText: "对标题进行搜索……" placeholderText: "对标题进行搜索……"
id: search_text
Layout.fillWidth: true Layout.fillWidth: true
} }
FluIconButton { FluIconButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
iconSource: FluentIcons.Search iconSource: FluentIcons.Search
onClicked: { onClicked: {
listModel.clear() var allTags = inputTags.getAllTags(tags.tagList)
var allTags = tags.tagMap var allTagId = []
var selectTagName = [] console.log(allTags)
var selectTagId = []
for (var i = 0; i < tags.tagList.count; i++) { for (var i = 0; i < allTags.length; i++) {
selectTagName.push(tags.tagList.get(i).tag) var url = "?name="
console.log(selectTagName[selectTagName.length - 1]) url = url + allTags[i]
}
for (i = 0; i < selectTagName.length; i++) {
for (var j = 0; j < allTags.length; j++) {
if (selectTagName[i] === allTags[j][1]) {
selectTagId.push(allTags[j][0])
console.log(allTags[j][0])
}
}
}
var params = {
"text": search_text.text,
"applyToBriefAndContent": searchTitleAndContent.checked,
"tags": selectTagId
}
var url = "/search/knowledge?"
// encode params to get url
url += "text=" + params.text
url += "&applyToBriefAndContent=" + params.applyToBriefAndContent
url += "&tags="
for (i = 0; i < params.tags.length; i++) {
url += "&tags=" + params.tags[i]
}
var tagString = ""
// merge all tag to a string split by ','
for (i = 0; i < selectTagName.length; i++) {
if (i !== 0) {
tagString += ","
}
tagString += selectTagName[i]
}
var sName = ""
var sBrief = ""
console.log(url) console.log(url)
Request.getSearch(url, response => { Request.get(url, function (result, data) {
var dataArray = JSON.parse(response) allTagId.push()
for (var i = 0; i < dataArray.length; i++) {
var data = dataArray[i]
if (data.highlightFields.name !== null
&& data.highlightFields.name !== undefined
&& data.highlightFields.name.length > 0) {
for (i = 0; i
< data.highlightFields.name.length; i++) {
if (i !== 0) {
sName += "..."
}
sName += data.highlightFields.name[i]
}
} else {
sName = data.content.name
}
if (data.highlightFields.brief !== null
&& data.highlightFields.brief !== undefined
&& data.highlightFields.brief.length > 0) {
for (i = 0; i
< data.highlightFields.brief.length; i++) {
if (i !== 0) {
sBrief += "..."
}
sBrief += data.highlightFields.brief[i]
}
}
if (data.highlightFields.content !== null
&& data.highlightFields.content !== undefined
&& data.highlightFields.content.length > 0) {
for (i = 0; i
< data.highlightFields.content.length; i++) {
if (i !== 0) {
sBrief += "..."
}
sBrief += data.highlightFields.content[i]
}
}
if (sBrief.length === 0) {
sBrief = data.content.brief
}
getKnowledgeDetail(
data.content.uuid, sName,
sBrief, tagString)
}
}) })
} }
} }
} }
}
FluCheckBox { FluCheckBox {
id: searchTitleAndContent id: searchTitleAndContent
text: "同时搜索简介和内容" text: "同时搜索简介和内容"
@ -217,28 +165,56 @@ FluArea {
FileList { FileList {
disableHeader: true disableHeader: true
dataModel: listModel dataModel: ListModel {
ListElement {
uuid: "0"
title: "File 1"
isDir: true
brief: "This is a test file"
type: "FOLDER"
}
ListElement {
uuid: "2"
title: "File 2"
isDir: false
brief: "This is a test file"
size: 500
type: "WORD"
date: "2020-09-09"
pageView: 100
stars: 10
}
ListElement {
uuid: "3"
title: "File 3"
isDir: false
brief: "This is a test file"
type: "PPT"
date: "2020-09-09"
pageView: 100
size: 10200000022
stars: 10
}
}
} }
} }
} }
function getKnowledgeDetail(uuid, title, brief, tags) { function getKnowledgeDetail(uuid, title, brief, tags) {
Request.get("/knowledge/" + uuid, raw => { var raw = Request.getAwait("/knowledget/" + uuid)
var data = JSON.parse(raw) var data = JSON.parse(raw)
var item = { var item = {
"uuid": uuid, "uuid": uuid,
"title": title, "title": title,
"brief": brief, "brief": brief,
"isDir": false, "isDir": false,
"date": data.createTime.substring(0, 10), "date": data.createTime,
"fuuid": "data.parent.id", "fuuid": data.parent.id,
"pageView": data.knowledgeFileAttribute.pageView, "pageView": data.knowledgeFileAttribute.pageView,
"stars": data.knowledgeFileAttribute.stars, "stars": data.knowledgeFileAttribute.stars,
"size": data.knowledgeFileAttribute.size, "size": data.knowledgeFileAttribute.size,
"type": getType(data.knowledgeFileAttribute.suffix), "type": getType(data.knowledgeFileAttribute.suffix),
"tags": tags "tags": tags
} }
listModel.append(item)
})
} }
function getType(suffix) { function getType(suffix) {
if (suffix === "ppt" || suffix === "pptx") if (suffix === "ppt" || suffix === "pptx")