Compare commits

..

No commits in common. "f40c6b28654f0d45cd0aa4f1510da2928b8a2cac" and "1c6aba5baf715a8cd4cd5bc59bcf2be72323c2b2" have entirely different histories.

5 changed files with 111 additions and 165 deletions

View File

@ -4,7 +4,6 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import SignalFileOperation 1.0
import org.wangwenx190.FramelessHelper import org.wangwenx190.FramelessHelper
import "qrc:///AicsKnowledgeBase/qml/global" import "qrc:///AicsKnowledgeBase/qml/global"
import "qrc:///AicsKnowledgeBase/qml/page" import "qrc:///AicsKnowledgeBase/qml/page"
@ -55,77 +54,16 @@ FluWindow {
} }
} }
StackView {
id: stack_view ContentPage {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 45 Layout.topMargin: 45
Layout.bottomMargin: 4 Layout.bottomMargin: 4
Layout.rightMargin: 4 Layout.rightMargin: 4
replaceEnter: Transition { type: "md"
PropertyAnimation {
target: stack_view
property: "opacity"
from: 0
to: 1
duration:700
easing.type: Easing.InOutElastic;
easing.amplitude: 2.0;
easing.period: 1.5
}
}
replaceExit: Transition {
PropertyAnimation {
target: stack_view
property: "opacity"
from: 1
to: 0
duration:500
easing.type: Easing.InOutElastic;
easing.amplitude: 2.0;
easing.period: 1.5
}
}
} }
Connections {
target: SignalFileOperation
function onOpen(file) {
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 {
}
}
// ContentPage {
// Layout.fillHeight: true
// Layout.fillWidth: true
// Layout.topMargin: 45
// Layout.bottomMargin: 4
// Layout.rightMargin: 4
// type: "md"
// }
/* /*
FluArea { FluArea {

View File

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

View File

@ -40,10 +40,9 @@ FluArea {
id: content_area id: content_area
paddings: 0 paddings: 0
backgroundColor: "#f9f9f9" backgroundColor: "#f9f9f9"
// visible: false visible: false
property string type: "" property string type: ""
property string knowledgeFileId property string knowledgeFileId
signal back()
signal download(string knowledgeFileId) signal download(string knowledgeFileId)
signal clickTags(string tagName) signal clickTags(string tagName)
@ -53,6 +52,13 @@ FluArea {
// bottom: 10 // bottom: 10
// left: 10 // left: 10
// } // }
Connections {
target: SignalFileOperation
function onOpen(file) {
content_area.visible = true
content_page.loadFile(file)
}
}
FluScrollablePage { FluScrollablePage {
id: content_page id: content_page
@ -63,7 +69,6 @@ FluArea {
bottomPadding: 0 bottomPadding: 0
property string fileId property string fileId
property int noteCount: 0
property int favoriteCount: 0 property int favoriteCount: 0
property int shareCount: 0 property int shareCount: 0
property int browsCount: 555 property int browsCount: 555
@ -72,7 +77,7 @@ FluArea {
property double fileSize: 455 property double fileSize: 455
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: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
function getType(suffix) { function getType(suffix) {
@ -116,20 +121,9 @@ FluArea {
} }
Component.onCompleted: { Component.onCompleted: {
loadFile(knowledgeFileId)
console.log(content_area.type)
}
FluIconButton {
iconSize: 12
iconSource: FluentIcons.Back
onClicked: {
emit: SignalFileOperation.back()
}
Layout.margins: -5
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 50 implicitHeight: 50
@ -155,7 +149,7 @@ FluArea {
} }
} }
FluText { FluText {
text: content_page.noteCount text: ""
font.pointSize: 8 font.pointSize: 8
Layout.alignment: button_note.Center Layout.alignment: button_note.Center
Layout.topMargin: -5 Layout.topMargin: -5
@ -268,47 +262,38 @@ FluArea {
} }
} }
WebEngineView { Loader {
id: content_view
Layout.fillWidth: true Layout.fillWidth: true
backgroundColor: "transparent" sourceComponent: video_view
implicitHeight: 200
settings.javascriptEnabled: true
settings.pluginsEnabled: true
url: "https://www.baidu.com"
} }
// StackView { Component {
// id: content_view id: video_view
// Layout.fillWidth: true FluMediaPlayer {
// implicitHeight: 400 Layout.fillWidth: true
// initialItem: other_view implicitHeight: width * 9 / 16.
// } }
}
// Component { Component {
// id: video_view id: text_view
// FluMediaPlayer { NoteEditPage {
// width: parent.width noteId: "255454"
// implicitHeight: width * 9 / 16. Layout.fillWidth: true
// } implicitHeight: 400
// } }
// Component { }
// id: text_view Component {
// NoteEditPage { id: other_view
// noteId: "255454" WebEngineView {
// width: parent.width Layout.fillWidth: true
// implicitHeight: 400 id: sitemonitory_view
// } backgroundColor: "transparent"
// } implicitHeight: 200
// Component { settings.javascriptEnabled: true
// id: other_view settings.pluginsEnabled: true
// WebEngineView { url: "https://www.baidu.com"
// width: parent.width }
// backgroundColor: "transparent" }
// implicitHeight: 200
// settings.javascriptEnabled: true
// settings.pluginsEnabled: true
// url: "https://www.baidu.com"
// }
// }
} }
} }

View File

@ -8,16 +8,16 @@ import FluentUI
import AicsKB.FileTransferManager import AicsKB.FileTransferManager
import SignalFileOperation 1.0 import SignalFileOperation 1.0
import "qrc:///AicsKnowledgeBase/qml/page" import "qrc:///AicsKnowledgeBase/qml/page"
import "qrc:///AicsKnowledgeBase/qml/component"
import "qrc:///AicsKnowledgeBase/qml/global"
FluArea { 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 noteId
property string isFile: false
property string knowledgeUrl : "aics/main/knowledge/"
signal clickTags(string tagName) signal clickTags(string tagName)
// paddings: { // paddings: {
@ -26,6 +26,12 @@ FluArea {
// bottom: 10 // bottom: 10
// left: 10 // left: 10
// } // }
Connections {
target: SignalFileOperation
function onOpen(file) {
}
}
FluScrollablePage { FluScrollablePage {
id: note_page id: note_page
@ -35,45 +41,44 @@ FluArea {
rightPadding: 10 rightPadding: 10
bottomPadding: 0 bottomPadding: 0
property string fileId
property int likeCount: 0 property int likeCount: 0
property int favoriteCount: 0 property int favoriteCount: 0
property int shareCount: 0 property int shareCount: 0
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 bool isDownload: false
property double fileSize: 455 property double fileSize: 455
property string title: "文章标题" property list<string> tags: ["tag1", "tag2", "tag3"]
property list<string> tags: ["tag 1", "tag 2", "tag 3"] property string publishTime: "2002-01-01"
property string publishTime: "2020-01-01"
property string brief: "这是一个简介" property string brief: "这是一个简介"
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 === "mkv")
|| suffix === "rmvb" || suffix === "rm" return "video"
|| suffix === "wmv" || suffix === "mkv") else return "other"
return "VIDEO"
else return "OTHER"
} }
function loadFile(noteFileId) { function loadFile(noteId) {
note_area.noteFileId = noteFileId var fileUrl = knowledgeUrl+noteId
Request.get(fileUrl, function (response) {
} var data = JSON.parse(response)
console.log(data.knowledgeFileAttribute)
Component.onCompleted: { publishTime = data.createTime
type = getType(data.knowledgeFileAttribute.suffix)
} brief = data.knowledgeFileAttribute.brief
fileSize = data.knowledgeFileAttribute.size
FluIconButton { browsCount = data.knowledgeFileAttribute.pageView
iconSize: 12 var tagString = ""
iconSource: FluentIcons.Back for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) {
onClicked: { if (j != 0)
emit: SignalFileOperation.back() tagString = tagString + ","
} tagString = tagString + file.knowledgeFileAttribute.tags[j].name
Layout.margins: -5 }
tags = tagString.split(",")
})
} }
Item { Item {
@ -83,7 +88,7 @@ FluArea {
FluText { FluText {
id: text_title id: text_title
padding: 10 padding: 10
text: note_page.title text: "文章标题"
font { font {
pointSize: 15 pointSize: 15
bold: true bold: true
@ -95,7 +100,7 @@ FluArea {
id: button_share id: button_share
iconSize: 15 iconSize: 15
iconSource: FluentIcons.Share iconSource: FluentIcons.Share
text: note_page.shareCount.toString() text: content_page.shareCount.toString()
} }
FluText { FluText {
id: text_share id: text_share
@ -113,8 +118,12 @@ FluArea {
id: layout_favorite id: layout_favorite
FluIconButton { FluIconButton {
id: button_favorite id: button_favorite
iconSize: 15 iconSize: 15
iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar iconSource: note_page.isFavorite ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
onClicked: {
Request.put()
}
} }
FluText { FluText {
id: text_favorite id: text_favorite
@ -137,7 +146,7 @@ FluArea {
} }
FluText { FluText {
id: text_like id: text_like
text: note_page.likeCount text: note_page.favoriteCount
font.pointSize: 8 font.pointSize: 8
Layout.alignment: button_like.Center Layout.alignment: button_like.Center
Layout.topMargin: -5 Layout.topMargin: -5
@ -147,6 +156,20 @@ FluArea {
right: layout_favorite.left 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 { FluArea {
@ -154,33 +177,32 @@ FluArea {
implicitHeight: 100 implicitHeight: 100
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
width: parent.width
FluText { FluText {
padding: 10 padding: 10
text: note_page.publishTime text: content_page.publishTime
} }
FluText { FluText {
padding: 10 padding: 10
text: note_page.fileSize.toString() + "MB" text: content_page.fileSize.toString() + "MB"
} }
FluText { FluText {
padding: 10 padding: 10
text: note_page.browsCount.toString() + "浏览量" text: content_page.browsCount.toString() + "浏览量"
} }
} }
FluText { FluText {
Layout.topMargin: -2 Layout.topMargin: -2
Layout.leftMargin: 10 Layout.leftMargin: 10
text: note_page.brief text: content_page.brief
} }
RowLayout { RowLayout {
Layout.topMargin: 2 Layout.topMargin: 2
Layout.leftMargin: 5 Layout.leftMargin: 5
Repeater { Repeater {
model: note_page.tags model: content_page.tags
delegate: Button { delegate: Button {
Layout.margins: 2 Layout.margins: 2
text: "#" + note_page.tags[index] text: "#" + content_page.tags[index]
background: Rectangle { background: Rectangle {
implicitHeight: 10 implicitHeight: 10
implicitWidth: 10 implicitWidth: 10
@ -188,18 +210,20 @@ FluArea {
radius: 10 radius: 10
} }
onClicked: { onClicked: {
emit: note_area.clickTags(text) emit: content_area.clickTags(text)
} }
} }
} }
} }
} }
} }
NoteEditPage { NoteEditPage {
id: text_view id: md_edit_page
noteId: "255454" noteId: "255454"
width: parent.width Layout.fillWidth: true
implicitHeight: 400 implicitHeight: 400
} }
} }
} }

View File

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
&app, [url](QObject *obj, const QUrl &objUrl) { &app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl) if (!obj && url == objUrl)
QCoreApplication::exit(-1); QCoreApplication::exit(-1);
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
engine.load(url); engine.load(url);
auto result = QGuiApplication::exec(); auto result = QGuiApplication::exec();
httpClient->deleteLater(); httpClient->deleteLater();