Compare commits

...

2 Commits

4 changed files with 63 additions and 41 deletions

View File

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

View File

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

View File

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

View File

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