解决了ContentPage不显示视频播放器的问题

main
wuyize 2023-07-02 19:47:51 +08:00
parent 9ced807900
commit 9c5d8115cb
8 changed files with 82 additions and 18 deletions

View File

@ -4,7 +4,6 @@ import QtQuick.Controls
import QtQuick.Window
import QtQuick.Layouts
import org.wangwenx190.FramelessHelper
import AicsKB.HttpClient
import "qrc:///AicsKnowledgeBase/qml/global"
AppFluWindow {
@ -109,8 +108,8 @@ AppFluWindow {
}, function (p1, p2) {
console.log(p1)
console.log(p2)
//FluApp.navigate("/");
//window.close();
FluApp.navigate("/")
window.close()
btn_login.disabled = false
btn_login.text = "登录"
})

View File

@ -5,6 +5,7 @@ import QtQuick.Layouts
import FluentUI
Rectangle {
property string username: "用户名"
property string title: ""
property string darkText: "夜间模式"
property string minimizeText: "最小化"
@ -113,16 +114,25 @@ Rectangle {
Layout.margins: {
right: 10
}
text: "用户名"
text: username
}
Rectangle {
Item {
Layout.rightMargin: 10
color: FluColors.White
radius: 50
width: 32
height: 32
Rectangle {
anchors.fill: parent
color: "#d2d2d2"
radius: 50
}
Text {
anchors.centerIn: parent
text: username[0]
color: "#8a8a8a"
}
}
RowLayout {
Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: 5

View File

@ -23,6 +23,7 @@ Popup {
{
id: itemModel
ListElement {
name: "Apple"
progressValue: 0.1
}

View File

@ -5,7 +5,7 @@ import QtQuick
QtObject {
id: request
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-default/"
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-5604d062/"
//property string baseUrl: "http://192.168.156.74:8080/"
// GET

View File

@ -10,7 +10,7 @@ FluArea {
id: content_area
paddings: 0
backgroundColor: "#f9f9f9"
property string type: null
property string type: ""
property int knowledgeFileId
signal download(string knowledgeFileId)
signal clickTags(string tagName)
@ -42,14 +42,14 @@ FluArea {
property string brief: "这是一个简介"
Component.onCompleted: {
if(content_area.type == "video") {
console.log(content_area.type)
if (content_area.type == "video") {
content_view.sourceComponent = video_view
} else if(content_area.type == "md") {
} else if (content_area.type == "md") {
content_view.sourceComponent = text_view
} else {
content_view.sourceComponent = other_view
}
}
Item {
@ -133,7 +133,7 @@ FluArea {
rightMargin: 20
}
onClicked: {
emit: content_area.download(content_area.knowledgeFileId);
emit: content_area.download(content_area.knowledgeFileId)
}
}
}
@ -148,6 +148,7 @@ FluArea {
id: video_view
FluMediaPlayer {
Layout.fillWidth: true
implicitHeight: 270
}
}
Component {
@ -224,7 +225,7 @@ FluArea {
id: text_note
text: "笔记"
padding: 10
font{
font {
pointSize: 15
bold: true
}
@ -234,14 +235,11 @@ FluArea {
text: "发布笔记"
hoverColor: "blue"
normalColor: "black"
anchors{
anchors {
verticalCenter: text_note.verticalCenter
right: parent.right
}
}
}
}
}

View File

@ -3,7 +3,9 @@ import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Dialogs
import FluentUI
import AicsKB.FileTransferManager
import "qrc:///AicsKnowledgeBase/qml/component"
FluArea {
@ -22,6 +24,17 @@ FluArea {
FluButton {
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
FileTransferManager.upload(selectedFile)
}
}
}
FileList {}

View File

@ -3,8 +3,49 @@
//
#include "FileTransferManager.h"
#include <QDebug>
#include <curl/curl.h>
FileTransferManager::FileTransferManager(QObject *parent) : QObject(parent)
{
}
void FileTransferManager::upload(QUrl fileUrl)
{
qDebug() << fileUrl.fileName();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:4523/m1/2914957-0-default/");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "User-Agent: Apifox/1.0.0 (https://apifox.com)");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "ticket");
curl_mime_data(part, "<ticket>", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "rangeStart");
curl_mime_data(part, "<rangeStart>", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "rangeEnd");
curl_mime_data(part, "<rangeEnd>", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "data");
curl_mime_filedata(part, "<data>");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_mime_free(mime);
}
curl_easy_cleanup(curl);
}

View File

@ -7,12 +7,14 @@
#include <QObject>
#include <QUrl>
class FileTransferManager: public QObject
{
Q_OBJECT
public:
explicit FileTransferManager(QObject *parent = nullptr);
Q_INVOKABLE void upload(QUrl fileUrl);
};