添加了笔记的布局信息
parent
eb09b43ee8
commit
0db2c63f76
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,11 +28,12 @@ FluArea {
|
|||
backgroundColor: "#f9f9f9"
|
||||
NoteList {
|
||||
id: noteList
|
||||
noteListModel: content_page.noteListModel
|
||||
onOpen: function handle(noteId) {
|
||||
emit: SignalFileOperation.openNote(noteId)
|
||||
}
|
||||
onCreateNote: function handle() {
|
||||
console.log("create note")
|
||||
emit: SignalFileOperation.createNote()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +75,7 @@ FluArea {
|
|||
property string brief: "这是一个简介"
|
||||
property string fileUrl: "https://api.hammer-hfut.tk:233/aics/file/"
|
||||
property string suffix: "md"
|
||||
property ListModel noteListModel
|
||||
|
||||
function getType(suffix) {
|
||||
if (suffix === "md")
|
||||
|
@ -88,14 +90,14 @@ FluArea {
|
|||
function loadFile(knowledgeFileId) {
|
||||
content_area.knowledgeFileId = knowledgeFileId
|
||||
console.log(knowledgeFileId)
|
||||
Request.get("knowledge/" + knowledgeFileId,
|
||||
Request.get("knowledge/" + knowledgeFileId + "/detail",
|
||||
function (response, data) {
|
||||
content_page.publishTime = data.createTime
|
||||
content_page.title = data.name
|
||||
content_page.fileId = data.knowledgeFileAttribute.id
|
||||
content_page.suffix = data.knowledgeFileAttribute.suffix
|
||||
|
||||
content_area.type = getType(
|
||||
data.knowledgeFileAttribute.suffix)
|
||||
content_area.type = getType(content_page.suffix)
|
||||
console.log(content_area.type)
|
||||
|
||||
var tagString = ""
|
||||
|
@ -109,19 +111,39 @@ FluArea {
|
|||
content_page.brief = data.knowledgeFileAttribute.brief
|
||||
content_page.browsCount = data.knowledgeFileAttribute.pageView
|
||||
|
||||
// var starers = data.knowledgeFileAttribute.starers
|
||||
// for (var i = 0; i < starers.length; i++) {
|
||||
isFavorite = false
|
||||
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
|
||||
|
||||
// }
|
||||
// content_page.favoriteCount = starers.length
|
||||
if (content_area.type == "MD") {
|
||||
noteListModel.clear()
|
||||
var notes = data.knowledgeFileAttribute.notes
|
||||
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)
|
||||
FileTransferManager.getMarkdown(
|
||||
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, {
|
||||
"url": fileUrl + "static/"
|
||||
+ fileId + "." + suffix
|
||||
"source": fileUrl + "static/" + fileId
|
||||
+ "." + suffix
|
||||
})
|
||||
} else {
|
||||
Request.get("knowledge/" + knowledgeFileId + "/preview/external",
|
||||
|
@ -316,13 +338,15 @@ FluArea {
|
|||
id: content_view
|
||||
Layout.fillWidth: true
|
||||
height: 500
|
||||
//initialItem: video_view
|
||||
}
|
||||
|
||||
Component {
|
||||
id: video_view
|
||||
FluMediaPlayer {
|
||||
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 {
|
||||
|
|
|
@ -15,10 +15,19 @@ FluArea {
|
|||
id: edit_area
|
||||
paddings: 0
|
||||
backgroundColor: "#f9f9f9"
|
||||
property string uuid
|
||||
property string fileType: "OTHER"
|
||||
property string fileTitle: "dgfgf"
|
||||
property string noteId
|
||||
property string noteTitle
|
||||
property string noteContent
|
||||
property bool isModifying: false
|
||||
|
||||
Component.onCompleted: {
|
||||
if (isModifying) {
|
||||
|
||||
}
|
||||
|
||||
noteTitle = Qt.binding(function () {
|
||||
return input_title.text
|
||||
})
|
||||
|
@ -34,14 +43,42 @@ FluArea {
|
|||
topPadding: 5
|
||||
rightPadding: 5
|
||||
bottomPadding: 0
|
||||
RowLayout {
|
||||
FluIconButton {
|
||||
iconSize: 12
|
||||
iconSource: FluentIcons.Back
|
||||
onClicked: {
|
||||
emit: SignalFileOperation.back()
|
||||
|
||||
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 {
|
||||
FluIconButton {
|
||||
iconSize: 12
|
||||
iconSource: FluentIcons.Back
|
||||
onClicked: {
|
||||
emit: SignalFileOperation.back()
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
Layout.margins: -5
|
||||
}
|
||||
}
|
||||
Item {
|
||||
|
@ -90,8 +127,7 @@ FluArea {
|
|||
FluFilledButton {
|
||||
text: "上传"
|
||||
onClicked: {
|
||||
console.log(noteTitle)
|
||||
console.log(noteContent)
|
||||
|
||||
}
|
||||
}
|
||||
FluButton {
|
||||
|
|
|
@ -41,12 +41,14 @@ FluArea {
|
|||
property int browsCount: 555
|
||||
property bool isLike: false
|
||||
property bool isFavorite: false
|
||||
property double fileSize: 455
|
||||
property string title: "文章标题"
|
||||
property list<string> tags: ["tag 1", "tag 2", "tag 3"]
|
||||
property string publishTime: "2020-01-01"
|
||||
property string brief: "这是一个简介"
|
||||
property var fromFile
|
||||
|
||||
property string uuid: "354"
|
||||
property string fileTitle: "dfnfgf"
|
||||
property string fileType: "OTHER"
|
||||
|
||||
function getType(suffix) {
|
||||
if (suffix === "md")
|
||||
|
@ -63,29 +65,25 @@ FluArea {
|
|||
}
|
||||
|
||||
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)
|
||||
tagString = tagString + ","
|
||||
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
|
||||
}
|
||||
fromFile.tags = 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 {
|
||||
|
@ -172,7 +170,7 @@ FluArea {
|
|||
|
||||
FluArea {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 100
|
||||
implicitHeight: 140
|
||||
ColumnLayout {
|
||||
RowLayout {
|
||||
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 {
|
||||
id: text_view
|
||||
noteId: "255454"
|
||||
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(",")
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue