修改search界面,完善tag组件

main
shmily744 2023-07-05 15:39:29 +08:00
parent 7be44d40b1
commit 16c9e6c632
2 changed files with 115 additions and 74 deletions

View File

@ -15,7 +15,7 @@ Rectangle {
clip: true
border.color: textInput.activeFocus ? "#268CDC":"#979592" //gray100
ListModel { id: tagListModel }
property ListModel tagList: tagListModel
Row {
@ -52,6 +52,9 @@ Rectangle {
id:textInput
placeholderText: qsTr("按回车键Enter创建标签")
onFocusChanged: {
text =""
}
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 15
@ -61,9 +64,14 @@ Rectangle {
}
Keys.onReturnPressed: {
var presetsTags = ["前端","后端","数据库"]
if (text.length === 0)
return
if(presetsTags.indexOf(text) === -1){
text = ""
return
}
tagListModel.append({"tag": text})
//console.log(tagListModel.get(0))
@ -91,7 +99,8 @@ Rectangle {
width: content.width
height: 25
radius: 5
border.color: "#77c7ff"
color: "#00aeec"
border.color: "#00aeec"
MouseArea {
id: mouseArea
@ -113,7 +122,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: rootTagItem.height * 0.5
text: "Hello"
color: rootTagItem.border.color
color: "white"
}
Item { visible: mouseArea.hovered; width: 5; height: 1 }
@ -143,7 +152,7 @@ Rectangle {
Text {
anchors.centerIn: parent
text: "×"
color: closeMouseArea.hovered ? "white" : rootTagItem.border.color
color: "white"
}
MouseArea {

View File

@ -4,6 +4,7 @@ import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global"
import "qrc:///AicsKnowledgeBase/qml/component"
FluArea {
@ -18,49 +19,71 @@ FluArea {
// Layout.topMargin: 20
// text: "Search"
// }
/*
*/
ColumnLayout{
width: parent.width
RowLayout{
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
}
}
]
}
// 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{
//placeholderText:""
placeholderText:"对标题进行搜索……"
Layout.fillWidth: true
}
FluIconButton{
Layout.alignment: Qt.AlignRight
iconSource:FluentIcons.Search
onClicked:{
var allTags = inputTags.getAllTags(tags.tagList)
var allTagId =[]
console.log(allTags)
for (var i = 0; i < allTags.length; i++) {
var url = "?name="
url = url + allTags[i]
console.log(url)
Request.get(url,
function(result, data){
allTagId.push()
}
)
}
}
}
}
FluCheckBox{
id:searchTitleAndContent
text:"同时搜索简介和内容"
}
//
@ -107,23 +130,32 @@ FluArea {
}
function setAllStatus() {
selectAllFormat.checked = selectVideo.checked
&& selectDoc.checked && selectAudio.checked
selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked
}
}
RowLayout{
id:inputTags
width:parent.width
height: 32
FluText{
id: tag
Layout.alignment: Qt.AlignLeft
text:"标签: "
}
Tag{
id:tags
width: 290
}
function getAllTags(tagList){
var allTags=[];
for (var i = 0; i < tagList.count; i++) {
var item = tagList.get(i);
allTags.push(item.tag)
}
return allTags
//console.log(allTags)
}
}
FluArea {