From d27ed8ede04c85281682a53c3fdaae2e5817f3b1 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Fri, 7 Jul 2023 00:24:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qml/component/FileListItem.qml | 15 +- AicsKnowledgeBase/qml/page/AudioPage.qml | 75 ++++++++- AicsKnowledgeBase/qml/page/DocumentPage.qml | 74 +++++++++ AicsKnowledgeBase/qml/page/NotePage.qml | 37 ----- AicsKnowledgeBase/qml/page/SearchPage.qml | 154 +++++++++++------- AicsKnowledgeBase/qml/page/VideoPage.qml | 74 +++++++++ 6 files changed, 329 insertions(+), 100 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileListItem.qml b/AicsKnowledgeBase/qml/component/FileListItem.qml index f8e89ce..68c7053 100644 --- a/AicsKnowledgeBase/qml/component/FileListItem.qml +++ b/AicsKnowledgeBase/qml/component/FileListItem.qml @@ -37,12 +37,15 @@ FluArea { message: fileItem.title onPositiveClicked: text => { var param = { - "name": text, - "parentId": fuuid + "parentId": fileItem.fuuid, + "name": text } - Request.post("/knowledge", - JSON.stringify(param)) - refresh() + console.log(JSON.stringify(param)) + Request.put( + "/knowledge/" + fileItem.uuid, + JSON.stringify(param), () => { + refresh() + }) } } } @@ -63,6 +66,7 @@ FluArea { "parentId": uuid, "name": fileItem.title } + console.log(JSON.stringify(param)) Request.put( "/knowledge/" + fileItem.uuid, JSON.stringify(param), () => { @@ -114,6 +118,7 @@ FluArea { font.bold: true font.pointSize: 12 text: fileItem.title + textFormat: Text.RichText } } diff --git a/AicsKnowledgeBase/qml/page/AudioPage.qml b/AicsKnowledgeBase/qml/page/AudioPage.qml index b58495f..91b533c 100644 --- a/AicsKnowledgeBase/qml/page/AudioPage.qml +++ b/AicsKnowledgeBase/qml/page/AudioPage.qml @@ -4,18 +4,91 @@ import QtQuick.Window import QtQuick.Controls import QtQuick.Controls.Basic import FluentUI +import "qrc:///AicsKnowledgeBase/qml/component" +import "qrc:///AicsKnowledgeBase/qml/global" FluArea { property string url: '' backgroundColor: "#f9f9f9" - Layout.fillWidth: true Layout.fillHeight: true paddings: 10 Layout.topMargin: 20 FluText { + id: title Layout.topMargin: 20 text: "Audio" } + FileList { + anchors.top: title.bottom + disableHeader: true + width: parent.width + dataModel: listModel + } + ListModel { + id: listModel + } + Component.onCompleted: { + Request.get("/knowledge?type=AUDIO", response => { + var files = JSON.parse(response) + listModel.clear() + for (var i = 0; i < files.length; i++) { + var file = files[i] + console.log(file.name) + var modelItem = { + "title": file.name, + "uuid": file.id, + "date"// cut time after 'T' + : file.createTime.substring(0, 10), + "fuuid": "0" + } + if (file.knowledgeFileAttribute === null) { + modelItem.type = "folder" + modelItem.isDir = true + modelItem.size = 0 + } else { + modelItem.isDir = false + modelItem.type = getType( + file.knowledgeFileAttribute.suffix) + modelItem.size = file.knowledgeFileAttribute.size + modelItem.brief = file.knowledgeFileAttribute.brief + modelItem.pageView = file.knowledgeFileAttribute.pageView + modelItem.stars = 0 + var tagString = "" + for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + file.knowledgeFileAttribute.tags[j].name + } + modelItem.tags = tagString + } + listModel.append(modelItem) + } + }) + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" || suffix === "jpeg" + || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } } diff --git a/AicsKnowledgeBase/qml/page/DocumentPage.qml b/AicsKnowledgeBase/qml/page/DocumentPage.qml index b4939f9..929b5eb 100644 --- a/AicsKnowledgeBase/qml/page/DocumentPage.qml +++ b/AicsKnowledgeBase/qml/page/DocumentPage.qml @@ -4,6 +4,8 @@ import QtQuick.Window import QtQuick.Controls import QtQuick.Controls.Basic import FluentUI +import "qrc:///AicsKnowledgeBase/qml/component" +import "qrc:///AicsKnowledgeBase/qml/global" FluArea { property string url: '' @@ -14,7 +16,79 @@ FluArea { Layout.topMargin: 20 FluText { + id: title Layout.topMargin: 20 text: "Document" } + FileList { + anchors.top: title.bottom + disableHeader: true + width: parent.width + dataModel: listModel + } + ListModel { + id: listModel + } + Component.onCompleted: { + Request.get("/knowledge?type=DOCUMENT", response => { + var files = JSON.parse(response) + listModel.clear() + for (var i = 0; i < files.length; i++) { + var file = files[i] + console.log(file.name) + var modelItem = { + "title": file.name, + "uuid": file.id, + "date"// cut time after 'T' + : file.createTime.substring(0, 10), + "fuuid": "0" + } + if (file.knowledgeFileAttribute === null) { + modelItem.type = "folder" + modelItem.isDir = true + modelItem.size = 0 + } else { + modelItem.isDir = false + modelItem.type = getType( + file.knowledgeFileAttribute.suffix) + modelItem.size = file.knowledgeFileAttribute.size + modelItem.brief = file.knowledgeFileAttribute.brief + modelItem.pageView = file.knowledgeFileAttribute.pageView + modelItem.stars = 0 + var tagString = "" + for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + file.knowledgeFileAttribute.tags[j].name + } + modelItem.tags = tagString + } + listModel.append(modelItem) + } + }) + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" || suffix === "jpeg" + || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } } diff --git a/AicsKnowledgeBase/qml/page/NotePage.qml b/AicsKnowledgeBase/qml/page/NotePage.qml index 2540182..d2fe8c5 100644 --- a/AicsKnowledgeBase/qml/page/NotePage.qml +++ b/AicsKnowledgeBase/qml/page/NotePage.qml @@ -46,7 +46,6 @@ FluArea { property list tags: ["tag 1", "tag 2", "tag 3"] property string publishTime: "2020-01-01" property string brief: "这是一个简介" - property var fromFile function getType(suffix) { if (suffix === "md") @@ -63,29 +62,7 @@ FluArea { } Component.onCompleted: { - Request.get("knowledge/", function (response, data) { - fromFile = { - "uuid": data.id, - "fuuid": data.knowledgeFileAttribute.id, - "title": data.name, - "date": data.createTime, - "brief": data.knowledgeFileAttribute.brief, - "suffix": data.knowledgeFileAttribute.suffix, - "type": getType(data.knowledgeFileAttribute.suffix), - "pageView": data.knowledgeFileAttribute.pageView, - "size": data.knowledgeFileAttribute.size - } - fromFile.stars = 0 - - var tagString = "" - for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { - if (j != 0) - tagString = tagString + "," - tagString = tagString + file.knowledgeFileAttribute.tags[j].name - } - fromFile.tags = tagString - }) } FluIconButton { @@ -222,19 +199,5 @@ FluArea { width: parent.width implicitHeight: 400 } - // FistListItem { - // id: fileListItem - // uuid: fromFile.uuid - // fuuid: fromFile.fuuid - // title: fromFile.title - // date: fromFile.date - // brief: fromFile.brief - // type: fromFile.type - // pageView: fromFile.pageView - // size: fromFile.size - // stars: fromFile.stars - // tags: fromFile.tags === null || fromFile.tags === undefined - // || fromFile.tags === "" ? [] : fromFile.tags.split(",") - // } } } diff --git a/AicsKnowledgeBase/qml/page/SearchPage.qml b/AicsKnowledgeBase/qml/page/SearchPage.qml index 56cad27..773c728 100644 --- a/AicsKnowledgeBase/qml/page/SearchPage.qml +++ b/AicsKnowledgeBase/qml/page/SearchPage.qml @@ -8,6 +8,7 @@ import "qrc:///AicsKnowledgeBase/qml/global" import "qrc:///AicsKnowledgeBase/qml/component" FluArea { + id: searchPage property string url: '' backgroundColor: "#f9f9f9" Layout.fillHeight: true @@ -19,14 +20,17 @@ FluArea { // Layout.topMargin: 20 // text: "Search" // } + + /* 按标题,内容搜索 */ - ColumnLayout{ + ColumnLayout { width: parent.width - RowLayout{ - width:parent.width + RowLayout { + width: parent.width + // FluDropDownButton{ // id:select_model // Layout.alignment: Qt.AlignLeft @@ -52,105 +56,100 @@ FluArea { // } // ] // } - - FluTextBox{ - placeholderText:"对标题进行搜索……" + FluTextBox { + placeholderText: "对标题进行搜索……" Layout.fillWidth: true - } - FluIconButton{ + FluIconButton { Layout.alignment: Qt.AlignRight - iconSource:FluentIcons.Search - onClicked:{ + iconSource: FluentIcons.Search + onClicked: { var allTags = inputTags.getAllTags(tags.tagList) - var allTagId =[] + var allTagId = [] console.log(allTags) for (var i = 0; i < allTags.length; i++) { var url = "?name=" url = url + allTags[i] console.log(url) - Request.get(url, - function(result, data){ - allTagId.push() - } - - ) + Request.get(url, function (result, data) { + allTagId.push() + }) } } } - } - FluCheckBox{ - id:searchTitleAndContent - text:"同时搜索简介和内容" + FluCheckBox { + id: searchTitleAndContent + text: "同时搜索简介和内容" } //按文件类型 - RowLayout{ - id:selectFormat - width:parent.width - FluText{ + RowLayout { + id: selectFormat + width: parent.width + FluText { Layout.alignment: Qt.AlignLeft - text:"类型: " + text: "类型: " } - FluCheckBox{ - id:selectAllFormat - text:"all" - Component.onCompleted:{ + FluCheckBox { + id: selectAllFormat + text: "all" + Component.onCompleted: { clicked() } - onClicked:{ - selectVideo.checked=true - selectDoc.checked=true - selectAudio.checked=true + onClicked: { + selectVideo.checked = true + selectDoc.checked = true + selectAudio.checked = true } } - FluCheckBox{ - id:selectVideo - text:"Video" - onClicked:{ + FluCheckBox { + id: selectVideo + text: "Video" + onClicked: { selectFormat.setAllStatus() } } - FluCheckBox{ - id:selectDoc - text:"Doc" - onClicked:{ + FluCheckBox { + id: selectDoc + text: "Doc" + onClicked: { selectFormat.setAllStatus() } } - FluCheckBox{ - id:selectAudio - text:"Audio" - onClicked:{ + FluCheckBox { + id: selectAudio + text: "Audio" + onClicked: { selectFormat.setAllStatus() } } function setAllStatus() { - selectAllFormat.checked = selectVideo.checked && selectDoc.checked && selectAudio.checked + selectAllFormat.checked = selectVideo.checked + && selectDoc.checked && selectAudio.checked } } - RowLayout{ - id:inputTags - width:parent.width + RowLayout { + id: inputTags + width: parent.width height: 32 - FluText{ + FluText { Layout.alignment: Qt.AlignLeft - text:"标签: " + text: "标签: " } - Tag{ - id:tags + Tag { + id: tags width: 290 } - function getAllTags(tagList){ - var allTags=[]; + function getAllTags(tagList) { + var allTags = [] for (var i = 0; i < tagList.count; i++) { - var item = tagList.get(i); + var item = tagList.get(i) allTags.push(item.tag) } return allTags @@ -200,4 +199,45 @@ FluArea { } } } + function getKnowledgeDetail(uuid, title, brief, tags) { + var raw = Request.getAwait("/knowledget/" + uuid) + var data = JSON.parse(raw) + var item = { + "uuid": uuid, + "title": title, + "brief": brief, + "isDir": false, + "date": data.createTime, + "fuuid": data.parent.id, + "pageView": data.knowledgeFileAttribute.pageView, + "stars": data.knowledgeFileAttribute.stars, + "size": data.knowledgeFileAttribute.size, + "type": getType(data.knowledgeFileAttribute.suffix), + "tags": tags + } + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" || suffix === "jpeg" + || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } } diff --git a/AicsKnowledgeBase/qml/page/VideoPage.qml b/AicsKnowledgeBase/qml/page/VideoPage.qml index 52d56b9..ebb20fe 100644 --- a/AicsKnowledgeBase/qml/page/VideoPage.qml +++ b/AicsKnowledgeBase/qml/page/VideoPage.qml @@ -4,6 +4,8 @@ import QtQuick.Window import QtQuick.Controls import QtQuick.Controls.Basic import FluentUI +import "qrc:///AicsKnowledgeBase/qml/component" +import "qrc:///AicsKnowledgeBase/qml/global" FluArea { property string url: '' @@ -14,7 +16,79 @@ FluArea { Layout.topMargin: 20 FluText { + id: title Layout.topMargin: 20 text: "Video" } + FileList { + anchors.top: title.bottom + disableHeader: true + width: parent.width + dataModel: listModel + } + ListModel { + id: listModel + } + Component.onCompleted: { + Request.get("/knowledge?type=VIDEO", response => { + var files = JSON.parse(response) + listModel.clear() + for (var i = 0; i < files.length; i++) { + var file = files[i] + console.log(file.name) + var modelItem = { + "title": file.name, + "uuid": file.id, + "date"// cut time after 'T' + : file.createTime.substring(0, 10), + "fuuid": "0" + } + if (file.knowledgeFileAttribute === null) { + modelItem.type = "folder" + modelItem.isDir = true + modelItem.size = 0 + } else { + modelItem.isDir = false + modelItem.type = getType( + file.knowledgeFileAttribute.suffix) + modelItem.size = file.knowledgeFileAttribute.size + modelItem.brief = file.knowledgeFileAttribute.brief + modelItem.pageView = file.knowledgeFileAttribute.pageView + modelItem.stars = 0 + var tagString = "" + for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + file.knowledgeFileAttribute.tags[j].name + } + modelItem.tags = tagString + } + listModel.append(modelItem) + } + }) + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" || suffix === "jpeg" + || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb" + || suffix === "rm" || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } }