a lot thing

main
wuyize 2023-07-07 04:48:06 +08:00
parent ecff8e709c
commit b229fd037e
5 changed files with 64 additions and 42 deletions

View File

@ -58,6 +58,7 @@ Item {
model: noteListModel
delegate: noteListItemDelegate
}
Component {
id: noteListItemHeader
Item {
@ -111,5 +112,6 @@ Item {
}
function setListModel(listModel) {
listView.model = listModel
//console.log(listView.model.get(0).uuid)
}
}

View File

@ -6,7 +6,7 @@ QtObject {
id: request
property string baseUrl: "https://api.hammer-hfut.tk:233/aics/main/"
property string searchUrl: "https://api.hammer-hfut.tk:233/aics/query"
property string searchUrl: "https://api.hammer-hfut.tk:233/aics/query/"
//property string baseUrl: "http://192.168.156.74:8080/"
// GET

View File

@ -28,7 +28,7 @@ FluArea {
backgroundColor: "#f9f9f9"
NoteList {
id: noteList
noteListModel: content_page.noteListModel
//noteListModel: content_page.noteListModel
onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId)
popup.close()
@ -75,7 +75,7 @@ FluArea {
property double fileSize: 0
property string title: "文章标题"
property list<string> tags: ["tag 1", "tag 2", "tag 3"]
property var publishTime
property string publishTime
property string brief: "这是一个简介"
property string fileUrl: "https://api.hammer-hfut.tk:233/aics/file/"
property string suffix: "md"
@ -95,16 +95,18 @@ FluArea {
content_area.knowledgeFileId = knowledgeFileId
console.log(knowledgeFileId)
Request.get("knowledge/" + knowledgeFileId + "/detailed",
function (response, data) {
function (response) {
console.log(response)
content_page.publishTime = data.createTime
var data = JSON.parse(response)
content_page.publishTime = data.createTime.substring(
0, 10)
content_page.title = data.name
content_page.fileId = data.knowledgeFileAttribute.id
content_page.suffix = data.knowledgeFileAttribute.suffix
content_page.fileSize = data.knowledgeFileAttribute.size
content_area.type = getType(content_page.suffix)
console.log(content_area.fileId)
console.log(content_area.type)
var tagString = ""
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
@ -126,22 +128,30 @@ FluArea {
}
content_page.favoriteCount = starers.length
noteListModel.clear()
noteList.setListModel([])
var notes = data.knowledgeFileAttribute.notes
noteCount = notes.length
for (var i = 0; i < notes.length; i++) {
noteListModel.append({
"uuid": notes[i].id,
"title": notes[i].title,
"brief": notes[i].content,
"author": notes[i].author.username,
"authorId": notes[i].author.id,
"pageView": notes[i].pageView,
"stars": notes[i].starrers.length,
"date": notes[i].createTime
})
}
console.log(noteCount)
var noteItems = []
for (i = 0; i < notes.length; i++) {
var note = notes[i]
Request.getSearch(
"search/note/" + notes[i].id + "/content",
response => {
noteItems.push({
"uuid": note.id,
"title": note.title,
"brief": response,
"author": note.author.username,
"authorId": note.author.id,
"pageView": note.pageView,
"stars": note.starers.length,
"date": note.createTime
})
})
}
noteList.noteListModel.append(noteItems)
if (content_area.type === "MD") {
// console.log(content_area.type)
FileTransferManager.getMarkdown(
@ -246,10 +256,11 @@ FluArea {
iconSource: content_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
onClicked: {
content_page.isFavorite = !content_page.isFavorite
content_page.favoriteCount += 1
Request.put("knowledge/" + knowledgeFileId + "/star", {
"active": content_page.isFavorite
})
content_page.favoriteCount += (content_page.isFavorite ? 1 : -1)
Request.put("knowledge/" + knowledgeFileId + "/star",
JSON.stringify({
"active": content_page.isFavorite
}))
}
}
FluText {
@ -292,7 +303,7 @@ FluArea {
width: parent.width
FluText {
padding: 10
text: content_page.publishTime
text: content_page.publishTime.substring(0, 10)
}
FluText {
padding: 10

View File

@ -143,19 +143,26 @@ FluArea {
console.log(noteContent)
console.log(knowledgeFileId)
if (!isModifying) {
Request.post("note", {
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
Request.post("note", JSON.stringify({
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
}),
response => {
console.log(response)
}, response => {
console.log(response)
})
SignalFileOperation.back()
} else {
Request.put("note/" + noteFileId, {
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
})
Request.put("note/" + noteFileId, JSON.stringify({
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
}))
SignalFileOperation.back()
}
}
}

View File

@ -160,9 +160,10 @@ FluArea {
iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
onClicked: {
note_page.isFavorite = !note_page.isFavorite
Request.put("/note/" + noteFileId + "/star", {
"active": note_page.isFavorite
})
Request.put("/note/" + noteFileId + "/star",
JSON.stringify({
"active": note_page.isFavorite
}))
}
}
FluText {
@ -185,9 +186,10 @@ FluArea {
iconSource: note_page.isLike ? FluentIcons.HeartFill : FluentIcons.Heart
onClicked: {
note_page.isLike = !note_page.isLike
Request.put("/note/" + noteFileId + "/like", {
"active": note_page.isLike
})
Request.put("/note/" + noteFileId + "/like",
JSON.stringify({
"active": note_page.isLike
}))
}
}
FluText {
@ -212,7 +214,7 @@ FluArea {
width: parent.width
FluText {
padding: 10
text: note_page.publishTime
text: note_page.publishTime.substring(0, 10)
}
FluText {
padding: 10