main
wuyize 2023-07-07 05:54:08 +08:00
parent fc3dfa7ef4
commit 0e886e1489
5 changed files with 96 additions and 69 deletions

View File

@ -95,7 +95,6 @@ FluWindow {
duration: 200 duration: 200
} }
} }
initialItem: note_view
} }
Connections { Connections {
@ -108,6 +107,8 @@ FluWindow {
}) })
} }
function onOpenNote(note, authorId) { function onOpenNote(note, authorId) {
console.log(note)
console.log(authorId)
stack_view.push(note_view, { stack_view.push(note_view, {
"noteFileId": note, "noteFileId": note,
"authorId": authorId "authorId": authorId
@ -118,6 +119,9 @@ FluWindow {
stack_view.pop() stack_view.pop()
} }
function onCreateNote(file, fileType, fileTitle) { function onCreateNote(file, fileType, fileTitle) {
console.log(file)
console.log(fileType)
console.log(fileTitle)
stack_view.push(create_note_view, { stack_view.push(create_note_view, {
"knowledgeFileId": file, "knowledgeFileId": file,
"fileType": fileType, "fileType": fileType,
@ -129,7 +133,7 @@ FluWindow {
"knowledgeFileId": file, "knowledgeFileId": file,
"fileType": fileType, "fileType": fileType,
"fileTitle": fileTitle, "fileTitle": fileTitle,
"noteId": note, "noteFileId": note,
"isModifying": true "isModifying": true
}) })
} }

View File

@ -260,10 +260,9 @@ 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", Request.put("knowledge/" + knowledgeFileId + "/star", {
JSON.stringify({
"active": content_page.isFavorite "active": content_page.isFavorite
}), response => { }, response => {
console.log(response) console.log(response)
}, response => { }, response => {
console.log(response) console.log(response)

View File

@ -30,10 +30,8 @@ FluArea {
if (isModifying) { if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content", Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) { function (response, data) {
noteTitle = data.title input_title.text = data.title
noteContent = data.content input_md.contentMd = data.content
input_title.text = noteTitle
input_md.contentMd = noteContent
tags = data.tags tags = data.tags
}) })
} }
@ -94,9 +92,8 @@ FluArea {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 50 implicitHeight: 50
RowLayout {
Layout.fillWidth: true
FluText { FluText {
id: text_title
padding: 10 padding: 10
text: "标题" text: "标题"
font { font {
@ -110,6 +107,9 @@ FluArea {
placeholderText: "单行输入框" placeholderText: "单行输入框"
implicitWidth: parent.width implicitWidth: parent.width
font.pointSize: 12 font.pointSize: 12
anchors {
left: text_title.right
verticalCenter: text_title.verticalCenter
} }
} }
} }

View File

@ -180,7 +180,6 @@ FluArea {
id: textArea_edit id: textArea_edit
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
background: Rectangle { background: Rectangle {
color: customTextArea.focus ? "#E0E0E0" : "white"
border.color: FluColors.Grey30 border.color: FluColors.Grey30
radius: 10 radius: 10
} }
@ -197,7 +196,6 @@ FluArea {
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
textFormat: TextEdit.MarkdownText textFormat: TextEdit.MarkdownText
background: Rectangle { background: Rectangle {
color: customTextArea.focus ? "#E0E0E0" : "white"
border.color: FluColors.Grey30 border.color: FluColors.Grey30
radius: 10 radius: 10
} }

View File

@ -21,6 +21,67 @@ FluArea {
property string authorId property string authorId
signal clickTags(string tagName) signal clickTags(string tagName)
function getType(suffix) {
if (suffix === "md")
return "MD"
else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb"
|| suffix === "rm" || suffix === "wmv" || suffix === "mkv")
return "VIDEO"
else
return "OTHER"
}
function loadNote() {
console.log(noteFileId)
Request.get("note/" + noteFileId, function (response) {
var data = JSON.parse(response)
console.log(response)
note_page.fileId = data.id
note_page.fileTitle = data.knowledgeFiles[0].knowledge.name
note_page.fileType = getType(data.knowledgeFiles[0].suffix)
note_page.favoriteCount = 0
note_page.title = data.title
note_page.publishTime = data.createTime
note_page.browsCount = data.pageView
var tagString = ""
for (var j = 0; j < data.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + data.tags[j].name
}
note_page.tags = tagString.split(",")
note_page.likeCount = data.likers.length
note_page.isLike = false
for (var j = 0; j < data.likers.length; j++) {
if (data.likers[j].id === UserData.userId) {
isLike = true
break
}
}
note_page.favoriteCount = data.starers.length
note_page.isFavorite = false
for (var j = 0; j < data.starers.length; j++) {
if (data.starers[j].id === UserData.userId) {
isFavorite = true
break
}
}
Request.getSearch("search/note/" + noteFileId + "/content",
response => {
text_view.contentMd = response
note_page.brief = response
})
})
}
Component.onCompleted: {
loadNote()
}
// paddings: { // paddings: {
// top: 10 // top: 10
// right: 0 // right: 0
@ -42,7 +103,7 @@ FluArea {
property int browsCount: 555 property int browsCount: 555
property bool isLike: false property bool isLike: false
property bool isFavorite: false property bool isFavorite: false
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 string publishTime: "2020-01-01" property string publishTime: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
@ -64,41 +125,6 @@ FluArea {
note_area.noteFileId = noteFileId note_area.noteFileId = noteFileId
} }
Component.onCompleted: {
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 < data.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
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
}
}
})
}
FluIconButton { FluIconButton {
iconSize: 12 iconSize: 12
iconSource: FluentIcons.Back iconSource: FluentIcons.Back
@ -123,14 +149,18 @@ FluArea {
} }
FluIconButton { FluIconButton {
id: button_edit_note id: button_edit_note
iconSize: FluentIcons.Edit iconSource: FluentIcons.Edit
visible: authorId === UserData.userId visible: note_area.authorId.toString() == UserData.userId
onClicked: { onClicked: {
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)
} }
anchors {
left: text_title.right
verticalCenter: text_title.verticalCenter
}
} }
ColumnLayout { ColumnLayout {
id: layout_share id: layout_share
@ -216,10 +246,6 @@ FluArea {
padding: 10 padding: 10
text: note_page.publishTime.substring(0, 10) text: note_page.publishTime.substring(0, 10)
} }
FluText {
padding: 10
text: note_page.fileSize.toString() + "MB"
}
FluText { FluText {
padding: 10 padding: 10
text: note_page.browsCount.toString() + "浏览量" text: note_page.browsCount.toString() + "浏览量"