添加了笔记的布局信息

main
yang.yongquan 2023-07-07 01:45:03 +08:00
parent eb09b43ee8
commit 0db2c63f76
4 changed files with 240 additions and 61 deletions

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

@ -28,11 +28,12 @@ FluArea {
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
NoteList { NoteList {
id: noteList id: noteList
noteListModel: content_page.noteListModel
onOpen: function handle(noteId) { onOpen: function handle(noteId) {
emit: SignalFileOperation.openNote(noteId) emit: SignalFileOperation.openNote(noteId)
} }
onCreateNote: function handle() { onCreateNote: function handle() {
console.log("create note") emit: SignalFileOperation.createNote()
} }
} }
} }
@ -74,6 +75,7 @@ FluArea {
property string brief: "这是一个简介" property string brief: "这是一个简介"
property string fileUrl: "https://api.hammer-hfut.tk:233/aics/file/" property string fileUrl: "https://api.hammer-hfut.tk:233/aics/file/"
property string suffix: "md" property string suffix: "md"
property ListModel noteListModel
function getType(suffix) { function getType(suffix) {
if (suffix === "md") if (suffix === "md")
@ -88,14 +90,14 @@ FluArea {
function loadFile(knowledgeFileId) { function loadFile(knowledgeFileId) {
content_area.knowledgeFileId = knowledgeFileId content_area.knowledgeFileId = knowledgeFileId
console.log(knowledgeFileId) console.log(knowledgeFileId)
Request.get("knowledge/" + knowledgeFileId, Request.get("knowledge/" + knowledgeFileId + "/detail",
function (response, data) { function (response, data) {
content_page.publishTime = data.createTime content_page.publishTime = data.createTime
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_area.type = getType( content_area.type = getType(content_page.suffix)
data.knowledgeFileAttribute.suffix)
console.log(content_area.type) console.log(content_area.type)
var tagString = "" var tagString = ""
@ -109,19 +111,39 @@ FluArea {
content_page.brief = data.knowledgeFileAttribute.brief content_page.brief = data.knowledgeFileAttribute.brief
content_page.browsCount = data.knowledgeFileAttribute.pageView content_page.browsCount = data.knowledgeFileAttribute.pageView
// var starers = data.knowledgeFileAttribute.starers isFavorite = false
// for (var i = 0; i < starers.length; i++) { var starers = data.knowledgeFileAttribute.starers
for (var i = 0; i < starers.length; i++) {
if (starers[i].id === UserData.userId) {
isFavorite = true
}
}
content_page.favoriteCount = starers.length
// } noteListModel.clear()
// content_page.favoriteCount = starers.length var notes = data.knowledgeFileAttribute.notes
if (content_area.type == "MD") { noteCount = notes.length
for (var i = 0; i < notes.length; i++) {
noteListModel.append({
"uuid": notes[i].id,
"title": notes[i].title,
"brief": notes[i].content,
"author": notes[i].author.username,
"pageView": notes[i].pageView,
"stars": notes[i].starrers.length,
"date": notes[i].createTime
})
}
if (content_area.type === "MD") {
// console.log(content_area.type) // console.log(content_area.type)
FileTransferManager.getMarkdown( FileTransferManager.getMarkdown(
content_page.fileId) content_page.fileId)
} else if (content_area.type == "VIDEO") { } else if (content_area.type === "VIDEO") {
console.log(fileUrl + "static/" + fileId + "." + suffix)
content_view.push(video_view, { content_view.push(video_view, {
"url": fileUrl + "static/" "source": fileUrl + "static/" + fileId
+ fileId + "." + suffix + "." + suffix
}) })
} else { } else {
Request.get("knowledge/" + knowledgeFileId + "/preview/external", Request.get("knowledge/" + knowledgeFileId + "/preview/external",
@ -316,13 +338,15 @@ FluArea {
id: content_view id: content_view
Layout.fillWidth: true Layout.fillWidth: true
height: 500 height: 500
//initialItem: video_view
} }
Component { Component {
id: video_view id: video_view
FluMediaPlayer { FluMediaPlayer {
width: parent.width width: parent.width
implicitHeight: width * 9 / 16. height: width * 9 / 16.
source: "https://api.hammer-hfut.tk:233/aics/file/static/3f28fea9-27f1-4a85-9d3e-def187c4456e.mp4"
} }
} }
Component { Component {

View File

@ -15,10 +15,19 @@ FluArea {
id: edit_area id: edit_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
property string uuid
property string fileType: "OTHER"
property string fileTitle: "dgfgf"
property string noteId
property string noteTitle property string noteTitle
property string noteContent property string noteContent
property bool isModifying: false
Component.onCompleted: { Component.onCompleted: {
if (isModifying) {
}
noteTitle = Qt.binding(function () { noteTitle = Qt.binding(function () {
return input_title.text return input_title.text
}) })
@ -34,6 +43,20 @@ FluArea {
topPadding: 5 topPadding: 5
rightPadding: 5 rightPadding: 5
bottomPadding: 0 bottomPadding: 0
Item {
Layout.fillWidth: true
implicitHeight: 30
Layout.leftMargin: 5
Layout.bottomMargin: 10
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.uuid)
}
}
RowLayout {
id: titleRow
RowLayout { RowLayout {
FluIconButton { FluIconButton {
iconSize: 12 iconSize: 12
@ -41,7 +64,21 @@ FluArea {
onClicked: { onClicked: {
emit: SignalFileOperation.back() emit: SignalFileOperation.back()
} }
Layout.margins: -5 }
}
Image {
id: icon
source: edit_area.fileType ? "qrc:/AicsKnowledgeBase/res/"
+ edit_area.fileType + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: edit_area.fileTitle
}
} }
} }
Item { Item {
@ -90,8 +127,7 @@ FluArea {
FluFilledButton { FluFilledButton {
text: "上传" text: "上传"
onClicked: { onClicked: {
console.log(noteTitle)
console.log(noteContent)
} }
} }
FluButton { FluButton {

View File

@ -41,12 +41,14 @@ FluArea {
property int browsCount: 555 property int browsCount: 555
property bool isLike: false property bool isLike: false
property bool isFavorite: false property bool isFavorite: false
property double fileSize: 455
property string title: "文章标题" property string title: "文章标题"
property list<string> tags: ["tag 1", "tag 2", "tag 3"] property list<string> tags: ["tag 1", "tag 2", "tag 3"]
property string publishTime: "2020-01-01" property string publishTime: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
property var fromFile
property string uuid: "354"
property string fileTitle: "dfnfgf"
property string fileType: "OTHER"
function getType(suffix) { function getType(suffix) {
if (suffix === "md") if (suffix === "md")
@ -63,29 +65,25 @@ FluArea {
} }
Component.onCompleted: { Component.onCompleted: {
Request.get("knowledge/", function (response, data) {
fromFile = {
"uuid": data.id,
"fuuid": data.knowledgeFileAttribute.id,
"title": data.name,
"date": data.createTime,
"brief": data.knowledgeFileAttribute.brief,
"suffix": data.knowledgeFileAttribute.suffix,
"type": getType(data.knowledgeFileAttribute.suffix),
"pageView": data.knowledgeFileAttribute.pageView,
"size": data.knowledgeFileAttribute.size
}
fromFile.stars = 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),
var tagString = "" // }
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0) // note_page.fileStars = 0
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name // var tagString = ""
} // for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
fromFile.tags = tagString // if (j != 0)
}) // tagString = tagString + ","
// tagString = tagString + file.knowledgeFileAttribute.tags[j].name
// }
// note_page.fileTags = tagString
// })
} }
FluIconButton { FluIconButton {
@ -172,7 +170,7 @@ FluArea {
FluArea { FluArea {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 100 implicitHeight: 140
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
width: parent.width width: parent.width
@ -214,27 +212,42 @@ FluArea {
} }
} }
} }
Item {
Layout.fillWidth: true
implicitHeight: 30
Layout.leftMargin: 10
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.uuid)
} }
} }
RowLayout {
id: titleRow
Image {
id: icon
source: note_page.fileType ? "qrc:/AicsKnowledgeBase/res/"
+ note_page.fileType + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: note_page.fileTitle
}
}
}
}
}
NoteEditPage { NoteEditPage {
id: text_view id: text_view
noteId: "255454" noteId: "255454"
width: parent.width width: parent.width
implicitHeight: 400 implicitHeight: width * 9 / 16
} }
// FistListItem {
// id: fileListItem
// uuid: fromFile.uuid
// fuuid: fromFile.fuuid
// title: fromFile.title
// date: fromFile.date
// brief: fromFile.brief
// type: fromFile.type
// pageView: fromFile.pageView
// size: fromFile.size
// stars: fromFile.stars
// tags: fromFile.tags === null || fromFile.tags === undefined
// || fromFile.tags === "" ? [] : fromFile.tags.split(",")
// }
} }
} }