karlis 2023-07-07 01:11:33 +08:00
commit 9817746fb4
4 changed files with 44 additions and 15 deletions

View File

@ -6,7 +6,7 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
find_package(Qt6 COMPONENTS Quick WebEngineQuick REQUIRED) find_package(Qt6 COMPONENTS Gui Quick WebEngineQuick REQUIRED)
#Cpp #Cpp
file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h) file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h)

View File

@ -4,6 +4,8 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import QtQml
import "qrc:///AicsKnowledgeBase/qml/global"
Rectangle { Rectangle {
id: input id: input
@ -13,10 +15,32 @@ Rectangle {
radius: 5 radius: 5
clip: true clip: true
border.color: textInput.activeFocus ? "#268CDC":"#979592" //gray100
ListModel { id: tagListModel } ListModel { id: tagListModel }
property ListModel tagList: tagListModel property ListModel tagList: tagListModel
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<data.length;i++){
tagMap.push([data[i].id,data[i].name])
presetsTags.push(data[i].name)
presetsTagsItem.push({title:data[i].name})
}
// console.log(tagMap)
// console.log(presetsTags)
},function (p1, p2) {
// console.log("failure")
// console.log(p1)
// console.log(p2)
})
}
Row { Row {
x: 5 x: 5
@ -48,23 +72,23 @@ Rectangle {
width: input.width - rowTag.width width: input.width - rowTag.width
height: parent.height height: parent.height
TextField { FluAutoSuggestBox{
id:textInput id:textInput
placeholderText: qsTr("按回车键Enter创建标签") anchors.verticalCenter: parent.verticalCenter
width: parent.width
placeholderText: "按回车键Enter创建标签"
Layout.preferredWidth: 300
//items:[{title:""},{title:""},{title:""}]
items: presetsTagsItem
onFocusChanged: { onFocusChanged: {
text ="" text =""
} }
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 15
clip: true
background: Rectangle {
}
Keys.onReturnPressed: { Keys.onReturnPressed: {
var presetsTags = ["前端","后端","数据库"]
if (text.length === 0) if (text.length === 0)
return return
@ -72,12 +96,10 @@ Rectangle {
text = "" text = ""
return return
} }
tagListModel.append({"tag": text}) tagListModel.append({"tag": text})
//console.log(tagListModel.get(0)) //console.log(tagListModel.get(0))
text = "" text = ""
} }
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Backspace) { if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) { if (text.length === 0 && tagListModel.count) {
@ -86,7 +108,6 @@ Rectangle {
} }
} }
} }
} }
} }

View File

@ -8,6 +8,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <fstream> #include <fstream>
#include <QDesktopServices>
static const std::string baseUrl = "https://api.hammer-hfut.tk:233/aics/file/"; static const std::string baseUrl = "https://api.hammer-hfut.tk:233/aics/file/";
//static const std::string baseUrl = "http://127.0.0.1:4523/m1/2914957-0-6e5f2db1/"; //static const std::string baseUrl = "http://127.0.0.1:4523/m1/2914957-0-6e5f2db1/";
@ -426,3 +427,8 @@ void FileTransferManager::getMarkdown(const QString &fileId)
}); });
} }
void FileTransferManager::openLocalFile(const QString &fileName)
{
QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Downloads\\"+ fileName));
}

View File

@ -32,6 +32,8 @@ public:
Q_INVOKABLE void getMarkdown(const QString &fileId); Q_INVOKABLE void getMarkdown(const QString &fileId);
Q_INVOKABLE void openLocalFile(const QString &fileName);
signals: signals:
void transferComplete(bool download, QString fileId, QString fileName); void transferComplete(bool download, QString fileId, QString fileName);
void markdownData(QString data); void markdownData(QString data);