答辩版本

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 "fileTitle": fileTitle
}) })
} }
function onModifyNote(file, fileType, fileTitle, note) { function onModifyNote(file, fileType, fileTitle, note, noteTitle, noteContent) {
stack_view.push(create_note_view, { stack_view.push(create_note_view, {
"knowledgeFileId": file, "knowledgeFileId": file,
"fileType": fileType, "fileType": fileType,
"fileTitle": fileTitle, "fileTitle": fileTitle,
"noteFileId": note, "noteFileId": note,
"noteTitle": noteTitle,
"noteContent": noteContent,
"isModifying": true "isModifying": true
}) })
} }

View File

@ -7,14 +7,6 @@ FluObject {
property var navigationView property var navigationView
FluPaneItem {
title: "探索"
icon: FluentIcons.Home
onTap: {
navigationView.push("qrc:/AicsKnowledgeBase/qml/page/HomePage.qml")
}
}
FluPaneItem { FluPaneItem {
title: "全部" title: "全部"
icon: FluentIcons.FileExplorer icon: FluentIcons.FileExplorer
@ -27,7 +19,8 @@ FluObject {
title: "文档" title: "文档"
icon: FluentIcons.Document icon: FluentIcons.Document
onTap: { onTap: {
navigationView.push("qrc:/AicsKnowledgeBase/qml/page/DocumentPage.qml") navigationView.push(
"qrc:/AicsKnowledgeBase/qml/page/DocumentPage.qml")
} }
} }
@ -51,7 +44,8 @@ FluObject {
title: "搜索" title: "搜索"
icon: FluentIcons.Search icon: FluentIcons.Search
onTap: { 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) { function putForm(url, arg, success, failure) {
var xhr = new XMLHttpRequest var xhr = new XMLHttpRequest
xhr.open("POST", baseUrl + url) xhr.open("PUT", baseUrl + url)
xhr.setRequestHeader("Content-Length", arg.length) //xhr.setRequestHeader("Content-Length", arg.length)
xhr.setRequestHeader("Content-Type", xhr.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded;") "application/x-www-form-urlencoded;")
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (this.readyState === 4) {
console.log(this.responseText)
}
handleResponse(xhr, success, failure) handleResponse(xhr, success, failure)
} }
xhr.send(arg) xhr.send(arg)

View File

@ -6,6 +6,6 @@ QtObject {
signal open(string file) signal open(string file)
signal openNote(string note, string authorId) signal openNote(string note, string authorId)
signal createNote(string file, string fileType, string fileTitle) 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 signal back
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -432,3 +432,29 @@ void FileTransferManager::openLocalFile(const QString &fileName)
QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Downloads\\"+ 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 openLocalFile(const QString &fileName);
Q_INVOKABLE void putForm(QString knowledgeId, bool active);
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);
private: private:
}; };