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 20)
find_package(Qt6 COMPONENTS Quick WebEngineQuick REQUIRED)
find_package(Qt6 COMPONENTS Gui Quick WebEngineQuick REQUIRED)
#Cpp
file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h)

View File

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

View File

@ -8,6 +8,7 @@
#include <QJsonDocument>
#include <QtConcurrent/QtConcurrent>
#include <fstream>
#include <QDesktopServices>
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/";
@ -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 openLocalFile(const QString &fileName);
signals:
void transferComplete(bool download, QString fileId, QString fileName);
void markdownData(QString data);