From 0014cc018a1f857e426020956963c8f1b5f3a38f Mon Sep 17 00:00:00 2001 From: wuyize Date: Wed, 5 Jul 2023 21:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 95 ++++++++++++++------ AicsKnowledgeBase/qml/page/FilePage.qml | 42 +-------- 2 files changed, 70 insertions(+), 67 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index e514a09..5e0fb06 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -1,6 +1,7 @@ import QtQuick 2.15 import QtQuick.Layouts import FluentUI +import QtQuick.Dialogs import "qrc:///AicsKnowledgeBase/qml/global" import SignalFileOperation 1.0 @@ -34,39 +35,81 @@ Item { Component { id: fileListItemHeader - Item { + + RowLayout { id: fileListItemHeaderItem width: ListView.view.width height: 48 - RowLayout { - FluBreadcrumbBar { - id: header - width: parent.width - height: parent.height - separator: ">" - items: [] - onClickItem: function (model) { - if (model.index + 1 !== count()) { - items = items.slice(0, model.index + 1) - } + + // back to folder button + FluIconButton { + Layout.alignment: Qt.AlignVCenter + id: backButton + width: 24 + height: 24 + iconSource: FluentIcons.ForwardCall + onClicked: { + if (header.count() > 0) { + header.items = header.items.slice(0, header.count() - 1) } - onItemsChanged: { - fileListItemHeaderItem.update() + fileListItemHeaderItem.update() + } + } + FluBreadcrumbBar { + id: header + //width: parent.width + height: parent.height + separator: ">" + items: [] + onClickItem: function (model) { + if (model.index + 1 !== count()) { + items = items.slice(0, model.index + 1) } } - // back to folder button - FluIconButton { - Layout.alignment: Qt.AlignVCenter - id: backButton - width: 24 - height: 24 - iconSource: FluentIcons.ChromeBack - onClicked: { - if (header.count() > 0) { - header.items = header.items.slice( - 0, header.count() - 1) + onItemsChanged: { + fileListItemHeaderItem.update() + } + } + + FluButton { + Layout.alignment: Qt.AlignRight + text: "上传" + onClicked: function () { + console.log("click") + fileDialog.open() + } + + FileDialog { + id: fileDialog + onAccepted: function () { + const size = FileTransferManager.getFileSize( + selectedFile) + const md5 = FileTransferManager.getFileMd5(selectedFile) + + if (size <= 0 || md5 === '') + return + + var body = { + "name": "test2", + "brief": "brief", + "size": size, + "md5": md5, + "tags": [], + "parentId": null } - fileListItemHeaderItem.update() + console.log("begin") + console.log(JSON.stringify(body)) + + Request.post("knowledge/file", JSON.stringify(body), + function (res, data) { + console.log(res) + console.log(data) + FileTransferManager.upload( + selectedFile, data.id, + data.ticket) + }, function (res, data) { + console.log(res) + }) } } } diff --git a/AicsKnowledgeBase/qml/page/FilePage.qml b/AicsKnowledgeBase/qml/page/FilePage.qml index 90aefd9..c43a418 100644 --- a/AicsKnowledgeBase/qml/page/FilePage.qml +++ b/AicsKnowledgeBase/qml/page/FilePage.qml @@ -23,48 +23,8 @@ FluArea { text: "" } - FluButton { - text: "上传" - onClicked: function () { - console.log("click") - fileDialog.open() - } - - FileDialog { - id: fileDialog - onAccepted: function () { - const size = FileTransferManager.getFileSize(selectedFile) - const md5 = FileTransferManager.getFileMd5(selectedFile) - - if (size <= 0 || md5 === '') - return - - var body = { - "name": "test2", - "brief": "brief", - "size": size, - "md5": md5, - "tags": [], - "parentId": null - } - console.log("begin") - console.log(JSON.stringify(body)) - - Request.post("knowledge/file", JSON.stringify(body), - function (res, data) { - console.log(res) - console.log(data) - FileTransferManager.upload(selectedFile, - data.id, - data.ticket) - }, function (res, data) { - console.log(res) - }) - } - } - } - FileList { autoRequest: true + width: parent.width } }