diff --git a/example/qml/page/T_Http.qml b/example/qml/page/T_Http.qml index 1ee6bbc3..e8a00bd7 100644 --- a/example/qml/page/T_Http.qml +++ b/example/qml/page/T_Http.qml @@ -102,7 +102,7 @@ FluContentPage{ param.custname = "朱子楚" param.custtel = "1234567890" param.custemail = "zhuzichu520@gmail.com" - http.postJson("https://httpbingo.org/post",callable,param) +// http.postJson("https://httpbingo.org/post",callable,param) } } FluButton{ @@ -125,7 +125,7 @@ FluContentPage{ console.debug(status+";"+errorString) } var param = "我命由我不由天" - http.postString("https://httpbingo.org/post",callable,param) +// http.postString("https://httpbingo.org/post",callable,param) } } FluButton{ diff --git a/example/qml/page/T_QRCode.qml b/example/qml/page/T_QRCode.qml index ec5fe15d..f7a89401 100644 --- a/example/qml/page/T_QRCode.qml +++ b/example/qml/page/T_QRCode.qml @@ -57,7 +57,7 @@ FluScrollablePage{ FluSlider{ id:slider_size from:60 - to:200 + to:260 value: 120 } } diff --git a/src/FluHttp.cpp b/src/FluHttp.cpp index 9831e56d..03f455e5 100644 --- a/src/FluHttp.cpp +++ b/src/FluHttp.cpp @@ -32,8 +32,8 @@ void FluHttp::handleReply(QNetworkReply* reply){ _cache.append(reply); } -void FluHttp::post(QString url,QJSValue callable,QVariantMap params,QVariantMap headers){ - QVariantMap data = invokeIntercept(params,headers,"post").toMap(); +void FluHttp::post(QString url,QJSValue callable,QMap params,QMap headers){ + QMap data = invokeIntercept(params,headers,"post").toMap(); QThreadPool::globalInstance()->start([=](){ onStart(callable); for (int i = 0; i < retry(); ++i) { @@ -82,8 +82,8 @@ void FluHttp::post(QString url,QJSValue callable,QVariantMap params,QVariantMap }); } -void FluHttp::postString(QString url,QJSValue callable,QString params,QVariantMap headers){ - QVariantMap data = invokeIntercept(params,headers,"postString").toMap(); +void FluHttp::postString(QString url,QJSValue callable,QString params,QMap headers){ + QMap data = invokeIntercept(params,headers,"postString").toMap(); QThreadPool::globalInstance()->start([=](){ onStart(callable); for (int i = 0; i < retry(); ++i) { @@ -121,8 +121,8 @@ void FluHttp::postString(QString url,QJSValue callable,QString params,QVariantMa }); } -void FluHttp::postJson(QString url,QJSValue callable,QVariantMap params,QVariantMap headers){ - QVariantMap data = invokeIntercept(params,headers,"postJson").toMap(); +void FluHttp::postJson(QString url,QJSValue callable,QMap params,QMap headers){ + QMap data = invokeIntercept(params,headers,"postJson").toMap(); QThreadPool::globalInstance()->start([=](){ onStart(callable); for (int i = 0; i < retry(); ++i) { @@ -160,8 +160,8 @@ void FluHttp::postJson(QString url,QJSValue callable,QVariantMap params,QVariant }); } -void FluHttp::get(QString url,QJSValue callable,QVariantMap params,QVariantMap headers){ - QVariantMap data = invokeIntercept(params,headers,"get").toMap(); +void FluHttp::get(QString url,QJSValue callable,QMap params,QMap headers){ + QMap data = invokeIntercept(params,headers,"get").toMap(); QThreadPool::globalInstance()->start([=](){ for (int i = 0; i < retry(); ++i) { onStart(callable); @@ -198,8 +198,8 @@ void FluHttp::get(QString url,QJSValue callable,QVariantMap params,QVariantMap h }); } -void FluHttp::download(QString url,QJSValue callable,QString filePath,QVariantMap params,QVariantMap headers){ - QVariantMap data = invokeIntercept(params,headers,"download").toMap(); +void FluHttp::download(QString url,QJSValue callable,QString filePath,QMap params,QMap headers){ + QMap data = invokeIntercept(params,headers,"download").toMap(); QThreadPool::globalInstance()->start([=](){ onStart(callable); QNetworkAccessManager manager; @@ -239,7 +239,7 @@ void FluHttp::download(QString url,QJSValue callable,QString filePath,QVariantMa } QVariant FluHttp::invokeIntercept(const QVariant& params,const QVariant& headers,const QString& method){ - QVariantMap requet = { + QMap requet = { {"params",params}, {"headers",headers}, {"method",method} diff --git a/src/FluHttp.h b/src/FluHttp.h index 3c60089b..6a253e1f 100644 --- a/src/FluHttp.h +++ b/src/FluHttp.h @@ -26,11 +26,12 @@ private: public: explicit FluHttp(QObject *parent = nullptr); ~FluHttp(); - Q_INVOKABLE void get(QString url,QJSValue callable,QVariantMap params = {},QVariantMap headers = {}); - Q_INVOKABLE void post(QString url,QJSValue callable,QVariantMap params = {},QVariantMap headers = {}); - Q_INVOKABLE void postString(QString url,QJSValue callable,QString params = "",QVariantMap headers = {}); - Q_INVOKABLE void postJson(QString url,QJSValue callable,QVariantMap params = {},QVariantMap headers = {}); - Q_INVOKABLE void download(QString url,QJSValue callable,QString filePath,QVariantMap params = {},QVariantMap headers = {}); + //神坑!!! 如果参数使用QVariantMap会有问题,在6.4.3版本中QML一调用就会编译失败。所有改用QMap + Q_INVOKABLE void get(QString url,QJSValue callable,QMap = {},QMap headers = {}); + Q_INVOKABLE void post(QString url,QJSValue callable,QMap = {},QMap headers = {}); + Q_INVOKABLE void postString(QString url,QJSValue callable,QString params = "",QMap headers = {}); + Q_INVOKABLE void postJson(QString url,QJSValue callable,QMap params = {},QMap headers = {}); + Q_INVOKABLE void download(QString url,QJSValue callable,QString filePath,QMap params = {},QMap headers = {}); Q_INVOKABLE void cancel(); private: QList> _cache; diff --git a/src/imports/FluentUI/qmldir b/src/imports/FluentUI/qmldir index fef6a183..52032839 100644 --- a/src/imports/FluentUI/qmldir +++ b/src/imports/FluentUI/qmldir @@ -81,4 +81,4 @@ FluTooltip 1.0 Controls/FluTooltip.qml FluTour 1.0 Controls/FluTour.qml FluTreeView 1.0 Controls/FluTreeView.qml FluWindow 1.0 Controls/FluWindow.qml -plugin fluentuiplugin \ No newline at end of file +plugin fluentuiplugin