main
karlis 2023-07-07 03:27:31 +08:00
commit 2ceb74b862
20 changed files with 385 additions and 176 deletions

View File

@ -95,7 +95,7 @@ FluWindow {
duration: 200 duration: 200
} }
} }
initialItem: create_note_view initialItem: note_view
} }
Connections { Connections {
@ -107,17 +107,31 @@ FluWindow {
"knowledgeFileId": file "knowledgeFileId": file
}) })
} }
function onOpenNote(note) { function onOpenNote(note, authorId) {
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() { function onCreateNote(file, fileType, fileTitle) {
stack_view.push(create_note_view) stack_view.push(create_note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle
})
}
function onModifyNote(file, fileType, fileTitle, note) {
stack_view.push(create_note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle,
"noteId": note,
"isModifying": true
})
} }
} }

View File

@ -117,6 +117,20 @@ Rectangle {
Layout.rightMargin: 10 Layout.rightMargin: 10
iconSource: FluentIcons.PenPalette iconSource: FluentIcons.PenPalette
iconSize: 14 iconSize: 14
onClicked: {
note_menu.open()
}
FluMenu {
id: note_menu
x: parent ? (parent.width - width) / 2 : 0
y: parent ? parent.height : 0
FluMenuItem {
text: "收藏的笔记"
}
FluMenuItem {
text: "我的笔记"
}
}
} }
Text { Text {
@ -218,5 +232,6 @@ Rectangle {
frameless_helper.setHitTestVisible(btn_maximize) frameless_helper.setHitTestVisible(btn_maximize)
frameless_helper.setHitTestVisible(btn_close) frameless_helper.setHitTestVisible(btn_close)
frameless_helper.setHitTestVisible(btn_transfer) frameless_helper.setHitTestVisible(btn_transfer)
frameless_helper.setHitTestVisible(btn_note)
} }
} }

View File

@ -126,9 +126,15 @@ Item {
return "OTHER" return "OTHER"
} }
RowLayout { RowLayout {
Layout.preferredWidth: parent.width Layout.alignment: Qt.AlignRight
//Layout.preferredWidth: parent.width
layoutDirection: Qt.RightToLeft
UploadButton {
//Layout.alignment: Qt.AlignRight
header: header
}
Item { Item {
anchors.right: uploadBtn.left //anchors.right: uploadBtn.left
height: 28 height: 28
width: 28 width: 28
InputDialog { InputDialog {
@ -153,59 +159,14 @@ Item {
} }
} }
Image { FluIconButton {
source: "qrc:/AicsKnowledgeBase/res/createFolder.png"
anchors.fill: parent
}
MouseArea {
anchors.fill: parent anchors.fill: parent
iconSource: FluentIcons.NewFolder
onClicked: { onClicked: {
dialog.open() dialog.open()
} }
} }
} }
FluButton {
id: uploadIcon
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
let name = FileTransferManager.getFileName(
selectedFile)
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(
selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": name,
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null
}
console.log("begin")
Request.post("knowledge/file",
JSON.stringify(body),
function (res, data) {
console.log(res)
console.log(data)
FileTransferManager.upload(
selectedFile, data.id,
data.ticket, name)
}, function (res, data) {
console.log(res)
})
}
}
}
} }
RowLayout { RowLayout {
id: fileListItemHeaderItem id: fileListItemHeaderItem

View File

@ -84,17 +84,8 @@ FluArea {
} }
} }
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: row
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: { onDoubleClicked: {
fileItem.parent.doubleClicked() fileItem.parent.doubleClicked()
@ -105,6 +96,11 @@ FluArea {
} }
} }
} }
ColumnLayout {
id: clickable
anchors.fill: row
RowLayout { RowLayout {
id: titleRow id: titleRow
Image { Image {
@ -112,6 +108,7 @@ FluArea {
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : "" source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24 Layout.preferredHeight: 24
Layout.preferredWidth: 24 Layout.preferredWidth: 24
fillMode: Image.PreserveAspectFit
} }
FluText { FluText {
id: title id: title

View File

@ -5,7 +5,7 @@ import "qrc:///AicsKnowledgeBase/qml/global"
Item { Item {
anchors.fill: parent anchors.fill: parent
signal open(string note) signal open(string note, string authorId)
signal createNote signal createNote
width: parent.width - 8 width: parent.width - 8
property ListModel noteListModel: ListModel { property ListModel noteListModel: ListModel {
@ -14,6 +14,7 @@ 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"
@ -23,6 +24,7 @@ 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"
@ -32,6 +34,7 @@ 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"
@ -41,6 +44,7 @@ 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"
@ -87,7 +91,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
open(model.uuid) open(model.uuid, model.authorId)
} }
} }
NoteListItem { NoteListItem {
@ -100,6 +104,7 @@ 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,6 +11,7 @@ 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

@ -16,29 +16,31 @@ Rectangle {
radius: 5 radius: 5
clip: true clip: true
ListModel { id: tagListModel } ListModel {
id: tagListModel
}
property ListModel tagList: tagListModel property ListModel tagList: tagListModel
property var tagMap:[] property var tagMap: []
property var presetsTags:[] property var presetsTags: []
property var presetsTagsItem:[] property var presetsTagsItem: []
Component.onCompleted: { Component.onCompleted: {
Request.get("tag?name", Request.get("tag?name", function (result, data) {
function(result, data){ // console.log("success")
// console.log("success") // console.log(result)
// console.log(result) // console.log(data.length)
// console.log(data.length) for (var i = 0; i < data.length; i++) {
for(var i =0;i<data.length;i++){ tagMap.push(data[i])
tagMap.push([data[i].id,data[i].name])
presetsTags.push(data[i].name) presetsTags.push(data[i].name)
presetsTagsItem.push({title:data[i].name}) presetsTagsItem.push({
"title": data[i].name
})
} }
// console.log(tagMap) // console.log(tagMap)
// console.log(presetsTags) // console.log(presetsTags)
},function (p1, p2) { }, function (p1, p2) {// console.log("failure")
// console.log("failure") // console.log(p1)
// console.log(p1) // console.log(p2)
// console.log(p2)
}) })
} }
@ -58,11 +60,13 @@ Rectangle {
Loader { Loader {
sourceComponent: tagItem sourceComponent: tagItem
Component.onCompleted: { Component.onCompleted: {
item.closeClicked.connect(function(){ item.closeClicked.connect(function () {
tagListModel.remove(index) tagListModel.remove(index)
}) })
item.tag = Qt.binding(function(){return tag}) item.tag = Qt.binding(function () {
return tag
})
} }
} }
} }
@ -72,19 +76,18 @@ Rectangle {
width: input.width - rowTag.width width: input.width - rowTag.width
height: parent.height height: parent.height
FluAutoSuggestBox{ FluAutoSuggestBox {
id:textInput id: textInput
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: parent.width width: parent.width
placeholderText: "按回车键Enter创建标签" placeholderText: "按回车键Enter创建标签"
Layout.preferredWidth: 300 Layout.preferredWidth: 300
//items:[{title:""},{title:""},{title:""}] //items:[{title:""},{title:""},{title:""}]
items: presetsTagsItem items: presetsTagsItem
onFocusChanged: { onFocusChanged: {
text ="" text = ""
} }
Keys.onReturnPressed: { Keys.onReturnPressed: {
@ -92,18 +95,22 @@ Rectangle {
if (text.length === 0) if (text.length === 0)
return return
if(presetsTags.indexOf(text) === -1){ var tagId
text = "" for (var i = 0; i < tagMap.length; i++) {
return if (tagMap[i].name === text) {
} tagListModel.append({
tagListModel.append({"tag": text}) "tag": text,
"id": tagMap[i].id
})
//console.log(tagListModel.get(0)) //console.log(tagListModel.get(0))
text = "" text = ""
} }
}
}
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Backspace) { if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) { if (text.length === 0 && tagListModel.count) {
tagListModel.remove(tagListModel.count-1) tagListModel.remove(tagListModel.count - 1)
} }
} }
} }
@ -111,11 +118,10 @@ Rectangle {
} }
} }
property Component tagItem: property Component tagItem: Rectangle {
Rectangle {
id: rootTagItem id: rootTagItem
property alias tag: tagText.text property alias tag: tagText.text
signal closeClicked() signal closeClicked
width: content.width width: content.width
height: 25 height: 25
@ -136,7 +142,10 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: rootTagItem.height height: rootTagItem.height
Item { width: 5; height: 1 } Item {
width: 5
height: 1
}
Text { Text {
id: tagText id: tagText
@ -146,7 +155,11 @@ Rectangle {
color: "white" color: "white"
} }
Item { visible: mouseArea.hovered; width: 5; height: 1 } Item {
visible: mouseArea.hovered
width: 5
height: 1
}
Item { Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -154,11 +167,15 @@ Rectangle {
height: rootTagItem.height height: rootTagItem.height
visible: mouseArea.hovered visible: mouseArea.hovered
Behavior on width { Behavior on width {
NumberAnimation {duration: 100} NumberAnimation {
duration: 100
}
} }
Behavior on visible { Behavior on visible {
NumberAnimation {duration: 100} NumberAnimation {
duration: 100
}
} }
Rectangle { Rectangle {
@ -189,9 +206,11 @@ Rectangle {
} }
} }
Item { width: 5; height: 1 } Item {
width: 5
height: 1
}
} }
} }
} }
} }

View File

@ -10,11 +10,12 @@ FluButton {
property var header property var header
property var currentSelectedFile: null property var currentSelectedFile: null
Layout.alignment: Qt.AlignRight //Layout.alignment: Qt.AlignRight
text: "上传" text: "上传"
onClicked: function () { onClicked: function () {
console.log("click") console.log("click")
fileDialog.open() fileDialog.open()
//popup.open()
} }
FileDialog { FileDialog {
id: fileDialog id: fileDialog
@ -52,7 +53,7 @@ FluButton {
} }
} }
Row { Column {
id: content id: content
topPadding: 14 topPadding: 14
leftPadding: 20 leftPadding: 20
@ -68,6 +69,9 @@ FluButton {
width: parent.width - parent.leftPadding - parent.rightPadding width: parent.width - parent.leftPadding - parent.rightPadding
placeholderText: "请输入简介" placeholderText: "请输入简介"
} }
Tag {
id: tags
}
} }
Rectangle { Rectangle {
@ -107,6 +111,12 @@ FluButton {
text: "上传" text: "上传"
onClicked: { onClicked: {
popup.close() popup.close()
var tagIds = []
for (var i = 0; i < tags.tagList.count; i++) {
console.log(tags.tagList.get(i).tag)
console.log(tags.tagList.get(i).id)
tagIds.push(tags.tagList.get(i).id)
}
let name = FileTransferManager.getFileName( let name = FileTransferManager.getFileName(
currentSelectedFile) currentSelectedFile)
const size = FileTransferManager.getFileSize( const size = FileTransferManager.getFileSize(
@ -120,7 +130,7 @@ FluButton {
"brief": brief_textbox.text, "brief": brief_textbox.text,
"size": size, "size": size,
"md5": md5, "md5": md5,
"tags": [], "tags": tagIds,
"parentId": currentParentId() "parentId": currentParentId()
} }
console.log("begin") console.log("begin")

View File

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

View File

@ -28,11 +28,16 @@ FluArea {
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
NoteList { NoteList {
id: noteList id: noteList
onOpen: function handle(noteId) { noteListModel: content_page.noteListModel
emit: SignalFileOperation.openNote(noteId) onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId)
popup.close()
} }
onCreateNote: function handle() { onCreateNote: function handle() {
console.log("create note") emit: SignalFileOperation.createNote(content_page.fileId,
content_area.type,
content_page.title)
popup.close()
} }
} }
} }
@ -66,7 +71,7 @@ FluArea {
property int shareCount: 0 property int shareCount: 0
property int browsCount: 555 property int browsCount: 555
property bool isFavorite: false property bool isFavorite: false
property bool isDownload: false property bool isDownload: UserData.downloadedFiles.indexOf(fileId) != -1
property double fileSize: 0 property double fileSize: 0
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"]
@ -74,6 +79,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,15 +94,17 @@ 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 + "/detailed",
function (response, data) { function (response, data) {
console.log(response)
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_page.fileSize = data.knowledgeFileAttribute.size
content_area.type = getType( content_area.type = getType(content_page.suffix)
data.knowledgeFileAttribute.suffix) console.log(content_area.fileId)
console.log(content_area.type)
var tagString = "" var tagString = ""
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
@ -109,19 +117,40 @@ 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,
"authorId": notes[i].author.id,
"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",
@ -219,7 +248,7 @@ FluArea {
content_page.isFavorite = !content_page.isFavorite content_page.isFavorite = !content_page.isFavorite
content_page.favoriteCount += 1 content_page.favoriteCount += 1
Request.put("knowledge/" + knowledgeFileId + "/star", { Request.put("knowledge/" + knowledgeFileId + "/star", {
"active": UserData.userId "active": content_page.isFavorite
}) })
} }
} }
@ -249,7 +278,7 @@ FluArea {
FileTransferManager.download(content_page.fileId, FileTransferManager.download(content_page.fileId,
content_page.title) content_page.title)
else { else {
FileTransferManager.openLocalFile(content_page.title)
} }
} }
} }
@ -267,8 +296,9 @@ FluArea {
} }
FluText { FluText {
padding: 10 padding: 10
text: fileSize > 1024 * 1024 ? (fileSize / 1024 / 1024).toFixed( text: content_page.fileSize > 1024
2) + "MB" : (fileSize / 1024).toFixed( * 1024 ? (content_page.fileSize / 1024 / 1024).toFixed(
2) + "MB" : (content_page.fileSize / 1024).toFixed(
2) + "KB" 2) + "KB"
} }
FluText { FluText {
@ -316,13 +346,14 @@ 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.
} }
} }
Component { Component {

View File

@ -15,10 +15,29 @@ FluArea {
id: edit_area id: edit_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
property string noteTitle property string knowledgeFileId
property string noteContent property string fileType: "OTHER"
property string fileTitle: "dgfgf"
property string noteFileId
property string noteTitle: ""
property string noteContent: ""
property var tags: []
property bool isModifying: false
Component.onCompleted: { Component.onCompleted: {
console.log(knowledgeFileId)
isModifying = false
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 () {
return input_title.text return input_title.text
}) })
@ -34,6 +53,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.knowledgeFileId)
}
}
RowLayout {
id: titleRow
RowLayout { RowLayout {
FluIconButton { FluIconButton {
iconSize: 12 iconSize: 12
@ -41,7 +74,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 {
@ -62,6 +109,7 @@ FluArea {
padding: 10 padding: 10
placeholderText: "单行输入框" placeholderText: "单行输入框"
implicitWidth: parent.width implicitWidth: parent.width
font.pointSize: 12
} }
} }
} }
@ -90,12 +138,33 @@ FluArea {
FluFilledButton { FluFilledButton {
text: "上传" text: "上传"
onClicked: { onClicked: {
if (noteTitle.trim() !== "" && noteContent !== "") {
console.log(noteTitle) console.log(noteTitle)
console.log(noteContent) console.log(noteContent)
console.log(knowledgeFileId)
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

@ -18,6 +18,7 @@ FluArea {
// visible: false // visible: false
property string type: "" property string type: ""
property string noteFileId property string noteFileId
property string authorId
signal clickTags(string tagName) signal clickTags(string tagName)
// paddings: { // paddings: {
@ -41,12 +42,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 string fileTitle: "dfnfgf"
property string fileType: "OTHER"
function getType(suffix) { function getType(suffix) {
if (suffix === "md") if (suffix === "md")
return "MD" return "MD"
@ -62,7 +65,38 @@ FluArea {
} }
Component.onCompleted: { Component.onCompleted: {
Request.getSearch("note/" + noteFileId, function (response, data) {
note_page.fileId = 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 < data.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + data.tags[j].name
}
note_page.fileTags = tagString
likeCount = data.likers.length
isLike = false
for (var j = 0; j < data.likers.length; j++) {
if (data.likers[j].id === UserData.userId) {
isLike = true
break
}
}
favoriteCount = data.starrers.length
isLike = false
for (var j = 0; j < data.starrers.length; j++) {
if (data.starrers[j].id === UserData.userId) {
isFavorite = true
break
}
}
})
} }
FluIconButton { FluIconButton {
@ -87,6 +121,17 @@ FluArea {
bold: true bold: true
} }
} }
FluIconButton {
id: button_edit_note
iconSize: FluentIcons.Edit
visible: authorId === UserData.userId
onClicked: {
emit: SignalFileOperation.modifyNote(note_page.fileId,
note_page.fileType,
note_page.fileTitle,
noteFileId)
}
}
ColumnLayout { ColumnLayout {
id: layout_share id: layout_share
FluIconButton { FluIconButton {
@ -113,6 +158,12 @@ FluArea {
id: button_favorite id: button_favorite
iconSize: 15 iconSize: 15
iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
onClicked: {
note_page.isFavorite = !note_page.isFavorite
Request.put("/note/" + noteFileId + "/star", {
"active": note_page.isFavorite
})
}
} }
FluText { FluText {
id: text_favorite id: text_favorite
@ -132,6 +183,12 @@ FluArea {
id: button_like id: button_like
iconSize: 15 iconSize: 15
iconSource: note_page.isLike ? FluentIcons.HeartFill : FluentIcons.Heart iconSource: note_page.isLike ? FluentIcons.HeartFill : FluentIcons.Heart
onClicked: {
note_page.isLike = !note_page.isLike
Request.put("/note/" + noteFileId + "/like", {
"active": note_page.isLike
})
}
} }
FluText { FluText {
id: text_like id: text_like
@ -149,7 +206,7 @@ FluArea {
FluArea { FluArea {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 100 implicitHeight: 140
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
width: parent.width width: parent.width
@ -191,13 +248,42 @@ FluArea {
} }
} }
} }
Item {
Layout.fillWidth: true
implicitHeight: 30
Layout.leftMargin: 10
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.fileId)
} }
} }
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
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent)
m_roleName.insert(kSpeedRole, "speed"); m_roleName.insert(kSpeedRole, "speed");
m_roleName.insert(kPausedRole, "paused"); m_roleName.insert(kPausedRole, "paused");
m_data.append({true, "id", "name", 30, 100, 30}); //m_data.append({true, "id", "name", 30, 100, 30});
} }