Compare commits

..

2 Commits

Author SHA1 Message Date
yang.yongquan f40c6b2865 合并 2023-07-06 17:21:57 +08:00
yang.yongquan 95883878e3 使用stackView完成界面跳转 2023-07-06 17:16:55 +08:00
5 changed files with 166 additions and 112 deletions

View File

@ -4,6 +4,7 @@ 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"
@ -54,15 +55,76 @@ FluWindow {
} }
} }
StackView {
ContentPage { id: stack_view
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
type: "md" replaceEnter: Transition {
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"
// }
/* /*

View File

@ -5,4 +5,5 @@ 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,9 +40,10 @@ 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)
@ -52,13 +53,6 @@ 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
@ -69,6 +63,7 @@ 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
@ -77,7 +72,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 string publishTime: "2020-01-01" property var publishTime
property string brief: "这是一个简介" property string brief: "这是一个简介"
function getType(suffix) { function getType(suffix) {
@ -121,9 +116,20 @@ 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
@ -149,7 +155,7 @@ FluArea {
} }
} }
FluText { FluText {
text: "" text: content_page.noteCount
font.pointSize: 8 font.pointSize: 8
Layout.alignment: button_note.Center Layout.alignment: button_note.Center
Layout.topMargin: -5 Layout.topMargin: -5
@ -262,38 +268,47 @@ FluArea {
} }
} }
Loader {
id: content_view
Layout.fillWidth: true
sourceComponent: video_view
}
Component {
id: video_view
FluMediaPlayer {
Layout.fillWidth: true
implicitHeight: width * 9 / 16.
}
}
Component {
id: text_view
NoteEditPage {
noteId: "255454"
Layout.fillWidth: true
implicitHeight: 400
}
}
Component {
id: other_view
WebEngineView { WebEngineView {
Layout.fillWidth: true Layout.fillWidth: true
id: sitemonitory_view
backgroundColor: "transparent" backgroundColor: "transparent"
implicitHeight: 200 implicitHeight: 200
settings.javascriptEnabled: true settings.javascriptEnabled: true
settings.pluginsEnabled: true settings.pluginsEnabled: true
url: "https://www.baidu.com" url: "https://www.baidu.com"
} }
}
// StackView {
// id: content_view
// Layout.fillWidth: true
// implicitHeight: 400
// initialItem: other_view
// }
// Component {
// id: video_view
// FluMediaPlayer {
// width: parent.width
// implicitHeight: width * 9 / 16.
// }
// }
// Component {
// id: text_view
// NoteEditPage {
// noteId: "255454"
// width: parent.width
// implicitHeight: 400
// }
// }
// Component {
// id: other_view
// WebEngineView {
// 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 noteId property string noteFileId
property string isFile: false
property string knowledgeUrl : "aics/main/knowledge/"
signal clickTags(string tagName) signal clickTags(string tagName)
// paddings: { // paddings: {
@ -26,12 +26,6 @@ FluArea {
// bottom: 10 // bottom: 10
// left: 10 // left: 10
// } // }
Connections {
target: SignalFileOperation
function onOpen(file) {
}
}
FluScrollablePage { FluScrollablePage {
id: note_page id: note_page
@ -41,44 +35,45 @@ 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 list<string> tags: ["tag1", "tag2", "tag3"] property string title: "文章标题"
property string publishTime: "2002-01-01" property list<string> tags: ["tag 1", "tag 2", "tag 3"]
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" || suffix === "rmvb" || suffix === "mkv") else if(suffix === "mp4" || suffix === "avi"
return "video" || suffix === "rmvb" || suffix === "rm"
else return "other" || suffix === "wmv" || suffix === "mkv")
return "VIDEO"
else return "OTHER"
} }
function loadFile(noteId) { function loadFile(noteFileId) {
var fileUrl = knowledgeUrl+noteId note_area.noteFileId = noteFileId
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
} }
tags = tagString.split(",")
}) Component.onCompleted: {
}
FluIconButton {
iconSize: 12
iconSource: FluentIcons.Back
onClicked: {
emit: SignalFileOperation.back()
}
Layout.margins: -5
} }
Item { Item {
@ -88,7 +83,7 @@ FluArea {
FluText { FluText {
id: text_title id: text_title
padding: 10 padding: 10
text: "文章标题" text: note_page.title
font { font {
pointSize: 15 pointSize: 15
bold: true bold: true
@ -100,7 +95,7 @@ FluArea {
id: button_share id: button_share
iconSize: 15 iconSize: 15
iconSource: FluentIcons.Share iconSource: FluentIcons.Share
text: content_page.shareCount.toString() text: note_page.shareCount.toString()
} }
FluText { FluText {
id: text_share id: text_share
@ -118,12 +113,8 @@ 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
@ -146,7 +137,7 @@ FluArea {
} }
FluText { FluText {
id: text_like id: text_like
text: note_page.favoriteCount text: note_page.likeCount
font.pointSize: 8 font.pointSize: 8
Layout.alignment: button_like.Center Layout.alignment: button_like.Center
Layout.topMargin: -5 Layout.topMargin: -5
@ -156,20 +147,6 @@ 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 {
@ -177,32 +154,33 @@ FluArea {
implicitHeight: 100 implicitHeight: 100
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
width: parent.width
FluText { FluText {
padding: 10 padding: 10
text: content_page.publishTime text: note_page.publishTime
} }
FluText { FluText {
padding: 10 padding: 10
text: content_page.fileSize.toString() + "MB" text: note_page.fileSize.toString() + "MB"
} }
FluText { FluText {
padding: 10 padding: 10
text: content_page.browsCount.toString() + "浏览量" text: note_page.browsCount.toString() + "浏览量"
} }
} }
FluText { FluText {
Layout.topMargin: -2 Layout.topMargin: -2
Layout.leftMargin: 10 Layout.leftMargin: 10
text: content_page.brief text: note_page.brief
} }
RowLayout { RowLayout {
Layout.topMargin: 2 Layout.topMargin: 2
Layout.leftMargin: 5 Layout.leftMargin: 5
Repeater { Repeater {
model: content_page.tags model: note_page.tags
delegate: Button { delegate: Button {
Layout.margins: 2 Layout.margins: 2
text: "#" + content_page.tags[index] text: "#" + note_page.tags[index]
background: Rectangle { background: Rectangle {
implicitHeight: 10 implicitHeight: 10
implicitWidth: 10 implicitWidth: 10
@ -210,20 +188,18 @@ FluArea {
radius: 10 radius: 10
} }
onClicked: { onClicked: {
emit: content_area.clickTags(text) emit: note_area.clickTags(text)
} }
} }
} }
} }
} }
} }
NoteEditPage { NoteEditPage {
id: md_edit_page id: text_view
noteId: "255454" noteId: "255454"
Layout.fillWidth: true width: parent.width
implicitHeight: 400 implicitHeight: 400
} }
} }
} }