mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-27 05:38:37 +08:00
update
This commit is contained in:
parent
d014997d52
commit
29329d10df
@ -60,8 +60,9 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
onFinish: {
|
onFinish: {
|
||||||
btn_download.disabled = false
|
btn_download.disabled = false
|
||||||
|
btn_download.text = "下载文件"
|
||||||
}
|
}
|
||||||
onDownloadFileProgress:
|
onDownloadProgress:
|
||||||
(recv,total)=>{
|
(recv,total)=>{
|
||||||
var precent = (recv/total * 100).toFixed(0) + "%"
|
var precent = (recv/total * 100).toFixed(0) + "%"
|
||||||
btn_download.text = "下载中..."+precent
|
btn_download.text = "下载中..."+precent
|
||||||
|
@ -23,6 +23,7 @@ FluApp *FluApp::getInstance()
|
|||||||
FluApp::FluApp(QObject *parent)
|
FluApp::FluApp(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
|
httpInterceptor(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
FluApp::~FluApp(){
|
FluApp::~FluApp(){
|
||||||
|
@ -100,7 +100,6 @@ void FluHttp::get(QVariantMap params,QVariantMap headers){
|
|||||||
|
|
||||||
Q_INVOKABLE void FluHttp::download(QString path,QVariantMap params,QVariantMap headers){
|
Q_INVOKABLE void FluHttp::download(QString path,QVariantMap params,QVariantMap headers){
|
||||||
QVariantMap request = invokeIntercept(params,headers,"download").toMap();
|
QVariantMap request = invokeIntercept(params,headers,"download").toMap();
|
||||||
qDebug()<<request["headers"].toMap();
|
|
||||||
QThreadPool::globalInstance()->start([=](){
|
QThreadPool::globalInstance()->start([=](){
|
||||||
HttpClient client;
|
HttpClient client;
|
||||||
Q_EMIT start();
|
Q_EMIT start();
|
||||||
@ -110,7 +109,7 @@ Q_INVOKABLE void FluHttp::download(QString path,QVariantMap params,QVariantMap h
|
|||||||
.queryParams(request["params"].toMap())
|
.queryParams(request["params"].toMap())
|
||||||
.headers(request["headers"].toMap())
|
.headers(request["headers"].toMap())
|
||||||
.onDownloadProgress([=](qint64 recv, qint64 total) {
|
.onDownloadProgress([=](qint64 recv, qint64 total) {
|
||||||
Q_EMIT downloadFileProgress(recv,total);
|
Q_EMIT downloadProgress(recv,total);
|
||||||
})
|
})
|
||||||
.onDownloadFileSuccess([=](QString result) {
|
.onDownloadFileSuccess([=](QString result) {
|
||||||
Q_EMIT success(result);
|
Q_EMIT success(result);
|
||||||
@ -131,6 +130,9 @@ QVariant FluHttp::invokeIntercept(const QVariant& params,const QVariant& headers
|
|||||||
{"headers",headers},
|
{"headers",headers},
|
||||||
{"method",method}
|
{"method",method}
|
||||||
};
|
};
|
||||||
|
if(!FluApp::getInstance()->httpInterceptor()){
|
||||||
|
return requet;
|
||||||
|
}
|
||||||
QVariant target;
|
QVariant target;
|
||||||
QMetaObject::invokeMethod(FluApp::getInstance()->httpInterceptor(), "onIntercept",Q_RETURN_ARG(QVariant,target),Q_ARG(QVariant, requet));
|
QMetaObject::invokeMethod(FluApp::getInstance()->httpInterceptor(), "onIntercept",Q_RETURN_ARG(QVariant,target),Q_ARG(QVariant, requet));
|
||||||
return target;
|
return target;
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
Q_SIGNAL void finish();
|
Q_SIGNAL void finish();
|
||||||
Q_SIGNAL void error(int status,QString errorString);
|
Q_SIGNAL void error(int status,QString errorString);
|
||||||
Q_SIGNAL void success(QString result);
|
Q_SIGNAL void success(QString result);
|
||||||
Q_SIGNAL void downloadFileProgress(qint64 recv, qint64 total);
|
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
|
||||||
Q_INVOKABLE void get(QVariantMap params = {},QVariantMap headers = {});
|
Q_INVOKABLE void get(QVariantMap params = {},QVariantMap headers = {});
|
||||||
Q_INVOKABLE void post(QVariantMap params = {},QVariantMap headers = {});
|
Q_INVOKABLE void post(QVariantMap params = {},QVariantMap headers = {});
|
||||||
Q_INVOKABLE void postJson(QVariantMap params = {},QVariantMap headers = {});
|
Q_INVOKABLE void postJson(QVariantMap params = {},QVariantMap headers = {});
|
||||||
|
Loading…
Reference in New Issue
Block a user