答辩版本

main
wuyize 2023-07-08 13:51:14 +08:00
parent f32bcae463
commit d56a236466
10 changed files with 81 additions and 54 deletions

View File

@ -128,12 +128,14 @@ FluWindow {
"fileTitle": fileTitle
})
}
function onModifyNote(file, fileType, fileTitle, note) {
function onModifyNote(file, fileType, fileTitle, note, noteTitle, noteContent) {
stack_view.push(create_note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle,
"noteFileId": note,
"noteTitle": noteTitle,
"noteContent": noteContent,
"isModifying": true
})
}

View File

@ -7,14 +7,6 @@ FluObject {
property var navigationView
FluPaneItem {
title: "探索"
icon: FluentIcons.Home
onTap: {
navigationView.push("qrc:/AicsKnowledgeBase/qml/page/HomePage.qml")
}
}
FluPaneItem {
title: "全部"
icon: FluentIcons.FileExplorer
@ -27,7 +19,8 @@ FluObject {
title: "文档"
icon: FluentIcons.Document
onTap: {
navigationView.push("qrc:/AicsKnowledgeBase/qml/page/DocumentPage.qml")
navigationView.push(
"qrc:/AicsKnowledgeBase/qml/page/DocumentPage.qml")
}
}
@ -51,7 +44,8 @@ FluObject {
title: "搜索"
icon: FluentIcons.Search
onTap: {
navigationView.push("qrc:/AicsKnowledgeBase/qml/page/SearchPage.qml")
navigationView.push(
"qrc:/AicsKnowledgeBase/qml/page/SearchPage.qml")
}
}

View File

@ -72,11 +72,14 @@ QtObject {
function putForm(url, arg, success, failure) {
var xhr = new XMLHttpRequest
xhr.open("POST", baseUrl + url)
xhr.setRequestHeader("Content-Length", arg.length)
xhr.open("PUT", baseUrl + url)
//xhr.setRequestHeader("Content-Length", arg.length)
xhr.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded;")
xhr.onreadystatechange = function () {
if (this.readyState === 4) {
console.log(this.responseText)
}
handleResponse(xhr, success, failure)
}
xhr.send(arg)

View File

@ -6,6 +6,6 @@ QtObject {
signal open(string file)
signal openNote(string note, string authorId)
signal createNote(string file, string fileType, string fileTitle)
signal modifyNote(string file, string fileType, string fileTitle, string note)
signal modifyNote(string file, string fileType, string fileTitle, string note, string noteTitle, string noteContent)
signal back
}

View File

@ -32,7 +32,7 @@ FluArea {
backgroundColor: "#f9f9f9"
NoteList {
id: noteList
//noteListModel: noteListModel2
noteListModel: noteListModel2
onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId)
popup.close()
@ -125,7 +125,8 @@ FluArea {
isFavorite = false
var starers = data.knowledgeFileAttribute.starers
for (var i = 0; i < starers.length; i++) {
if (starers[i].id === UserData.userId) {
if (starers[i].id.toString(
) === UserData.userId) {
isFavorite = true
}
}
@ -263,13 +264,10 @@ FluArea {
content_page.isFavorite = !content_page.isFavorite
console.log(content_page.isFavorite)
content_page.favoriteCount += (content_page.isFavorite ? 1 : -1)
Request.put("knowledge/" + knowledgeFileId + "/star", {
"active": content_page.isFavorite
}, response => {
console.log(response)
}, response => {
console.log(response)
})
var form = "active=" + content_page.isFavorite ? "true" : "false"
Request.putForm(
"knowledge/" + knowledgeFileId + "/star",
form)
}
}
FluText {

View File

@ -25,17 +25,12 @@ FluArea {
property bool isModifying: false
Component.onCompleted: {
console.log(knowledgeFileId)
isModifying = false
if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) {
input_title.text = data.title
input_md.contentMd = data.content
tags = data.tags
function (response) {
input_title.text = noteTitle
})
}
} else {
noteTitle = Qt.binding(function () {
return input_title.text
})
@ -43,6 +38,7 @@ FluArea {
return input_md.contentMd
})
}
}
FluScrollablePage {
id: edit_page
@ -92,6 +88,8 @@ FluArea {
Item {
Layout.fillWidth: true
implicitHeight: 50
RowLayout {
Layout.fillWidth: true
FluText {
id: text_title
padding: 10
@ -107,9 +105,6 @@ FluArea {
placeholderText: "单行输入框"
implicitWidth: parent.width
font.pointSize: 12
anchors {
left: text_title.right
verticalCenter: text_title.verticalCenter
}
}
}
@ -130,6 +125,7 @@ FluArea {
height: width * 9 / 16
isEditable: true
isEditing: true
contentMd: noteContent
}
RowLayout {

View File

@ -46,6 +46,7 @@ FluArea {
}
textArea_edit.text = edit_area.contentMd
edit_area.contentMd = Qt.binding(function () {
return textArea_edit.text
})

View File

@ -155,7 +155,9 @@ FluArea {
emit: SignalFileOperation.modifyNote(note_page.fileId,
note_page.fileType,
note_page.fileTitle,
noteFileId)
noteFileId,
note_page.title,
text_view.contentMd)
}
anchors {
left: text_title.right

View File

@ -432,3 +432,29 @@ void FileTransferManager::openLocalFile(const QString &fileName)
QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Downloads\\"+ fileName));
}
void FileTransferManager::putForm(QString knowledgeId, bool active)
{
CURL *curl = curl_easy_init();
if (!curl) {
qCritical() << "CURL INIT FAILED!";
return;
}
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_URL, ("https://api.hammer-hfut.tk:233/aics/main/knowledge/"+knowledgeId+"/star").toStdString().c_str());
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3000);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "active");
curl_mime_data(part, active?"true":"false", CURL_ZERO_TERMINATED);
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
auto res = curl_easy_perform(curl);
curl_mime_free(mime);
curl_easy_cleanup(curl);
}

View File

@ -34,9 +34,14 @@ public:
Q_INVOKABLE void openLocalFile(const QString &fileName);
Q_INVOKABLE void putForm(QString knowledgeId, bool active);
signals:
void transferComplete(bool download, QString fileId, QString fileName);
void markdownData(QString data);
private:
};