diff --git a/AicsKnowledgeBase/qml/MainWindow.qml b/AicsKnowledgeBase/qml/MainWindow.qml index 9763a23..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 { @@ -107,17 +107,31 @@ FluWindow { "knowledgeFileId": file }) } - function onOpenNote(note) { + function onOpenNote(note, authorId) { stack_view.push(note_view, { - "noteFileId": note + "noteFileId": note, + "authorId": authorId }) } function onBack() { if (stack_view.depth > 0) stack_view.pop() } - function onCreateNote() { - stack_view.push(create_note_view) + function onCreateNote(file, fileType, fileTitle) { + 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 + }) } } diff --git a/AicsKnowledgeBase/qml/component/CustomAppBar.qml b/AicsKnowledgeBase/qml/component/CustomAppBar.qml index 56ead21..6285759 100644 --- a/AicsKnowledgeBase/qml/component/CustomAppBar.qml +++ b/AicsKnowledgeBase/qml/component/CustomAppBar.qml @@ -117,6 +117,20 @@ Rectangle { Layout.rightMargin: 10 iconSource: FluentIcons.PenPalette 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 { @@ -218,5 +232,6 @@ Rectangle { frameless_helper.setHitTestVisible(btn_maximize) frameless_helper.setHitTestVisible(btn_close) frameless_helper.setHitTestVisible(btn_transfer) + frameless_helper.setHitTestVisible(btn_note) } } diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index 5c17833..828ba1a 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -126,9 +126,15 @@ Item { return "OTHER" } RowLayout { - Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignRight + //Layout.preferredWidth: parent.width + layoutDirection: Qt.RightToLeft + UploadButton { + //Layout.alignment: Qt.AlignRight + header: header + } Item { - anchors.right: uploadBtn.left + //anchors.right: uploadBtn.left height: 28 width: 28 InputDialog { @@ -153,59 +159,14 @@ Item { } } - Image { - source: "qrc:/AicsKnowledgeBase/res/createFolder.png" - anchors.fill: parent - } - MouseArea { + FluIconButton { anchors.fill: parent + iconSource: FluentIcons.NewFolder onClicked: { 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 { id: fileListItemHeaderItem diff --git a/AicsKnowledgeBase/qml/component/FileListItem.qml b/AicsKnowledgeBase/qml/component/FileListItem.qml index f4f2713..67b234a 100644 --- a/AicsKnowledgeBase/qml/component/FileListItem.qml +++ b/AicsKnowledgeBase/qml/component/FileListItem.qml @@ -84,43 +84,40 @@ FluArea { } } - ColumnLayout { - id: row - anchors.fill: parent - anchors.margins: 10 - spacing: 10 + MouseArea { + anchors.fill: row + acceptedButtons: Qt.LeftButton | Qt.RightButton + onDoubleClicked: { + fileItem.parent.doubleClicked() + } + onClicked: { + if (mouse.button === Qt.RightButton) { + menu.popup() + } + } + } - ColumnLayout { - id: clickable - anchors.fill: parent - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onDoubleClicked: { - fileItem.parent.doubleClicked() - } - onClicked: { - if (mouse.button === Qt.RightButton) { - menu.popup() - } - } + ColumnLayout { + id: clickable + anchors.fill: row + + RowLayout { + id: titleRow + Image { + id: icon + source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : "" + Layout.preferredHeight: 24 + Layout.preferredWidth: 24 + fillMode: Image.PreserveAspectFit } - 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 - textFormat: Text.RichText - } + FluText { + id: title + font.bold: true + font.pointSize: 12 + text: fileItem.title + textFormat: Text.RichText } + } FluText { id: brief diff --git a/AicsKnowledgeBase/qml/component/NoteList.qml b/AicsKnowledgeBase/qml/component/NoteList.qml index 539c917..b1e8031 100644 --- a/AicsKnowledgeBase/qml/component/NoteList.qml +++ b/AicsKnowledgeBase/qml/component/NoteList.qml @@ -5,7 +5,7 @@ import "qrc:///AicsKnowledgeBase/qml/global" Item { anchors.fill: parent - signal open(string note) + signal open(string note, string authorId) signal createNote width: parent.width - 8 property ListModel noteListModel: ListModel { @@ -14,6 +14,7 @@ Item { title: "超级无敌报错" brief: "file:///D:/academic/2023-qtBig/AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/NoteList.qml:41:21: Unable to assign [undefined] to QString" author: "admin" + authorId: "345" pageView: 123 stars: 27 date: "2022-02-02" @@ -23,6 +24,7 @@ Item { title: "Qt布局" brief: "锚定(anchors)在确定父子组件之间,同级组件之间的相对位置时非常常用,若使用锚定方式确定子组件与父组件之间的位置关系,使用 top,bottom,left,right, topMargin,bottomMargin,leftMargin,rightMargin进行上下左右对齐,以及对齐后的留白距离。若要使子组件在父组件的水平,垂直居中,使用:" author: "超级无敌长的账户名" + authorId: "345" pageView: 123 stars: 27 date: "2022-02-02" @@ -32,6 +34,7 @@ Item { title: "Qt布局" brief: "锚定(anchors)在确定父子组件之间,同级组件之间的相对位置时非常常用,若使用锚定方式确定子组件与父组件之间的位置关系,使用 top,bottom,left,right, topMargin,bottomMargin,leftMargin,rightMargin进行上下左右对齐,以及对齐后的留白距离。若要使子组件在父组件的水平,垂直居中,使用:" author: "超级无敌长的账户名" + authorId: "345" pageView: 123 stars: 27 date: "2022-02-02" @@ -41,6 +44,7 @@ Item { title: "Qt布局" brief: "锚定(anchors)在确定父子组件之间,同级组件之间的相对位置时非常常用,若使用锚定方式确定子组件与父组件之间的位置关系,使用 top,bottom,left,right, topMargin,bottomMargin,leftMargin,rightMargin进行上下左右对齐,以及对齐后的留白距离。若要使子组件在父组件的水平,垂直居中,使用:" author: "超级无敌长的账户名" + authorId: "345" pageView: 123 stars: 27 date: "2022-02-02" @@ -87,7 +91,7 @@ Item { MouseArea { anchors.fill: parent onClicked: { - open(model.uuid) + open(model.uuid, model.authorId) } } NoteListItem { @@ -100,6 +104,7 @@ Item { brief: model.brief pageView: model.pageView author: model.author + authorId: model.authorId stars: model.stars } } diff --git a/AicsKnowledgeBase/qml/component/NoteListItem.qml b/AicsKnowledgeBase/qml/component/NoteListItem.qml index 9eaba75..28d8297 100644 --- a/AicsKnowledgeBase/qml/component/NoteListItem.qml +++ b/AicsKnowledgeBase/qml/component/NoteListItem.qml @@ -11,6 +11,7 @@ FluArea { property int pageView property int stars property string author + property string authorId ColumnLayout { id: row diff --git a/AicsKnowledgeBase/qml/component/Tag.qml b/AicsKnowledgeBase/qml/component/Tag.qml index 5a609ab..b6f85c8 100644 --- a/AicsKnowledgeBase/qml/component/Tag.qml +++ b/AicsKnowledgeBase/qml/component/Tag.qml @@ -16,30 +16,32 @@ Rectangle { radius: 5 clip: true - ListModel { id: tagListModel } + ListModel { + id: tagListModel + } property ListModel tagList: tagListModel - property var tagMap:[] - property var presetsTags:[] - property var presetsTagsItem:[] + property var tagMap: [] + property var presetsTags: [] + property var presetsTagsItem: [] Component.onCompleted: { - Request.get("tag?name", - function(result, data){ -// console.log("success") -// console.log(result) -// console.log(data.length) - for(var i =0;i tags: ["tag 1", "tag 2", "tag 3"] @@ -74,6 +79,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,15 +94,17 @@ FluArea { function loadFile(knowledgeFileId) { content_area.knowledgeFileId = knowledgeFileId console.log(knowledgeFileId) - Request.get("knowledge/" + knowledgeFileId, + 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 + content_page.suffix = data.knowledgeFileAttribute.suffix + content_page.fileSize = data.knowledgeFileAttribute.size - content_area.type = getType( - data.knowledgeFileAttribute.suffix) - console.log(content_area.type) + content_area.type = getType(content_page.suffix) + console.log(content_area.fileId) var tagString = "" for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) { @@ -109,19 +117,40 @@ 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, + "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) 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", @@ -219,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 }) } } @@ -249,7 +278,7 @@ FluArea { FileTransferManager.download(content_page.fileId, content_page.title) else { - + FileTransferManager.openLocalFile(content_page.title) } } } @@ -267,9 +296,10 @@ FluArea { } FluText { padding: 10 - text: fileSize > 1024 * 1024 ? (fileSize / 1024 / 1024).toFixed( - 2) + "MB" : (fileSize / 1024).toFixed( - 2) + "KB" + text: content_page.fileSize > 1024 + * 1024 ? (content_page.fileSize / 1024 / 1024).toFixed( + 2) + "MB" : (content_page.fileSize / 1024).toFixed( + 2) + "KB" } FluText { padding: 10 @@ -316,13 +346,14 @@ 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. } } Component { diff --git a/AicsKnowledgeBase/qml/page/CreateNotePage.qml b/AicsKnowledgeBase/qml/page/CreateNotePage.qml index ba3fd62..9f8f496 100644 --- a/AicsKnowledgeBase/qml/page/CreateNotePage.qml +++ b/AicsKnowledgeBase/qml/page/CreateNotePage.qml @@ -15,10 +15,29 @@ FluArea { id: edit_area paddings: 0 backgroundColor: "#f9f9f9" - property string noteTitle - property string noteContent + property string knowledgeFileId + 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: { + 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 () { return input_title.text }) @@ -34,14 +53,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.knowledgeFileId) + } + } + 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 { @@ -62,6 +109,7 @@ FluArea { padding: 10 placeholderText: "单行输入框" implicitWidth: parent.width + font.pointSize: 12 } } } @@ -90,12 +138,33 @@ FluArea { FluFilledButton { text: "上传" onClicked: { - console.log(noteTitle) - console.log(noteContent) + if (noteTitle.trim() !== "" && noteContent !== "") { + console.log(noteTitle) + 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 { text: "取消" + onClicked: { + emit: SignalFileOperation.back() + } } } } diff --git a/AicsKnowledgeBase/qml/page/NotePage.qml b/AicsKnowledgeBase/qml/page/NotePage.qml index d2fe8c5..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: { @@ -41,12 +42,14 @@ FluArea { property int browsCount: 555 property bool isLike: false property bool isFavorite: false - property double fileSize: 455 property string title: "文章标题" property list tags: ["tag 1", "tag 2", "tag 3"] property string publishTime: "2020-01-01" property string brief: "这是一个简介" + property string fileTitle: "dfnfgf" + property string fileType: "OTHER" + function getType(suffix) { if (suffix === "md") return "MD" @@ -62,7 +65,38 @@ FluArea { } 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 { @@ -87,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 { @@ -113,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 @@ -132,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 @@ -149,7 +206,7 @@ FluArea { FluArea { Layout.fillWidth: true - implicitHeight: 100 + implicitHeight: 140 ColumnLayout { RowLayout { 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 { id: text_view noteId: "255454" width: parent.width - implicitHeight: 400 + implicitHeight: width * 9 / 16 } } } diff --git a/AicsKnowledgeBase/res/FOLDER.png b/AicsKnowledgeBase/res/FOLDER.png index 799762c..27eda1d 100644 Binary files a/AicsKnowledgeBase/res/FOLDER.png and b/AicsKnowledgeBase/res/FOLDER.png differ diff --git a/AicsKnowledgeBase/res/MUSIC.png b/AicsKnowledgeBase/res/MUSIC.png new file mode 100644 index 0000000..592e25e Binary files /dev/null and b/AicsKnowledgeBase/res/MUSIC.png differ diff --git a/AicsKnowledgeBase/res/OTHER.png b/AicsKnowledgeBase/res/OTHER.png index 54a10d1..27ec62e 100644 Binary files a/AicsKnowledgeBase/res/OTHER.png and b/AicsKnowledgeBase/res/OTHER.png differ diff --git a/AicsKnowledgeBase/res/PDF.png b/AicsKnowledgeBase/res/PDF.png index 1505a76..eb859a0 100644 Binary files a/AicsKnowledgeBase/res/PDF.png and b/AicsKnowledgeBase/res/PDF.png differ diff --git a/AicsKnowledgeBase/res/PPT.png b/AicsKnowledgeBase/res/PPT.png index 8b0ec43..1bcb838 100644 Binary files a/AicsKnowledgeBase/res/PPT.png and b/AicsKnowledgeBase/res/PPT.png differ diff --git a/AicsKnowledgeBase/res/VIDEO.png b/AicsKnowledgeBase/res/VIDEO.png index 3d8536c..72783c6 100644 Binary files a/AicsKnowledgeBase/res/VIDEO.png and b/AicsKnowledgeBase/res/VIDEO.png differ diff --git a/AicsKnowledgeBase/res/WORD.png b/AicsKnowledgeBase/res/WORD.png index c381412..f34418d 100644 Binary files a/AicsKnowledgeBase/res/WORD.png and b/AicsKnowledgeBase/res/WORD.png differ diff --git a/AicsKnowledgeBase/src/FileTransferListModel.cpp b/AicsKnowledgeBase/src/FileTransferListModel.cpp index 46644e4..069efa8 100644 --- a/AicsKnowledgeBase/src/FileTransferListModel.cpp +++ b/AicsKnowledgeBase/src/FileTransferListModel.cpp @@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent) m_roleName.insert(kSpeedRole, "speed"); m_roleName.insert(kPausedRole, "paused"); - m_data.append({true, "id", "name", 30, 100, 30}); + //m_data.append({true, "id", "name", 30, 100, 30}); }