Compare commits

..

2 Commits

4 changed files with 77 additions and 24 deletions

View File

@ -102,7 +102,9 @@ FluWindow {
target: SignalFileOperation target: SignalFileOperation
function onOpen(file) { function onOpen(file) {
stack_view.clear() stack_view.clear()
stack_view.push(file_view, {knowledgeFileId: file}) stack_view.push(file_view, {
"knowledgeFileId": file
})
} }
function onOpenNote(note) { function onOpenNote(note) {
stack_view.push(note_view, { stack_view.push(note_view, {
@ -113,6 +115,9 @@ FluWindow {
if (stack_view.depth > 0) if (stack_view.depth > 0)
stack_view.pop() stack_view.pop()
} }
function onCreateNote() {
stack_view.push(create_note_view)
}
} }
Component { Component {
@ -127,11 +132,8 @@ FluWindow {
Component { Component {
id: create_note_view id: create_note_view
CreateNotePage { CreateNotePage {}
} }
}
// ContentPage { // ContentPage {
// Layout.fillHeight: true // Layout.fillHeight: true

View File

@ -5,5 +5,6 @@ import QtQuick
QtObject { QtObject {
signal open(string file) signal open(string file)
signal openNote(string note) signal openNote(string note)
signal back() signal createNote
signal back
} }

View File

@ -41,10 +41,9 @@ FluArea {
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
// visible: false // visible: false
property string type: "" property string type: "MD"
property string knowledgeFileId property string knowledgeFileId
signal back signal back
signal download(string knowledgeFileId)
signal clickTags(string tagName) signal clickTags(string tagName)
// paddings: { // paddings: {
@ -68,11 +67,13 @@ FluArea {
property int browsCount: 555 property int browsCount: 555
property bool isFavorite: false property bool isFavorite: false
property bool isDownload: false property bool isDownload: false
property double fileSize: 455 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 var publishTime
property string brief: "这是一个简介" property string brief: "这是一个简介"
property string fileUrl: "https://api.hammer-hfut.tk:233/aics/file/"
property string suffix: "md"
function getType(suffix) { function getType(suffix) {
if (suffix === "md") if (suffix === "md")
@ -114,11 +115,14 @@ FluArea {
// } // }
// content_page.favoriteCount = starers.length // content_page.favoriteCount = starers.length
if (content_area.type == "MD") { if (content_area.type == "MD") {
console.log(content_area.type) // console.log(content_area.type)
FileTransferManager.getMarkdown( FileTransferManager.getMarkdown(
content_page.fileId) content_page.fileId)
} else if (content_area.type == "VIDEO") { } else if (content_area.type == "VIDEO") {
content_view.push(video_view, {
"url": fileUrl + "static/"
+ fileId + "." + suffix
})
} else { } else {
Request.get("knowledge/" + knowledgeFileId + "/preview/external", Request.get("knowledge/" + knowledgeFileId + "/preview/external",
function (res) { function (res) {
@ -211,6 +215,13 @@ FluArea {
id: button_favorite id: button_favorite
iconSize: 15 iconSize: 15
iconSource: content_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar 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": UserData.userId
})
}
} }
FluText { FluText {
id: text_favorite id: text_favorite
@ -234,10 +245,12 @@ FluArea {
rightMargin: 20 rightMargin: 20
} }
onClicked: { onClicked: {
emit: content_area.download(content_area.knowledgeFileId) if (!content_page.isDownload)
//FileTransferManager.getMarkdown(content_page.fileId)
FileTransferManager.download(content_page.fileId, FileTransferManager.download(content_page.fileId,
content_page.title) content_page.title)
else {
}
} }
} }
} }
@ -254,7 +267,9 @@ FluArea {
} }
FluText { FluText {
padding: 10 padding: 10
text: content_page.fileSize.toString() + "MB" text: fileSize > 1024 * 1024 ? (fileSize / 1024 / 1024).toFixed(
2) + "MB" : (fileSize / 1024).toFixed(
2) + "KB"
} }
FluText { FluText {
padding: 10 padding: 10

View File

@ -15,7 +15,7 @@ FluArea {
id: note_area id: note_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
// visible: false // visible: false
property string type: "" property string type: ""
property string noteFileId property string noteFileId
signal clickTags(string tagName) signal clickTags(string tagName)
@ -26,7 +26,6 @@ FluArea {
// bottom: 10 // bottom: 10
// left: 10 // left: 10
// } // }
FluScrollablePage { FluScrollablePage {
id: note_page id: note_page
anchors.fill: parent anchors.fill: parent
@ -47,24 +46,46 @@ FluArea {
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: "这是一个简介"
property var fromFile
function getType(suffix) { function getType(suffix) {
if(suffix === "md") if (suffix === "md")
return "MD" return "MD"
else if(suffix === "mp4" || suffix === "avi" else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb"
|| suffix === "rmvb" || suffix === "rm" || suffix === "rm" || suffix === "wmv" || suffix === "mkv")
|| suffix === "wmv" || suffix === "mkv")
return "VIDEO" return "VIDEO"
else return "OTHER" else
return "OTHER"
} }
function loadNote(noteFileId) { function loadNote(noteFileId) {
note_area.noteFileId = noteFileId note_area.noteFileId = noteFileId
} }
Component.onCompleted: { Component.onCompleted: {
Request.get("knowledge/", function (response, data) {
fromFile = {
"uuid": data.id,
"fuuid": data.knowledgeFileAttribute.id,
"title": data.name,
"date": data.createTime,
"brief": data.knowledgeFileAttribute.brief,
"suffix": data.knowledgeFileAttribute.suffix,
"type": getType(data.knowledgeFileAttribute.suffix),
"pageView": data.knowledgeFileAttribute.pageView,
"size": data.knowledgeFileAttribute.size
}
fromFile.stars = 0
var tagString = ""
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
if (j != 0)
tagString = tagString + ","
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
}
fromFile.tags = tagString
})
} }
FluIconButton { FluIconButton {
@ -201,5 +222,19 @@ FluArea {
width: parent.width width: parent.width
implicitHeight: 400 implicitHeight: 400
} }
// FistListItem {
// id: fileListItem
// uuid: fromFile.uuid
// fuuid: fromFile.fuuid
// title: fromFile.title
// date: fromFile.date
// brief: fromFile.brief
// type: fromFile.type
// pageView: fromFile.pageView
// size: fromFile.size
// stars: fromFile.stars
// tags: fromFile.tags === null || fromFile.tags === undefined
// || fromFile.tags === "" ? [] : fromFile.tags.split(",")
// }
} }
} }