From 16c9e6c6329a6bd3344e46e336fe734ae1db0e39 Mon Sep 17 00:00:00 2001 From: shmily744 <1527550984@qq.com> Date: Wed, 5 Jul 2023 15:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9search=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84tag=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/Tag.qml | 17 ++- AicsKnowledgeBase/qml/page/SearchPage.qml | 172 +++++++++++++--------- 2 files changed, 115 insertions(+), 74 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/Tag.qml b/AicsKnowledgeBase/qml/component/Tag.qml index f763f40..47cb448 100644 --- a/AicsKnowledgeBase/qml/component/Tag.qml +++ b/AicsKnowledgeBase/qml/component/Tag.qml @@ -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 { diff --git a/AicsKnowledgeBase/qml/page/SearchPage.qml b/AicsKnowledgeBase/qml/page/SearchPage.qml index d5d9761..56cad27 100644 --- a/AicsKnowledgeBase/qml/page/SearchPage.qml +++ b/AicsKnowledgeBase/qml/page/SearchPage.qml @@ -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,112 +19,143 @@ FluArea { // Layout.topMargin: 20 // text: "Search" // } - - /* 按标题,内容搜索 - */ - ColumnLayout { + */ + 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 - } + 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 + // } + // } + // ] + // } + + FluTextBox{ + 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() + } + + ) } - ] + } } - FluTextBox { - //placeholderText:"" - Layout.fillWidth: true - } - FluIconButton { - Layout.alignment: Qt.AlignRight - iconSource: FluentIcons.Search - } + } + FluCheckBox{ + id:searchTitleAndContent + text:"同时搜索简介和内容" } //按文件类型 - RowLayout { - id: selectFormat - width: parent.width - FluText { + RowLayout{ + id:selectFormat + width:parent.width + FluText{ Layout.alignment: Qt.AlignLeft - text: "类型: " + text:"类型: " } - FluCheckBox { - id: selectAllFormat - text: "all" - Component.onCompleted: { + FluCheckBox{ + id:selectAllFormat + text:"all" + Component.onCompleted:{ clicked() } - onClicked: { - selectVideo.checked = true - selectDoc.checked = true - selectAudio.checked = true + onClicked:{ + selectVideo.checked=true + selectDoc.checked=true + selectAudio.checked=true } } - FluCheckBox { - id: selectVideo - text: "Video" - onClicked: { + FluCheckBox{ + id:selectVideo + text:"Video" + onClicked:{ selectFormat.setAllStatus() } } - FluCheckBox { - id: selectDoc - text: "Doc" - onClicked: { + FluCheckBox{ + id:selectDoc + text:"Doc" + onClicked:{ selectFormat.setAllStatus() } } - FluCheckBox { - id: selectAudio - text: "Audio" - onClicked: { + FluCheckBox{ + id:selectAudio + text:"Audio" + onClicked:{ selectFormat.setAllStatus() } } function setAllStatus() { - selectAllFormat.checked = selectVideo.checked - && selectDoc.checked && selectAudio.checked + selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked } } - RowLayout { - width: parent.width + RowLayout{ + id:inputTags + width:parent.width height: 32 - FluText { - id: tag + FluText{ Layout.alignment: Qt.AlignLeft - text: "标签: " + text:"标签: " } - Tag { + 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 {