完成大部分

main
yang.yongquan 2023-07-07 03:21:43 +08:00
parent 26b9016a45
commit abec8f55f1
4 changed files with 67 additions and 18 deletions

View File

@ -95,7 +95,7 @@ FluWindow {
duration: 200 duration: 200
} }
} }
initialItem: create_note_view initialItem: note_view
} }
Connections { Connections {
@ -118,18 +118,19 @@ FluWindow {
stack_view.pop() stack_view.pop()
} }
function onCreateNote(file, fileType, fileTitle) { function onCreateNote(file, fileType, fileTitle) {
stack_view.push(note_view, { stack_view.push(create_note_view, {
"knowledgeFileId": file, "knowledgeFileId": file,
"fileType": fileType, "fileType": fileType,
"fileTitle": fileTitle "fileTitle": fileTitle
}) })
} }
function onModifyNote(file, fileType, fileTitle, note) { function onModifyNote(file, fileType, fileTitle, note) {
stack_view.push(note_view, { stack_view.push(create_note_view, {
"knowledgeFileId": file, "knowledgeFileId": file,
"fileType": fileType, "fileType": fileType,
"fileTitle": fileTitle, "fileTitle": fileTitle,
"noteId": note "noteId": note,
"isModifying": true
}) })
} }
} }

View File

@ -31,11 +31,13 @@ FluArea {
noteListModel: content_page.noteListModel noteListModel: content_page.noteListModel
onOpen: function handle(noteId, authorId) { onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId) emit: SignalFileOperation.openNote(noteId, authorId)
popup.close()
} }
onCreateNote: function handle() { onCreateNote: function handle() {
emit: SignalFileOperation.createNote( emit: SignalFileOperation.createNote(content_page.fileId,
content_area.knowledgeFileId, content_area.type, content_area.type,
content_page.title) content_page.title)
popup.close()
} }
} }
} }
@ -92,8 +94,9 @@ 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 + "/detail", 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
@ -101,7 +104,7 @@ FluArea {
content_page.fileSize = data.knowledgeFileAttribute.size 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.fileId)
var tagString = "" var tagString = ""
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
@ -245,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
}) })
} }
} }
@ -351,7 +354,6 @@ FluArea {
FluMediaPlayer { FluMediaPlayer {
width: parent.width width: parent.width
height: 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

@ -25,6 +25,8 @@ FluArea {
property bool isModifying: false property bool isModifying: false
Component.onCompleted: { Component.onCompleted: {
console.log(knowledgeFileId)
isModifying = false
if (isModifying) { if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content", Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) { function (response, data) {
@ -137,7 +139,10 @@ FluArea {
text: "上传" text: "上传"
onClicked: { onClicked: {
if (noteTitle.trim() !== "" && noteContent !== "") { if (noteTitle.trim() !== "" && noteContent !== "") {
if (isModifying) { console.log(noteTitle)
console.log(noteContent)
console.log(knowledgeFileId)
if (!isModifying) {
Request.post("note", { Request.post("note", {
"title": noteTitle, "title": noteTitle,
"content": noteContent, "content": noteContent,

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: {
@ -46,7 +47,6 @@ FluArea {
property string publishTime: "2020-01-01" property string publishTime: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
property string uuid: "354"
property string fileTitle: "dfnfgf" property string fileTitle: "dfnfgf"
property string fileType: "OTHER" property string fileType: "OTHER"
@ -65,19 +65,37 @@ FluArea {
} }
Component.onCompleted: { Component.onCompleted: {
Request.getSearch("/", function (response, data) { Request.getSearch("note/" + noteFileId, function (response, data) {
note_page.uuid = data.id note_page.fileId = data.id
note_page.fileTitle = data.name note_page.fileTitle = data.name
note_page.fileType = getType(data.knowledgeFileAttribute.suffix) note_page.fileType = getType(data.knowledgeFileAttribute.suffix)
note_page.fileStars = 0 note_page.fileStars = 0
var tagString = "" var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { for (var j = 0; j < data.tags.length; j++) {
if (j != 0) if (j != 0)
tagString = tagString + "," tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name tagString = tagString + data.tags[j].name
} }
note_page.fileTags = tagString 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
}
}
}) })
} }
@ -103,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 {
@ -129,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
@ -148,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
@ -215,7 +256,7 @@ FluArea {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onDoubleClicked: { onDoubleClicked: {
emit: SignalFileOperation.open(note_page.uuid) emit: SignalFileOperation.open(note_page.fileId)
} }
} }
RowLayout { RowLayout {