Merge remote-tracking branch 'origin/main' into main

main
wuyize 2023-07-05 21:14:55 +08:00
commit f65f9f3dbb
7 changed files with 355 additions and 67 deletions

View File

@ -2,13 +2,20 @@ 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
signal search(string tag) signal search(string tag)
signal open(string file) signal open(string file)
property bool disableHeader: false property bool disableHeader: false
property bool autoRequest: false
property string url: "http://127.0.0.1:4523/m1/2914957-0-5604d062/"
property ListModel dataModel: ListModel {}
function setListData(listmodel) {
listView.model = listmodel
}
ListView { ListView {
id: listView id: listView
anchors.fill: parent anchors.fill: parent
@ -17,7 +24,11 @@ Item {
model: fileListModel model: fileListModel
delegate: fileListItemDelegate delegate: fileListItemDelegate
Component.onCompleted: { Component.onCompleted: {
if (autoRequest) {
update() update()
} else {
listView.model = dataModel
}
} }
} }
@ -114,6 +125,7 @@ Item {
} }
fileListModel.append(modelItem) fileListModel.append(modelItem)
} }
console.log(fileListModel)
listView.currentIndex = -1 listView.currentIndex = -1
}) })
} }
@ -140,7 +152,9 @@ Item {
size: isDir ? 0 : model.size size: isDir ? 0 : model.size
stars: isDir ? 0 : model.stars stars: isDir ? 0 : model.stars
// split string to array // split string to array
tags: isDir ? [] : model.tags.split(",") tags: isDir ? [] : model.tags === null
|| model.tags === undefined
|| model.tags === "" ? [] : model.tags.split(",")
onTagClicked: { onTagClicked: {
emit: search(tag) emit: search(tag)
console.log(tag) console.log(tag)
@ -151,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)
} }
} }
} }
@ -165,7 +179,7 @@ Item {
type: "FOLDER" type: "FOLDER"
} }
ListElement { ListElement {
uid: "2" uuid: "2"
title: "File 2" title: "File 2"
isDir: false isDir: false
brief: "This is a test file" brief: "This is a test file"
@ -176,7 +190,7 @@ Item {
stars: 10 stars: 10
} }
ListElement { ListElement {
uid: "3" uuid: "3"
title: "File 3" title: "File 3"
isDir: false isDir: false
brief: "This is a test file" brief: "This is a test file"

View File

@ -0,0 +1,176 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import FluentUI
Rectangle {
id: input
width: 300
height: 32
radius: 5
clip: true
border.color: textInput.activeFocus ? "#268CDC":"#979592" //gray100
ListModel { id: tagListModel }
property ListModel tagList: tagListModel
Row {
x: 5
height: parent.height
spacing: 5
Row {
id: rowTag
anchors.verticalCenter: parent.verticalCenter
spacing: 5
Repeater {
model: tagListModel
Loader {
sourceComponent: tagItem
Component.onCompleted: {
item.closeClicked.connect(function(){
tagListModel.remove(index)
})
item.tag = Qt.binding(function(){return tag})
}
}
}
}
Item {
width: input.width - rowTag.width
height: parent.height
TextField {
id:textInput
placeholderText: qsTr("按回车键Enter创建标签")
onFocusChanged: {
text =""
}
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 15
clip: true
background: 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))
text = ""
}
Keys.onPressed: {
if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) {
tagListModel.remove(tagListModel.count-1)
}
}
}
}
}
}
property Component tagItem:
Rectangle {
id: rootTagItem
property alias tag: tagText.text
signal closeClicked()
width: content.width
height: 25
radius: 5
color: "#00aeec"
border.color: "#00aeec"
MouseArea {
id: mouseArea
property bool hovered: false
anchors.fill: parent
hoverEnabled: true
onEntered: hovered = true
onExited: hovered = false
Row {
id: content
anchors.verticalCenter: parent.verticalCenter
height: rootTagItem.height
Item { width: 5; height: 1 }
Text {
id: tagText
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: rootTagItem.height * 0.5
text: "Hello"
color: "white"
}
Item { visible: mouseArea.hovered; width: 5; height: 1 }
Item {
anchors.verticalCenter: parent.verticalCenter
width: mouseArea.hovered ? 15 : 0
height: rootTagItem.height
visible: mouseArea.hovered
Behavior on width {
NumberAnimation {duration: 100}
}
Behavior on visible {
NumberAnimation {duration: 100}
}
Rectangle {
width: height
height: parent.height * 0.6
anchors.centerIn: parent
radius: height
color: closeMouseArea.pressed ? "gray" : "red"
visible: closeMouseArea.hovered
}
Text {
anchors.centerIn: parent
text: "×"
color: "white"
}
MouseArea {
id: closeMouseArea
property bool hovered: false
anchors.fill: parent
hoverEnabled: true
onEntered: hovered = true
onExited: hovered = false
onCanceled: hovered = false
onClicked: rootTagItem.closeClicked()
}
}
Item { width: 5; height: 1 }
}
}
}
}

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

@ -64,5 +64,7 @@ FluArea {
} }
} }
FileList {} FileList {
autoRequest: true
}
} }

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 {
@ -22,46 +23,68 @@ FluArea {
*/ */
ColumnLayout{ ColumnLayout{
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{ // FluMenuItem{
text:"内容" // text:""
onClicked: { // onClicked: {
select_model.text = text // select_model.text = text
} // }
}, // },
FluMenuItem{ // FluMenuItem{
text:"标签" // text:""
onClicked: { // onClicked: {
select_model.text = text // select_model.text = text
} // }
} // }
] // ]
} // }
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:{
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:"同时搜索简介和内容"
}
// //
RowLayout{ RowLayout{
@ -111,6 +134,29 @@ FluArea {
} }
} }
RowLayout{
id:inputTags
width:parent.width
height: 32
FluText{
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 { FluArea {
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
@ -120,6 +166,37 @@ FluArea {
FileList { FileList {
disableHeader: true disableHeader: true
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
}
}
} }
} }
} }

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,