karlis 2023-07-05 21:00:06 +08:00
commit d7f5670700
6 changed files with 136 additions and 75 deletions

View File

@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global" import "qrc:///AicsKnowledgeBase/qml/global"
import SignalFileOperation 1.0
Item { Item {
anchors.fill: parent anchors.fill: parent
@ -164,7 +165,7 @@ Item {
if (model.isDir) { if (model.isDir) {
listView.headerItem.add(model.title, model.uuid) listView.headerItem.add(model.title, model.uuid)
} else { } else {
emit: open(model.uuid) emit: SignalFileOperation.open(model.uuid)
} }
} }
} }

View File

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

View File

@ -0,0 +1,8 @@
pragma Singleton
import QtQuick
QtObject {
signal open(string file)
signal openNote(string note)
}

View File

@ -6,12 +6,14 @@ import QtQuick.Controls.Basic
import QtWebEngine 1.2 import QtWebEngine 1.2
import FluentUI import FluentUI
import AicsKB.FileTransferManager import AicsKB.FileTransferManager
import SignalFileOperation 1.0
import "qrc:///AicsKnowledgeBase/qml/page" import "qrc:///AicsKnowledgeBase/qml/page"
FluArea { FluArea {
id: content_area id: content_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
visible: false
property string type: "" property string type: ""
property string knowledgeFileId property string knowledgeFileId
signal download(string knowledgeFileId) signal download(string knowledgeFileId)
@ -23,6 +25,13 @@ FluArea {
// bottom: 10 // bottom: 10
// left: 10 // left: 10
// } // }
Connections {
target: SignalFileOperation
function onOpen(file) {
content_area.visible = true
}
}
FluScrollablePage { FluScrollablePage {
id: content_page id: content_page
anchors.fill: parent anchors.fill: parent

View File

@ -4,6 +4,7 @@ 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/global"
import "qrc:///AicsKnowledgeBase/qml/component" import "qrc:///AicsKnowledgeBase/qml/component"
FluArea { FluArea {
@ -18,112 +19,143 @@ 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
text: "标题" // text:""
items: [ // items:[
FluMenuItem { // FluMenuItem{
text: "标题" // text:""
onClicked: { // onClicked: {
select_model.text = text // select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:""
// onClicked: {
// select_model.text = text
// }
// }
// ]
// }
FluTextBox{
placeholderText:"对标题进行搜索……"
Layout.fillWidth: true
} }
}, FluIconButton{
FluMenuItem { Layout.alignment: Qt.AlignRight
text: "内容" iconSource:FluentIcons.Search
onClicked: { onClicked:{
select_model.text = text var allTags = inputTags.getAllTags(tags.tagList)
} var allTagId =[]
}, console.log(allTags)
FluMenuItem {
text: "标签" for (var i = 0; i < allTags.length; i++) {
onClicked: { var url = "?name="
select_model.text = text 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 { 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 selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked
&& selectDoc.checked && selectAudio.checked
} }
} }
RowLayout { RowLayout{
width: parent.width id:inputTags
width:parent.width
height: 32 height: 32
FluText { FluText{
id: tag
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "标签: " text:"标签: "
} }
Tag { Tag{
id:tags
width: 290 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 { FluArea {

View File

@ -54,6 +54,8 @@ int main(int argc, char *argv[])
qmlRegisterSingletonInstance<FileTransferManager>("AicsKB.FileTransferManager", 1, 0, "FileTransferManager", qmlRegisterSingletonInstance<FileTransferManager>("AicsKB.FileTransferManager", 1, 0, "FileTransferManager",
fileTransferManager); fileTransferManager);
qmlRegisterSingletonType(QUrl("qrc:/AicsKnowledgeBase/qml/global/SignalFileOperation.qml"), "SignalFileOperation", 1, 0,
"SignalFileOperation");
const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs); const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,