Compare commits

...

2 Commits

8 changed files with 87 additions and 145 deletions

View File

@ -107,17 +107,30 @@ FluWindow {
"knowledgeFileId": file
})
}
function onOpenNote(note) {
function onOpenNote(note, authorId) {
stack_view.push(note_view, {
"noteFileId": note
"noteFileId": note,
"authorId": authorId
})
}
function onBack() {
if (stack_view.depth > 0)
stack_view.pop()
}
function onCreateNote() {
stack_view.push(create_note_view)
function onCreateNote(file, fileType, fileTitle) {
stack_view.push(note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle
})
}
function onModifyNote(file, fileType, fileTitle, note) {
stack_view.push(note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle,
"noteId": note
})
}
}

View File

@ -1,106 +0,0 @@
import QtQuick 2.15
import FluentUI
import QtQuick.Layouts
FluArea {
id: fileItem
property string uuid
property string title
property string brief
property string date
property string type
property string suffix
property bool isDir: false
property int size
property int pageView
property var tags: []
property int stars
property var colorList: ["blue", "green", "orange", "red", "yellow", "purple", "pink", "brown", "teal", "cyan", "gray", "darkgray"]
signal tagClicked(string tag)
ColumnLayout {
id: row
spacing: 10
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
}
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
}
}
FluText {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
textFormat: Text.RichText
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}
}
RowLayout {
visible: !fileItem.isDir
Repeater {
model: fileItem.tags
delegate: FluTextButton {
text: "#" + fileItem.tags[index]
normalColor: colorList[index % colorList.length]
font.pixelSize: 12
Layout.preferredWidth: 50
onClicked: {
emit: tagClicked(text)
}
}
}
}
}
}

View File

@ -5,7 +5,7 @@ import "qrc:///AicsKnowledgeBase/qml/global"
Item {
anchors.fill: parent
signal open(string note)
signal open(string note, string authorId)
signal createNote
width: parent.width - 8
property ListModel noteListModel: ListModel {
@ -14,6 +14,7 @@ Item {
title: "超级无敌报错"
brief: "file:///D:/academic/2023-qtBig/AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/NoteList.qml:41:21: Unable to assign [undefined] to QString"
author: "admin"
authorId: "345"
pageView: 123
stars: 27
date: "2022-02-02"
@ -23,6 +24,7 @@ Item {
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
authorId: "345"
pageView: 123
stars: 27
date: "2022-02-02"
@ -32,6 +34,7 @@ Item {
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
authorId: "345"
pageView: 123
stars: 27
date: "2022-02-02"
@ -41,6 +44,7 @@ Item {
title: "Qt布局"
brief: "锚定anchors在确定父子组件之间同级组件之间的相对位置时非常常用若使用锚定方式确定子组件与父组件之间的位置关系使用 topbottomleftright topMarginbottomMarginleftMarginrightMargin进行上下左右对齐以及对齐后的留白距离。若要使子组件在父组件的水平垂直居中使用"
author: "超级无敌长的账户名"
authorId: "345"
pageView: 123
stars: 27
date: "2022-02-02"
@ -87,7 +91,7 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
open(model.uuid)
open(model.uuid, model.authorId)
}
}
NoteListItem {
@ -100,6 +104,7 @@ Item {
brief: model.brief
pageView: model.pageView
author: model.author
authorId: model.authorId
stars: model.stars
}
}

View File

@ -11,6 +11,7 @@ FluArea {
property int pageView
property int stars
property string author
property string authorId
ColumnLayout {
id: row

View File

@ -4,7 +4,8 @@ import QtQuick
QtObject {
signal open(string file)
signal openNote(string note)
signal createNote
signal openNote(string note, string authorId)
signal createNote(string file, string fileType, string fileTitle)
signal modifyNote(string file, string fileType, string fileTitle, string note)
signal back
}

View File

@ -29,11 +29,13 @@ FluArea {
NoteList {
id: noteList
noteListModel: content_page.noteListModel
onOpen: function handle(noteId) {
emit: SignalFileOperation.openNote(noteId)
onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId)
}
onCreateNote: function handle() {
emit: SignalFileOperation.createNote()
emit: SignalFileOperation.createNote(
content_area.knowledgeFileId, content_area.type,
content_page.title)
}
}
}
@ -96,6 +98,7 @@ FluArea {
content_page.title = data.name
content_page.fileId = data.knowledgeFileAttribute.id
content_page.suffix = data.knowledgeFileAttribute.suffix
content_page.fileSize = data.knowledgeFileAttribute.size
content_area.type = getType(content_page.suffix)
console.log(content_area.type)
@ -129,6 +132,7 @@ FluArea {
"title": notes[i].title,
"brief": notes[i].content,
"author": notes[i].author.username,
"authorId": notes[i].author.id,
"pageView": notes[i].pageView,
"stars": notes[i].starrers.length,
"date": notes[i].createTime
@ -289,9 +293,10 @@ FluArea {
}
FluText {
padding: 10
text: fileSize > 1024 * 1024 ? (fileSize / 1024 / 1024).toFixed(
2) + "MB" : (fileSize / 1024).toFixed(
2) + "KB"
text: content_page.fileSize > 1024
* 1024 ? (content_page.fileSize / 1024 / 1024).toFixed(
2) + "MB" : (content_page.fileSize / 1024).toFixed(
2) + "KB"
}
FluText {
padding: 10

View File

@ -15,17 +15,25 @@ FluArea {
id: edit_area
paddings: 0
backgroundColor: "#f9f9f9"
property string uuid
property string knowledgeFileId
property string fileType: "OTHER"
property string fileTitle: "dgfgf"
property string noteId
property string noteTitle
property string noteContent
property string noteFileId
property string noteTitle: ""
property string noteContent: ""
property var tags: []
property bool isModifying: false
Component.onCompleted: {
if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) {
noteTitle = data.title
noteContent = data.content
input_title.text = noteTitle
input_md.contentMd = noteContent
tags = data.tags
})
}
noteTitle = Qt.binding(function () {
@ -52,7 +60,7 @@ FluArea {
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.uuid)
emit: SignalFileOperation.open(note_page.knowledgeFileId)
}
}
RowLayout {
@ -99,6 +107,7 @@ FluArea {
padding: 10
placeholderText: "单行输入框"
implicitWidth: parent.width
font.pointSize: 12
}
}
}
@ -127,11 +136,30 @@ FluArea {
FluFilledButton {
text: "上传"
onClicked: {
if (noteTitle.trim() !== "" && noteContent !== "") {
if (isModifying) {
Request.post("note", {
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
})
} else {
Request.put("note/" + noteFileId, {
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
})
}
}
}
}
FluButton {
text: "取消"
onClicked: {
emit: SignalFileOperation.back()
}
}
}
}

View File

@ -65,25 +65,20 @@ FluArea {
}
Component.onCompleted: {
Request.getSearch("/", function (response, data) {
note_page.uuid = data.id
note_page.fileTitle = data.name
note_page.fileType = getType(data.knowledgeFileAttribute.suffix)
note_page.fileStars = 0
// Request.get("knowledge/", function (response, data) {
// fromFile = {
// note_page.uuid = data.id,
// note_page.fileTitle = data.name,
// note_page.fileType = getType(data.knowledgeFileAttribute.suffix),
// }
// note_page.fileStars = 0
// var tagString = ""
// for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
// if (j != 0)
// tagString = tagString + ","
// tagString = tagString + file.knowledgeFileAttribute.tags[j].name
// }
// note_page.fileTags = tagString
// })
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
}
note_page.fileTags = tagString
})
}
FluIconButton {