Compare commits

..

No commits in common. "26b9016a45e1fd93d9aab854a2178f64d32545e6" and "b67075a3ba4d373403037ba9ac53945a20046d79" have entirely different histories.

8 changed files with 145 additions and 87 deletions

View File

@ -107,30 +107,17 @@ FluWindow {
"knowledgeFileId": file "knowledgeFileId": file
}) })
} }
function onOpenNote(note, authorId) { function onOpenNote(note) {
stack_view.push(note_view, { stack_view.push(note_view, {
"noteFileId": note, "noteFileId": note
"authorId": authorId
}) })
} }
function onBack() { function onBack() {
if (stack_view.depth > 0) if (stack_view.depth > 0)
stack_view.pop() stack_view.pop()
} }
function onCreateNote(file, fileType, fileTitle) { function onCreateNote() {
stack_view.push(note_view, { stack_view.push(create_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

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

View File

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

View File

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

View File

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

View File

@ -15,25 +15,17 @@ FluArea {
id: edit_area id: edit_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
property string knowledgeFileId property string uuid
property string fileType: "OTHER" property string fileType: "OTHER"
property string fileTitle: "dgfgf" property string fileTitle: "dgfgf"
property string noteFileId property string noteId
property string noteTitle: "" property string noteTitle
property string noteContent: "" property string noteContent
property var tags: []
property bool isModifying: false property bool isModifying: false
Component.onCompleted: { Component.onCompleted: {
if (isModifying) { 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 () { noteTitle = Qt.binding(function () {
@ -60,7 +52,7 @@ FluArea {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onDoubleClicked: { onDoubleClicked: {
emit: SignalFileOperation.open(note_page.knowledgeFileId) emit: SignalFileOperation.open(note_page.uuid)
} }
} }
RowLayout { RowLayout {
@ -107,7 +99,6 @@ FluArea {
padding: 10 padding: 10
placeholderText: "单行输入框" placeholderText: "单行输入框"
implicitWidth: parent.width implicitWidth: parent.width
font.pointSize: 12
} }
} }
} }
@ -136,30 +127,11 @@ FluArea {
FluFilledButton { FluFilledButton {
text: "上传" text: "上传"
onClicked: { 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 { FluButton {
text: "取消" text: "取消"
onClicked: {
emit: SignalFileOperation.back()
}
} }
} }
} }

View File

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