merge
commit
83c05d97c5
|
@ -103,6 +103,8 @@ AppFluWindow {
|
|||
function (result, data) {
|
||||
console.log(result)
|
||||
console.log(data)
|
||||
UserData.username = param.username
|
||||
|
||||
FluApp.navigate("/")
|
||||
window.close()
|
||||
}, function (p1, p2) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import QtQuick.Window
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
import SignalFileOperation 1.0
|
||||
import org.wangwenx190.FramelessHelper
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
import "qrc:///AicsKnowledgeBase/qml/page"
|
||||
|
@ -17,6 +18,7 @@ FluWindow {
|
|||
CustomAppBar {
|
||||
id: title_bar
|
||||
title: window.title
|
||||
username: UserData.username
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
|
@ -54,15 +56,91 @@ FluWindow {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ContentPage {
|
||||
StackView {
|
||||
id: stack_view
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 45
|
||||
Layout.bottomMargin: 4
|
||||
Layout.rightMargin: 4
|
||||
type: "md"
|
||||
pushEnter: Transition {
|
||||
PropertyAnimation {
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
pushExit: Transition {
|
||||
PropertyAnimation {
|
||||
property: "opacity"
|
||||
from: 1
|
||||
to: 0
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
popEnter: Transition {
|
||||
PropertyAnimation {
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
popExit: Transition {
|
||||
PropertyAnimation {
|
||||
property: "opacity"
|
||||
from: 1
|
||||
to: 0
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
initialItem: create_note_view
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SignalFileOperation
|
||||
function onOpen(file) {
|
||||
stack_view.clear()
|
||||
stack_view.push(file_view, {knowledgeFileId: file})
|
||||
}
|
||||
function onOpenNote(note) {
|
||||
stack_view.push(note_view, {
|
||||
"noteFileId": note
|
||||
})
|
||||
}
|
||||
function onBack() {
|
||||
if (stack_view.depth > 0)
|
||||
stack_view.pop()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: file_view
|
||||
ContentPage {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: note_view
|
||||
NotePage {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: create_note_view
|
||||
CreateNotePage {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ContentPage {
|
||||
// Layout.fillHeight: true
|
||||
// Layout.fillWidth: true
|
||||
// Layout.topMargin: 45
|
||||
// Layout.bottomMargin: 4
|
||||
// Layout.rightMargin: 4
|
||||
// type: "md"
|
||||
// }
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,12 +34,12 @@ FluButton {
|
|||
implicitWidth: Window.window == null ? 400 : Math.min(
|
||||
Window.window.width, 400)
|
||||
|
||||
implicitHeight: text_title.height + text_message.height + layout_actions.height
|
||||
implicitHeight: text_title.height + content.height + layout_actions.height
|
||||
color: 'transparent'
|
||||
radius: 5
|
||||
FluText {
|
||||
id: text_title
|
||||
font: FluTextStyle.TitleLarge
|
||||
font: FluTextStyle.Title
|
||||
text: "上传知识文件"
|
||||
topPadding: 20
|
||||
leftPadding: 20
|
||||
|
@ -51,11 +51,9 @@ FluButton {
|
|||
right: parent.right
|
||||
}
|
||||
}
|
||||
FluText {
|
||||
id: text_message
|
||||
font: FluTextStyle.Body
|
||||
wrapMode: Text.WrapAnywhere
|
||||
text: "content"
|
||||
|
||||
Row {
|
||||
id: content
|
||||
topPadding: 14
|
||||
leftPadding: 20
|
||||
rightPadding: 20
|
||||
|
@ -65,7 +63,13 @@ FluButton {
|
|||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
FluMultilineTextBox {
|
||||
id: brief_textbox
|
||||
width: parent.width - parent.leftPadding - parent.rightPadding
|
||||
placeholderText: "请输入简介"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: layout_actions
|
||||
height: 68
|
||||
|
@ -76,7 +80,7 @@ FluButton {
|
|||
243 / 255, 243 / 255, 243 / 255,
|
||||
blurBackground ? blurOpacity - 0.4 : 1)
|
||||
anchors {
|
||||
top: text_message.bottom
|
||||
top: content.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
@ -113,7 +117,7 @@ FluButton {
|
|||
return
|
||||
var body = {
|
||||
"name": name,
|
||||
"brief": "brief",
|
||||
"brief": brief_textbox.text,
|
||||
"size": size,
|
||||
"md5": md5,
|
||||
"tags": [],
|
||||
|
|
|
@ -5,4 +5,5 @@ import QtQuick
|
|||
QtObject {
|
||||
signal open(string file)
|
||||
signal openNote(string note)
|
||||
signal back()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property string username
|
||||
property string userId
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
singleton NavItems 1.0 NavItems.qml
|
||||
singleton FooterItems 1.0 FooterItems.qml
|
||||
singleton Request 1.0 Request.qml
|
||||
singleton UserData 1.0 UserData.qml
|
|
@ -29,7 +29,7 @@ FluArea {
|
|||
NoteList {
|
||||
id: noteList
|
||||
onOpen: function handle(noteId) {
|
||||
console.log("open note: " + noteId)
|
||||
emit: SignalFileOperation.openNote(noteId)
|
||||
}
|
||||
onCreateNote: function handle() {
|
||||
console.log("create note")
|
||||
|
@ -40,26 +40,20 @@ FluArea {
|
|||
id: content_area
|
||||
paddings: 0
|
||||
backgroundColor: "#f9f9f9"
|
||||
visible: false
|
||||
// visible: false
|
||||
property string type: ""
|
||||
property string knowledgeFileId
|
||||
signal back
|
||||
signal download(string knowledgeFileId)
|
||||
signal clickTags(string tagName)
|
||||
|
||||
|
||||
// paddings: {
|
||||
// top: 10
|
||||
// right: 0
|
||||
// bottom: 10
|
||||
// left: 10
|
||||
// }
|
||||
Connections {
|
||||
target: SignalFileOperation
|
||||
function onOpen(file) {
|
||||
content_area.visible = true
|
||||
content_page.loadFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
FluScrollablePage {
|
||||
id: content_page
|
||||
anchors.fill: parent
|
||||
|
@ -69,6 +63,7 @@ FluArea {
|
|||
bottomPadding: 0
|
||||
|
||||
property string fileId
|
||||
property int noteCount: 0
|
||||
property int favoriteCount: 0
|
||||
property int shareCount: 0
|
||||
property int browsCount: 555
|
||||
|
@ -77,23 +72,24 @@ FluArea {
|
|||
property double fileSize: 455
|
||||
property string title: "文章标题"
|
||||
property list<string> tags: ["tag 1", "tag 2", "tag 3"]
|
||||
property string publishTime: "2020-01-01"
|
||||
property var publishTime
|
||||
property string brief: "这是一个简介"
|
||||
|
||||
function getType(suffix) {
|
||||
if(suffix === "md")
|
||||
if (suffix === "md")
|
||||
return "MD"
|
||||
else if(suffix === "mp4" || suffix === "avi"
|
||||
|| suffix === "rmvb" || suffix === "rm"
|
||||
|| suffix === "wmv" || suffix === "mkv")
|
||||
else if (suffix === "mp4" || suffix === "avi" || suffix === "rmvb"
|
||||
|| suffix === "rm" || suffix === "wmv" || suffix === "mkv")
|
||||
return "VIDEO"
|
||||
else return "OTHER"
|
||||
else
|
||||
return "OTHER"
|
||||
}
|
||||
|
||||
function loadFile(knowledgeFileId) {
|
||||
content_area.knowledgeFileId = knowledgeFileId
|
||||
console.log(knowledgeFileId)
|
||||
Request.get("knowledge/" + knowledgeFileId, function (response, data) {
|
||||
Request.get("knowledge/" + knowledgeFileId,
|
||||
function (response, data) {
|
||||
content_page.publishTime = data.createTime
|
||||
content_page.title = data.name
|
||||
content_page.fileId = data.knowledgeFileAttribute.id
|
||||
|
@ -111,16 +107,42 @@ FluArea {
|
|||
content_page.brief = data.knowledgeFileAttribute.brief
|
||||
content_page.browsCount = data.knowledgeFileAttribute.pageView
|
||||
|
||||
var starers = data.knowledgeFileAttribute.starers
|
||||
for(var i=0; i<starers.length; i++) {
|
||||
// var starers = data.knowledgeFileAttribute.starers
|
||||
// for (var i = 0; i < starers.length; i++) {
|
||||
|
||||
// }
|
||||
// content_page.favoriteCount = starers.length
|
||||
if (content_area.type === "MD") {
|
||||
FileTransferManager.getMarkdown(content_page.fileId)
|
||||
} else if (content_area.type === "VIDEO") {
|
||||
|
||||
} else {
|
||||
Request.get("knowledge/" + knowledgeFileId + "/preview/external",
|
||||
function (res) {
|
||||
content_view.push(other_view, {
|
||||
"url": res
|
||||
})
|
||||
})
|
||||
}
|
||||
content_page.favoriteCount = starers.length
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Connections {
|
||||
target: FileTransferManager
|
||||
onMarkdownData: data => {
|
||||
content_view.push(text_view, {contentMd: data})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
loadFile(knowledgeFileId)
|
||||
console.log(content_area.type)
|
||||
}
|
||||
|
||||
FluText {
|
||||
font.pointSize: 12
|
||||
Layout.margins: -5
|
||||
}
|
||||
|
||||
Item {
|
||||
|
@ -130,7 +152,7 @@ FluArea {
|
|||
FluText {
|
||||
id: text_title
|
||||
padding: 10
|
||||
text: content_page.title
|
||||
text: content_page.title.split(".")[0]
|
||||
font {
|
||||
pointSize: 15
|
||||
bold: true
|
||||
|
@ -148,7 +170,7 @@ FluArea {
|
|||
}
|
||||
}
|
||||
FluText {
|
||||
text: ""
|
||||
text: content_page.noteCount
|
||||
font.pointSize: 8
|
||||
Layout.alignment: button_note.Center
|
||||
Layout.topMargin: -5
|
||||
|
@ -208,8 +230,11 @@ FluArea {
|
|||
}
|
||||
onClicked: {
|
||||
emit: content_area.download(content_area.knowledgeFileId)
|
||||
FileTransferManager.download(content_area.knowledgeFileId)
|
||||
//FileTransferManager.getMarkdown(content_page.fileId)
|
||||
FileTransferManager.download(content_page.fileId,
|
||||
content_page.title)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,16 +285,24 @@ FluArea {
|
|||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
// WebEngineView {
|
||||
// Layout.fillWidth: true
|
||||
// backgroundColor: "transparent"
|
||||
// implicitHeight: 200
|
||||
// settings.javascriptEnabled: true
|
||||
// settings.pluginsEnabled: true
|
||||
// url: "https://www.baidu.com"
|
||||
// }
|
||||
StackView {
|
||||
id: content_view
|
||||
Layout.fillWidth: true
|
||||
sourceComponent: video_view
|
||||
height: width*10/16
|
||||
}
|
||||
|
||||
Component {
|
||||
id: video_view
|
||||
FluMediaPlayer {
|
||||
Layout.fillWidth: true
|
||||
width: parent.width
|
||||
implicitHeight: width * 9 / 16.
|
||||
}
|
||||
}
|
||||
|
@ -277,15 +310,14 @@ FluArea {
|
|||
id: text_view
|
||||
NoteEditPage {
|
||||
noteId: "255454"
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 400
|
||||
width: parent.width
|
||||
height: width*9/16
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: other_view
|
||||
WebEngineView {
|
||||
Layout.fillWidth: true
|
||||
id: sitemonitory_view
|
||||
width: parent.width
|
||||
backgroundColor: "transparent"
|
||||
implicitHeight: 200
|
||||
settings.javascriptEnabled: true
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import QtWebEngine 1.2
|
||||
import FluentUI
|
||||
import AicsKB.FileTransferManager
|
||||
import SignalFileOperation 1.0
|
||||
import "qrc:///AicsKnowledgeBase/qml/page"
|
||||
import "qrc:///AicsKnowledgeBase/qml/component"
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
|
||||
FluArea {
|
||||
id: edit_area
|
||||
paddings: 0
|
||||
backgroundColor: "#f9f9f9"
|
||||
property string noteTitle
|
||||
property string noteContent
|
||||
|
||||
Component.onCompleted: {
|
||||
noteTitle = Qt.binding(function() {
|
||||
return input_title.text
|
||||
})
|
||||
noteContent = Qt.binding(function() {
|
||||
return input_md.contentMd
|
||||
})
|
||||
}
|
||||
|
||||
FluScrollablePage {
|
||||
id: edit_page
|
||||
anchors.fill: parent
|
||||
leftPadding: 5
|
||||
topPadding: 5
|
||||
rightPadding: 5
|
||||
bottomPadding: 0
|
||||
RowLayout {
|
||||
FluIconButton {
|
||||
iconSize: 12
|
||||
iconSource: FluentIcons.Back
|
||||
onClicked: {
|
||||
emit: SignalFileOperation.back()
|
||||
}
|
||||
Layout.margins: -5
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 50
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
FluText {
|
||||
padding: 10
|
||||
text: "标题"
|
||||
font {
|
||||
pointSize: 15
|
||||
bold: true
|
||||
}
|
||||
}
|
||||
FluTextBox {
|
||||
id: input_title
|
||||
padding: 10
|
||||
placeholderText:"单行输入框"
|
||||
implicitWidth: parent.width
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FluText {
|
||||
padding: 10
|
||||
text: "内容"
|
||||
font {
|
||||
pointSize: 15
|
||||
bold: true
|
||||
}
|
||||
}
|
||||
|
||||
NoteEditPage {
|
||||
id: input_md
|
||||
noteId: "255454"
|
||||
width: parent.width
|
||||
height: width*9/16
|
||||
isEditable: true
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.topMargin: 10
|
||||
FluFilledButton {
|
||||
text: "上传"
|
||||
onClicked: {
|
||||
console.log(noteTitle)
|
||||
console.log(noteContent)
|
||||
}
|
||||
}
|
||||
FluButton {
|
||||
text: "取消"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,10 @@ FluArea {
|
|||
paddings: 0
|
||||
backgroundColor: "#f9f9f9"
|
||||
property string noteId: "234"
|
||||
property string contentMd: ""
|
||||
property bool isEditing: false
|
||||
property bool isEditable: false
|
||||
Layout.fillWidth: true
|
||||
|
||||
FluScrollablePage {
|
||||
id: edit_page
|
||||
|
@ -20,21 +24,16 @@ FluArea {
|
|||
rightPadding: 5
|
||||
bottomPadding: 0
|
||||
|
||||
property string contentMd: "**ssijfdijgo**\ndfdgfdggggggggggggggggggggggggggggggggggggggggggggggggggg"
|
||||
property bool isEditing: false
|
||||
property bool isEditable: false
|
||||
|
||||
Component.onCompleted: {
|
||||
edit_page.isEditable = true
|
||||
|
||||
textArea_edit.text = edit_page.contentMd
|
||||
edit_page.contentMd = Qt.binding(
|
||||
textArea_edit.text = edit_area.contentMd
|
||||
edit_area.contentMd = Qt.binding(
|
||||
function() {
|
||||
return textArea_edit.text
|
||||
})
|
||||
textArea_preview.text = Qt.binding(
|
||||
function() {
|
||||
return edit_page.contentMd
|
||||
return edit_area.contentMd
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -46,7 +45,7 @@ FluArea {
|
|||
id: button_edit
|
||||
iconSource: FluentIcons.Edit
|
||||
iconSize: 12
|
||||
visible: edit_page.isEditable
|
||||
visible: edit_area.isEditable
|
||||
anchors {
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
|
@ -72,7 +71,7 @@ FluArea {
|
|||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
onClicked: {
|
||||
button_edit.visible = edit_page.isEditable
|
||||
button_edit.visible = edit_area.isEditable
|
||||
button_save.visible = false
|
||||
button_preview.visible = false
|
||||
button_subfield.visible = false
|
||||
|
@ -153,7 +152,7 @@ FluArea {
|
|||
property bool isPreviewShowing: true
|
||||
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 300
|
||||
implicitHeight: width * 8/16
|
||||
|
||||
ScrollView {
|
||||
id: edit_show_view
|
||||
|
|
|
@ -8,16 +8,16 @@ import FluentUI
|
|||
import AicsKB.FileTransferManager
|
||||
import SignalFileOperation 1.0
|
||||
import "qrc:///AicsKnowledgeBase/qml/page"
|
||||
import "qrc:///AicsKnowledgeBase/qml/component"
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
|
||||
FluArea {
|
||||
id: note_area
|
||||
paddings: 0
|
||||
backgroundColor: "#f9f9f9"
|
||||
visible: false
|
||||
// visible: false
|
||||
property string type: ""
|
||||
property string noteId
|
||||
property string isFile: false
|
||||
property string knowledgeUrl : "aics/main/knowledge/"
|
||||
property string noteFileId
|
||||
signal clickTags(string tagName)
|
||||
|
||||
// paddings: {
|
||||
|
@ -26,12 +26,6 @@ FluArea {
|
|||
// bottom: 10
|
||||
// left: 10
|
||||
// }
|
||||
Connections {
|
||||
target: SignalFileOperation
|
||||
function onOpen(file) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
FluScrollablePage {
|
||||
id: note_page
|
||||
|
@ -41,44 +35,45 @@ FluArea {
|
|||
rightPadding: 10
|
||||
bottomPadding: 0
|
||||
|
||||
property string fileId
|
||||
property int likeCount: 0
|
||||
property int favoriteCount: 0
|
||||
property int shareCount: 0
|
||||
property int browsCount: 555
|
||||
property bool isLike: false
|
||||
property bool isFavorite: false
|
||||
property bool isDownload: false
|
||||
property double fileSize: 455
|
||||
property list<string> tags: ["tag1", "tag2", "tag3"]
|
||||
property string publishTime: "2002-01-01"
|
||||
property string title: "文章标题"
|
||||
property list<string> tags: ["tag 1", "tag 2", "tag 3"]
|
||||
property string publishTime: "2020-01-01"
|
||||
property string brief: "这是一个简介"
|
||||
|
||||
function getType(suffix) {
|
||||
if(suffix === "md")
|
||||
return "md"
|
||||
else if(suffix === "mp4" || suffix === "avi" || suffix === "rmvb" || suffix === "mkv")
|
||||
return "video"
|
||||
else return "other"
|
||||
return "MD"
|
||||
else if(suffix === "mp4" || suffix === "avi"
|
||||
|| suffix === "rmvb" || suffix === "rm"
|
||||
|| suffix === "wmv" || suffix === "mkv")
|
||||
return "VIDEO"
|
||||
else return "OTHER"
|
||||
}
|
||||
|
||||
function loadFile(noteId) {
|
||||
var fileUrl = knowledgeUrl+noteId
|
||||
Request.get(fileUrl, function (response) {
|
||||
var data = JSON.parse(response)
|
||||
console.log(data.knowledgeFileAttribute)
|
||||
publishTime = data.createTime
|
||||
type = getType(data.knowledgeFileAttribute.suffix)
|
||||
brief = data.knowledgeFileAttribute.brief
|
||||
fileSize = data.knowledgeFileAttribute.size
|
||||
browsCount = data.knowledgeFileAttribute.pageView
|
||||
var tagString = ""
|
||||
for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
|
||||
if (j != 0)
|
||||
tagString = tagString + ","
|
||||
tagString = tagString + file.knowledgeFileAttribute.tags[j].name
|
||||
function loadNote(noteFileId) {
|
||||
note_area.noteFileId = noteFileId
|
||||
|
||||
}
|
||||
tags = tagString.split(",")
|
||||
})
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
}
|
||||
|
||||
FluIconButton {
|
||||
iconSize: 12
|
||||
iconSource: FluentIcons.Back
|
||||
onClicked: {
|
||||
emit: SignalFileOperation.back()
|
||||
}
|
||||
Layout.margins: -5
|
||||
}
|
||||
|
||||
Item {
|
||||
|
@ -88,7 +83,7 @@ FluArea {
|
|||
FluText {
|
||||
id: text_title
|
||||
padding: 10
|
||||
text: "文章标题"
|
||||
text: note_page.title
|
||||
font {
|
||||
pointSize: 15
|
||||
bold: true
|
||||
|
@ -100,7 +95,7 @@ FluArea {
|
|||
id: button_share
|
||||
iconSize: 15
|
||||
iconSource: FluentIcons.Share
|
||||
text: content_page.shareCount.toString()
|
||||
text: note_page.shareCount.toString()
|
||||
}
|
||||
FluText {
|
||||
id: text_share
|
||||
|
@ -118,12 +113,8 @@ FluArea {
|
|||
id: layout_favorite
|
||||
FluIconButton {
|
||||
id: button_favorite
|
||||
|
||||
iconSize: 15
|
||||
iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
|
||||
onClicked: {
|
||||
Request.put()
|
||||
}
|
||||
}
|
||||
FluText {
|
||||
id: text_favorite
|
||||
|
@ -146,7 +137,7 @@ FluArea {
|
|||
}
|
||||
FluText {
|
||||
id: text_like
|
||||
text: note_page.favoriteCount
|
||||
text: note_page.likeCount
|
||||
font.pointSize: 8
|
||||
Layout.alignment: button_like.Center
|
||||
Layout.topMargin: -5
|
||||
|
@ -156,20 +147,6 @@ FluArea {
|
|||
right: layout_favorite.left
|
||||
}
|
||||
}
|
||||
FluIconButton {
|
||||
id: button_download
|
||||
iconSize: 25
|
||||
iconSource: note_page.isDownload ? FluentIcons.OEM : FluentIcons.Download
|
||||
anchors {
|
||||
verticalCenter: text_title.verticalCenter
|
||||
right: layout_like.left
|
||||
rightMargin: 20
|
||||
}
|
||||
onClicked: {
|
||||
emit: content_area.download(content_area.knowledgeFileId)
|
||||
FileTransferManager.download(content_area.knowledgeFileId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluArea {
|
||||
|
@ -177,32 +154,33 @@ FluArea {
|
|||
implicitHeight: 100
|
||||
ColumnLayout {
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
FluText {
|
||||
padding: 10
|
||||
text: content_page.publishTime
|
||||
text: note_page.publishTime
|
||||
}
|
||||
FluText {
|
||||
padding: 10
|
||||
text: content_page.fileSize.toString() + "MB"
|
||||
text: note_page.fileSize.toString() + "MB"
|
||||
}
|
||||
FluText {
|
||||
padding: 10
|
||||
text: content_page.browsCount.toString() + "浏览量"
|
||||
text: note_page.browsCount.toString() + "浏览量"
|
||||
}
|
||||
}
|
||||
FluText {
|
||||
Layout.topMargin: -2
|
||||
Layout.leftMargin: 10
|
||||
text: content_page.brief
|
||||
text: note_page.brief
|
||||
}
|
||||
RowLayout {
|
||||
Layout.topMargin: 2
|
||||
Layout.leftMargin: 5
|
||||
Repeater {
|
||||
model: content_page.tags
|
||||
model: note_page.tags
|
||||
delegate: Button {
|
||||
Layout.margins: 2
|
||||
text: "#" + content_page.tags[index]
|
||||
text: "#" + note_page.tags[index]
|
||||
background: Rectangle {
|
||||
implicitHeight: 10
|
||||
implicitWidth: 10
|
||||
|
@ -210,20 +188,18 @@ FluArea {
|
|||
radius: 10
|
||||
}
|
||||
onClicked: {
|
||||
emit: content_area.clickTags(text)
|
||||
emit: note_area.clickTags(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NoteEditPage {
|
||||
id: md_edit_page
|
||||
id: text_view
|
||||
noteId: "255454"
|
||||
Layout.fillWidth: true
|
||||
width: parent.width
|
||||
implicitHeight: 400
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,7 +305,6 @@ bool httpDownload(const std::string &url, const std::string &savePath, const Fil
|
|||
return false;
|
||||
obj.totalSize = item.totalSize;//原始文件大小
|
||||
obj.file = std::ofstream(savePath, std::ios::binary | std::ios::app);
|
||||
|
||||
if (!obj.file.is_open()) {
|
||||
qDebug() << "Open File Failed";
|
||||
curl_easy_cleanup(obj.curlHandle);
|
||||
|
@ -348,8 +347,9 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam
|
|||
}
|
||||
|
||||
auto size = resJson["size"].toInteger();
|
||||
std::string savePath = "D:\\Downloads\\" + fileName.toStdString();
|
||||
QFileInfo fileInfo(savePath.c_str());
|
||||
std::string savePath = "D:\\Downloads\\" + fileName.toLocal8Bit().toStdString();
|
||||
qDebug() << savePath.c_str();
|
||||
QFileInfo fileInfo(QString::fromLocal8Bit(savePath.c_str()));
|
||||
int64_t completedSize = fileInfo.exists() ? fileInfo.size() : 0;
|
||||
FileItem item{true, fileId, fileName, completedSize, size};
|
||||
if (!resume)
|
||||
|
@ -359,14 +359,8 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam
|
|||
|
||||
auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), completedSize, size);
|
||||
auto res = httpDownload(fileUrl, savePath, item);
|
||||
/*auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), 0, size / 2);
|
||||
auto res = httpDownload(fileUrl, savePath, item);
|
||||
fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), size / 2, size);
|
||||
res = httpDownload(fileUrl, savePath, item);*/
|
||||
qDebug() << "End Get" << res;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
void FileTransferManager::pause(const QString &fileId)
|
||||
|
@ -403,3 +397,30 @@ QString FileTransferManager::getFileName(const QUrl &fileUrl)
|
|||
return fileUrl.fileName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FileTransferManager::getMarkdown(const QString &fileId)
|
||||
{
|
||||
QtConcurrent::run([fileId, this] {
|
||||
qDebug() << "Start Get";
|
||||
std::string resData;
|
||||
if (CURLE_OK != httpGet("File/" + fileId.toStdString() + "/status", resData))
|
||||
return;
|
||||
qDebug() << resData.c_str();
|
||||
auto resJson = QJsonDocument::fromJson(resData.c_str());
|
||||
if (!resJson["isCompleted"].toBool()) {
|
||||
qDebug() << "File Not Completed";
|
||||
return;
|
||||
}
|
||||
|
||||
auto size = resJson["size"].toInteger();
|
||||
auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), 0, size);
|
||||
std::string fileData;
|
||||
auto res = httpGet(fileUrl, fileData);
|
||||
//qDebug() << fileData.c_str();
|
||||
emit markdownData(QString::fromStdString(fileData));
|
||||
//qDebug() << "End Get" << res;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,21 +12,28 @@
|
|||
#include "FileTransferListModel.h"
|
||||
|
||||
|
||||
|
||||
class FileTransferManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileTransferManager(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE QString getFileName(const QUrl& fileUrl);
|
||||
Q_INVOKABLE int64_t getFileSize(const QUrl& fileUrl);
|
||||
Q_INVOKABLE QString getFileMd5(const QUrl& fileUrl);
|
||||
Q_INVOKABLE void upload(const QUrl& fileUrl, const QString& fileId, const QString& ticket, const QString &fileName);
|
||||
Q_INVOKABLE QString getFileName(const QUrl &fileUrl);
|
||||
|
||||
Q_INVOKABLE void download(const QString& fileId, const QString& fileName, bool resume = false);
|
||||
Q_INVOKABLE void pause(const QString& fileId);
|
||||
Q_INVOKABLE int64_t getFileSize(const QUrl &fileUrl);
|
||||
|
||||
Q_INVOKABLE QString getFileMd5(const QUrl &fileUrl);
|
||||
|
||||
Q_INVOKABLE void upload(const QUrl &fileUrl, const QString &fileId, const QString &ticket, const QString &fileName);
|
||||
|
||||
Q_INVOKABLE void download(const QString &fileId, const QString &fileName, bool resume = false);
|
||||
|
||||
Q_INVOKABLE void pause(const QString &fileId);
|
||||
|
||||
Q_INVOKABLE void getMarkdown(const QString &fileId);
|
||||
|
||||
signals:
|
||||
void markdownData(QString data);
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue