From 0e886e1489e1389a7b927de1e785017d5a10cb14 Mon Sep 17 00:00:00 2001 From: wuyize Date: Fri, 7 Jul 2023 05:54:08 +0800 Subject: [PATCH] complete --- AicsKnowledgeBase/qml/MainWindow.qml | 8 +- AicsKnowledgeBase/qml/page/ContentPage.qml | 7 +- AicsKnowledgeBase/qml/page/CreateNotePage.qml | 38 +++--- AicsKnowledgeBase/qml/page/NoteEditPage.qml | 2 - AicsKnowledgeBase/qml/page/NotePage.qml | 110 +++++++++++------- 5 files changed, 96 insertions(+), 69 deletions(-) diff --git a/AicsKnowledgeBase/qml/MainWindow.qml b/AicsKnowledgeBase/qml/MainWindow.qml index 7b6edfb..eab537c 100644 --- a/AicsKnowledgeBase/qml/MainWindow.qml +++ b/AicsKnowledgeBase/qml/MainWindow.qml @@ -95,7 +95,6 @@ FluWindow { duration: 200 } } - initialItem: note_view } Connections { @@ -108,6 +107,8 @@ FluWindow { }) } function onOpenNote(note, authorId) { + console.log(note) + console.log(authorId) stack_view.push(note_view, { "noteFileId": note, "authorId": authorId @@ -118,6 +119,9 @@ FluWindow { stack_view.pop() } function onCreateNote(file, fileType, fileTitle) { + console.log(file) + console.log(fileType) + console.log(fileTitle) stack_view.push(create_note_view, { "knowledgeFileId": file, "fileType": fileType, @@ -129,7 +133,7 @@ FluWindow { "knowledgeFileId": file, "fileType": fileType, "fileTitle": fileTitle, - "noteId": note, + "noteFileId": note, "isModifying": true }) } diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index fd11472..6d13f85 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -260,10 +260,9 @@ FluArea { content_page.isFavorite = !content_page.isFavorite console.log(content_page.isFavorite) content_page.favoriteCount += (content_page.isFavorite ? 1 : -1) - Request.put("knowledge/" + knowledgeFileId + "/star", - JSON.stringify({ - "active": content_page.isFavorite - }), response => { + Request.put("knowledge/" + knowledgeFileId + "/star", { + "active": content_page.isFavorite + }, response => { console.log(response) }, response => { console.log(response) diff --git a/AicsKnowledgeBase/qml/page/CreateNotePage.qml b/AicsKnowledgeBase/qml/page/CreateNotePage.qml index 8936036..42bc6a7 100644 --- a/AicsKnowledgeBase/qml/page/CreateNotePage.qml +++ b/AicsKnowledgeBase/qml/page/CreateNotePage.qml @@ -30,10 +30,8 @@ FluArea { 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 + input_title.text = data.title + input_md.contentMd = data.content tags = data.tags }) } @@ -94,22 +92,24 @@ FluArea { Item { Layout.fillWidth: true implicitHeight: 50 - RowLayout { - Layout.fillWidth: true - FluText { - padding: 10 - text: "标题" - font { - pointSize: 15 - bold: true - } + FluText { + id: text_title + padding: 10 + text: "标题" + font { + pointSize: 15 + bold: true } - FluTextBox { - id: input_title - padding: 10 - placeholderText: "单行输入框" - implicitWidth: parent.width - font.pointSize: 12 + } + FluTextBox { + id: input_title + padding: 10 + placeholderText: "单行输入框" + implicitWidth: parent.width + font.pointSize: 12 + anchors { + left: text_title.right + verticalCenter: text_title.verticalCenter } } } diff --git a/AicsKnowledgeBase/qml/page/NoteEditPage.qml b/AicsKnowledgeBase/qml/page/NoteEditPage.qml index 5d88ceb..90d5b12 100644 --- a/AicsKnowledgeBase/qml/page/NoteEditPage.qml +++ b/AicsKnowledgeBase/qml/page/NoteEditPage.qml @@ -180,7 +180,6 @@ FluArea { id: textArea_edit wrapMode: TextEdit.Wrap background: Rectangle { - color: customTextArea.focus ? "#E0E0E0" : "white" border.color: FluColors.Grey30 radius: 10 } @@ -197,7 +196,6 @@ FluArea { wrapMode: TextEdit.Wrap textFormat: TextEdit.MarkdownText background: Rectangle { - color: customTextArea.focus ? "#E0E0E0" : "white" border.color: FluColors.Grey30 radius: 10 } diff --git a/AicsKnowledgeBase/qml/page/NotePage.qml b/AicsKnowledgeBase/qml/page/NotePage.qml index 30cb9ba..e4d2a5c 100644 --- a/AicsKnowledgeBase/qml/page/NotePage.qml +++ b/AicsKnowledgeBase/qml/page/NotePage.qml @@ -21,6 +21,67 @@ FluArea { property string authorId signal clickTags(string tagName) + function getType(suffix) { + if (suffix === "md") + return "MD" + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } + + function loadNote() { + console.log(noteFileId) + Request.get("note/" + noteFileId, function (response) { + var data = JSON.parse(response) + console.log(response) + note_page.fileId = data.id + note_page.fileTitle = data.knowledgeFiles[0].knowledge.name + note_page.fileType = getType(data.knowledgeFiles[0].suffix) + note_page.favoriteCount = 0 + note_page.title = data.title + note_page.publishTime = data.createTime + note_page.browsCount = data.pageView + + var tagString = "" + for (var j = 0; j < data.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + data.tags[j].name + } + note_page.tags = tagString.split(",") + + note_page.likeCount = data.likers.length + note_page.isLike = false + for (var j = 0; j < data.likers.length; j++) { + if (data.likers[j].id === UserData.userId) { + isLike = true + break + } + } + + note_page.favoriteCount = data.starers.length + note_page.isFavorite = false + for (var j = 0; j < data.starers.length; j++) { + if (data.starers[j].id === UserData.userId) { + isFavorite = true + break + } + } + + Request.getSearch("search/note/" + noteFileId + "/content", + response => { + text_view.contentMd = response + note_page.brief = response + }) + }) + } + + Component.onCompleted: { + loadNote() + } + // paddings: { // top: 10 // right: 0 @@ -42,7 +103,7 @@ FluArea { property int browsCount: 555 property bool isLike: false property bool isFavorite: false - property string title: "文章标题" + property string title property list tags: ["tag 1", "tag 2", "tag 3"] property string publishTime: "2020-01-01" property string brief: "这是一个简介" @@ -64,41 +125,6 @@ FluArea { note_area.noteFileId = noteFileId } - 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 { iconSize: 12 iconSource: FluentIcons.Back @@ -123,14 +149,18 @@ FluArea { } FluIconButton { id: button_edit_note - iconSize: FluentIcons.Edit - visible: authorId === UserData.userId + iconSource: FluentIcons.Edit + visible: note_area.authorId.toString() == UserData.userId onClicked: { emit: SignalFileOperation.modifyNote(note_page.fileId, note_page.fileType, note_page.fileTitle, noteFileId) } + anchors { + left: text_title.right + verticalCenter: text_title.verticalCenter + } } ColumnLayout { id: layout_share @@ -216,10 +246,6 @@ FluArea { padding: 10 text: note_page.publishTime.substring(0, 10) } - FluText { - padding: 10 - text: note_page.fileSize.toString() + "MB" - } FluText { padding: 10 text: note_page.browsCount.toString() + "浏览量"