From abec8f55f190095bd8787009c926a33f91aeb577 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Fri, 7 Jul 2023 03:21:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A4=A7=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/MainWindow.qml | 9 ++-- AicsKnowledgeBase/qml/page/ContentPage.qml | 16 +++--- AicsKnowledgeBase/qml/page/CreateNotePage.qml | 7 ++- AicsKnowledgeBase/qml/page/NotePage.qml | 53 ++++++++++++++++--- 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/AicsKnowledgeBase/qml/MainWindow.qml b/AicsKnowledgeBase/qml/MainWindow.qml index 4da2a86..7b6edfb 100644 --- a/AicsKnowledgeBase/qml/MainWindow.qml +++ b/AicsKnowledgeBase/qml/MainWindow.qml @@ -95,7 +95,7 @@ FluWindow { duration: 200 } } - initialItem: create_note_view + initialItem: note_view } Connections { @@ -118,18 +118,19 @@ FluWindow { stack_view.pop() } function onCreateNote(file, fileType, fileTitle) { - 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, { + stack_view.push(create_note_view, { "knowledgeFileId": file, "fileType": fileType, "fileTitle": fileTitle, - "noteId": note + "noteId": note, + "isModifying": true }) } } diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index 0afe1b6..2a23609 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -31,11 +31,13 @@ FluArea { noteListModel: content_page.noteListModel onOpen: function handle(noteId, authorId) { emit: SignalFileOperation.openNote(noteId, authorId) + popup.close() } onCreateNote: function handle() { - emit: SignalFileOperation.createNote( - content_area.knowledgeFileId, content_area.type, - content_page.title) + emit: SignalFileOperation.createNote(content_page.fileId, + content_area.type, + content_page.title) + popup.close() } } } @@ -92,8 +94,9 @@ FluArea { function loadFile(knowledgeFileId) { content_area.knowledgeFileId = knowledgeFileId console.log(knowledgeFileId) - Request.get("knowledge/" + knowledgeFileId + "/detail", + Request.get("knowledge/" + knowledgeFileId + "/detailed", function (response, data) { + console.log(response) content_page.publishTime = data.createTime content_page.title = data.name content_page.fileId = data.knowledgeFileAttribute.id @@ -101,7 +104,7 @@ FluArea { content_page.fileSize = data.knowledgeFileAttribute.size content_area.type = getType(content_page.suffix) - console.log(content_area.type) + console.log(content_area.fileId) var tagString = "" for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { @@ -245,7 +248,7 @@ FluArea { content_page.isFavorite = !content_page.isFavorite content_page.favoriteCount += 1 Request.put("knowledge/" + knowledgeFileId + "/star", { - "active": UserData.userId + "active": content_page.isFavorite }) } } @@ -351,7 +354,6 @@ FluArea { FluMediaPlayer { width: parent.width height: width * 9 / 16. - source: "https://api.hammer-hfut.tk:233/aics/file/static/3f28fea9-27f1-4a85-9d3e-def187c4456e.mp4" } } Component { diff --git a/AicsKnowledgeBase/qml/page/CreateNotePage.qml b/AicsKnowledgeBase/qml/page/CreateNotePage.qml index b33fb13..9f8f496 100644 --- a/AicsKnowledgeBase/qml/page/CreateNotePage.qml +++ b/AicsKnowledgeBase/qml/page/CreateNotePage.qml @@ -25,6 +25,8 @@ FluArea { property bool isModifying: false Component.onCompleted: { + console.log(knowledgeFileId) + isModifying = false if (isModifying) { Request.getSearch("/search/note/" + noteFileId + "/content", function (response, data) { @@ -137,7 +139,10 @@ FluArea { text: "上传" onClicked: { if (noteTitle.trim() !== "" && noteContent !== "") { - if (isModifying) { + console.log(noteTitle) + console.log(noteContent) + console.log(knowledgeFileId) + if (!isModifying) { Request.post("note", { "title": noteTitle, "content": noteContent, diff --git a/AicsKnowledgeBase/qml/page/NotePage.qml b/AicsKnowledgeBase/qml/page/NotePage.qml index 0a413cf..e358b9f 100644 --- a/AicsKnowledgeBase/qml/page/NotePage.qml +++ b/AicsKnowledgeBase/qml/page/NotePage.qml @@ -18,6 +18,7 @@ FluArea { // visible: false property string type: "" property string noteFileId + property string authorId signal clickTags(string tagName) // paddings: { @@ -46,7 +47,6 @@ FluArea { property string publishTime: "2020-01-01" property string brief: "这是一个简介" - property string uuid: "354" property string fileTitle: "dfnfgf" property string fileType: "OTHER" @@ -65,19 +65,37 @@ FluArea { } Component.onCompleted: { - Request.getSearch("/", function (response, data) { - note_page.uuid = data.id + 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 < file.knowledgeFileAttribute.tags.length; j++) { + for (var j = 0; j < data.tags.length; j++) { if (j != 0) tagString = tagString + "," - tagString = tagString + file.knowledgeFileAttribute.tags[j].name + 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 + } + } }) } @@ -103,6 +121,17 @@ FluArea { 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 { id: layout_share FluIconButton { @@ -129,6 +158,12 @@ FluArea { id: button_favorite iconSize: 15 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 { id: text_favorite @@ -148,6 +183,12 @@ FluArea { id: button_like iconSize: 15 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 { id: text_like @@ -215,7 +256,7 @@ FluArea { MouseArea { anchors.fill: parent onDoubleClicked: { - emit: SignalFileOperation.open(note_page.uuid) + emit: SignalFileOperation.open(note_page.fileId) } } RowLayout {