完成大部分

main
yang.yongquan 2023-07-07 03:21:43 +08:00
parent 26b9016a45
commit abec8f55f1
4 changed files with 67 additions and 18 deletions

View File

@ -95,7 +95,7 @@ FluWindow {
duration: 200
}
}
initialItem: create_note_view
initialItem: note_view
}
Connections {
@ -118,18 +118,19 @@ FluWindow {
stack_view.pop()
}
function onCreateNote(file, fileType, fileTitle) {
stack_view.push(note_view, {
stack_view.push(create_note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle
})
}
function onModifyNote(file, fileType, fileTitle, note) {
stack_view.push(note_view, {
stack_view.push(create_note_view, {
"knowledgeFileId": file,
"fileType": fileType,
"fileTitle": fileTitle,
"noteId": note
"noteId": note,
"isModifying": true
})
}
}

View File

@ -31,11 +31,13 @@ FluArea {
noteListModel: content_page.noteListModel
onOpen: function handle(noteId, authorId) {
emit: SignalFileOperation.openNote(noteId, authorId)
popup.close()
}
onCreateNote: function handle() {
emit: SignalFileOperation.createNote(
content_area.knowledgeFileId, content_area.type,
content_page.title)
emit: SignalFileOperation.createNote(content_page.fileId,
content_area.type,
content_page.title)
popup.close()
}
}
}
@ -92,8 +94,9 @@ FluArea {
function loadFile(knowledgeFileId) {
content_area.knowledgeFileId = knowledgeFileId
console.log(knowledgeFileId)
Request.get("knowledge/" + knowledgeFileId + "/detail",
Request.get("knowledge/" + knowledgeFileId + "/detailed",
function (response, data) {
console.log(response)
content_page.publishTime = data.createTime
content_page.title = data.name
content_page.fileId = data.knowledgeFileAttribute.id
@ -101,7 +104,7 @@ FluArea {
content_page.fileSize = data.knowledgeFileAttribute.size
content_area.type = getType(content_page.suffix)
console.log(content_area.type)
console.log(content_area.fileId)
var tagString = ""
for (var j = 0; j < data.knowledgeFileAttribute.tags.length; j++) {
@ -245,7 +248,7 @@ FluArea {
content_page.isFavorite = !content_page.isFavorite
content_page.favoriteCount += 1
Request.put("knowledge/" + knowledgeFileId + "/star", {
"active": UserData.userId
"active": content_page.isFavorite
})
}
}
@ -351,7 +354,6 @@ FluArea {
FluMediaPlayer {
width: parent.width
height: width * 9 / 16.
source: "https://api.hammer-hfut.tk:233/aics/file/static/3f28fea9-27f1-4a85-9d3e-def187c4456e.mp4"
}
}
Component {

View File

@ -25,6 +25,8 @@ FluArea {
property bool isModifying: false
Component.onCompleted: {
console.log(knowledgeFileId)
isModifying = false
if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) {
@ -137,7 +139,10 @@ FluArea {
text: "上传"
onClicked: {
if (noteTitle.trim() !== "" && noteContent !== "") {
if (isModifying) {
console.log(noteTitle)
console.log(noteContent)
console.log(knowledgeFileId)
if (!isModifying) {
Request.post("note", {
"title": noteTitle,
"content": noteContent,

View File

@ -18,6 +18,7 @@ FluArea {
// visible: false
property string type: ""
property string noteFileId
property string authorId
signal clickTags(string tagName)
// paddings: {
@ -46,7 +47,6 @@ FluArea {
property string publishTime: "2020-01-01"
property string brief: "这是一个简介"
property string uuid: "354"
property string fileTitle: "dfnfgf"
property string fileType: "OTHER"
@ -65,19 +65,37 @@ FluArea {
}
Component.onCompleted: {
Request.getSearch("/", function (response, data) {
note_page.uuid = data.id
Request.getSearch("note/" + noteFileId, function (response, data) {
note_page.fileId = data.id
note_page.fileTitle = data.name
note_page.fileType = getType(data.knowledgeFileAttribute.suffix)
note_page.fileStars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
for (var j = 0; j < data.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
tagString = tagString + data.tags[j].name
}
note_page.fileTags = tagString
likeCount = data.likers.length
isLike = false
for (var j = 0; j < data.likers.length; j++) {
if (data.likers[j].id === UserData.userId) {
isLike = true
break
}
}
favoriteCount = data.starrers.length
isLike = false
for (var j = 0; j < data.starrers.length; j++) {
if (data.starrers[j].id === UserData.userId) {
isFavorite = true
break
}
}
})
}
@ -103,6 +121,17 @@ FluArea {
bold: true
}
}
FluIconButton {
id: button_edit_note
iconSize: FluentIcons.Edit
visible: authorId === UserData.userId
onClicked: {
emit: SignalFileOperation.modifyNote(note_page.fileId,
note_page.fileType,
note_page.fileTitle,
noteFileId)
}
}
ColumnLayout {
id: layout_share
FluIconButton {
@ -129,6 +158,12 @@ FluArea {
id: button_favorite
iconSize: 15
iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
onClicked: {
note_page.isFavorite = !note_page.isFavorite
Request.put("/note/" + noteFileId + "/star", {
"active": note_page.isFavorite
})
}
}
FluText {
id: text_favorite
@ -148,6 +183,12 @@ FluArea {
id: button_like
iconSize: 15
iconSource: note_page.isLike ? FluentIcons.HeartFill : FluentIcons.Heart
onClicked: {
note_page.isLike = !note_page.isLike
Request.put("/note/" + noteFileId + "/like", {
"active": note_page.isLike
})
}
}
FluText {
id: text_like
@ -215,7 +256,7 @@ FluArea {
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.uuid)
emit: SignalFileOperation.open(note_page.fileId)
}
}
RowLayout {