This commit is contained in:
朱子楚\zhuzi 2023-09-04 22:49:50 +08:00
parent f60eaec07c
commit 54be482833
9 changed files with 44 additions and 14 deletions

View File

@ -164,6 +164,14 @@ FluContentPage{
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
}
}
FluButton{
implicitWidth: parent.width
implicitHeight: 36
text: "打开缓存路径"
onClicked: {
Qt.openUrlExternally("file:///"+cacheDirPath)
}
}
FluButton{
implicitWidth: parent.width
implicitHeight: 36

View File

@ -138,7 +138,7 @@ CustomWindow {
id:loader
lazy: true
anchors.fill: parent
source: "https://zhu-zichu.gitee.io/Qt6_155_LieflatPage.qml"
source: "https://zhu-zichu.gitee.io/Qt6_156_LieflatPage.qml"
}
}
front: Item{

View File

@ -165,6 +165,14 @@ FluContentPage{
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
}
}
FluButton{
implicitWidth: parent.width
implicitHeight: 36
text: "打开缓存路径"
onClicked: {
Qt.openUrlExternally("file:///"+cacheDirPath)
}
}
FluButton{
implicitWidth: parent.width
implicitHeight: 36

View File

@ -139,7 +139,7 @@ CustomWindow {
id:loader
lazy: true
anchors.fill: parent
source: "https://zhu-zichu.gitee.io/Qt5_155_LieflatPage.qml"
source: "https://zhu-zichu.gitee.io/Qt5_156_LieflatPage.qml"
}
}
front: Item{

View File

@ -37,7 +37,7 @@ int main(int argc, char *argv[])
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,true);
#endif
#ifdef Q_OS_MACOS
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);

View File

@ -10,7 +10,6 @@
#include <QTextStream>
#include <QDir>
#include "Def.h"
#include "MainThread.h"
#include "FluApp.h"
#include "FluTools.h"
@ -54,7 +53,7 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
Q_EMIT callable->finish();
return;
}
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
for (int i = 0; i < retry(); ++i) {
@ -94,7 +93,7 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
break;
}else{
if(i == retry()-1){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
Q_EMIT callable->error(status,errorString,result);
@ -102,7 +101,6 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
}
}
Q_EMIT callable->finish();
// Q_EMIT callable->finish();
});
}
@ -116,7 +114,7 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap<
Q_EMIT callable->finish();
return;
}
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
for (int i = 0; i < retry(); ++i) {
@ -147,7 +145,7 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap<
break;
}else{
if(i == retry()-1){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
Q_EMIT callable->error(status,errorString,result);
@ -168,7 +166,7 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMap<QString, QVariant
Q_EMIT callable->finish();
return;
}
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
for (int i = 0; i < retry(); ++i) {
@ -199,7 +197,7 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMap<QString, QVariant
break;
}else{
if(i == retry()-1){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
Q_EMIT callable->error(status,errorString,result);
@ -215,7 +213,7 @@ void FluHttp::get(QString url,HttpCallable* callable,QMap<QString, QVariant> par
auto requestMap = toRequest(url,params,headers,"get");
QMap<QString, QVariant> data = invokeIntercept(requestMap).toMap();
Q_EMIT callable->start();
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){
@ -250,7 +248,7 @@ void FluHttp::get(QString url,HttpCallable* callable,QMap<QString, QVariant> par
break;
}else{
if(i == retry()-1){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
Q_EMIT callable->cache(readCache(requestMap));
}
Q_EMIT callable->error(status,errorString,result);

View File

@ -8,6 +8,21 @@ import QtQuick.tooling 1.2
Module {
dependencies: ["QtQuick 2.0"]
Component {
name: "FluHttpType"
exports: ["FluentUI/FluHttpType 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "CacheMode"
values: {
"NoCache": 0,
"RequestFailedReadCache": 1,
"IfNoneCacheRequest": 2,
"FirstCacheThenRequest": 4
}
}
}
Component {
name: "FluCalendarViewType"
exports: ["FluentUI/FluCalendarViewType 1.0"]

View File

@ -40,6 +40,7 @@ void FluentUIPlugin::registerTypes(const char *uri)
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluHttpType::staticMetaObject, uri,major,minor,"FluHttpType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri,major,minor,"FluPageType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");