mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 16:15:28 +08:00
FluNetwork add openLog funcation
This commit is contained in:
@ -54,6 +54,13 @@ int NetworkParams::getRetry(){
|
||||
return FluNetwork::getInstance()->retry();
|
||||
}
|
||||
|
||||
bool NetworkParams::getOpenLog(){
|
||||
if(!_openLog.isNull()){
|
||||
return _openLog.toBool();
|
||||
}
|
||||
return FluNetwork::getInstance()->openLog();
|
||||
}
|
||||
|
||||
DownloadParam::DownloadParam(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
@ -129,6 +136,11 @@ NetworkParams* NetworkParams::bind(QObject* target){
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::openLog(QVariant val){
|
||||
_openLog = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
QString NetworkParams::buildCacheKey(){
|
||||
QJsonObject obj;
|
||||
obj.insert("url",_url);
|
||||
@ -488,7 +500,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
|
||||
}
|
||||
|
||||
void FluNetwork::printRequestStartLog(QNetworkRequest request,NetworkParams* params){
|
||||
if(!_openLog){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
qDebug()<<"<------"<<qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString())<<"Request Start ------>";
|
||||
@ -516,7 +528,7 @@ void FluNetwork::printRequestStartLog(QNetworkRequest request,NetworkParams* par
|
||||
}
|
||||
|
||||
void FluNetwork::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){
|
||||
if(!_openLog){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
qDebug()<<"<------"<<qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString())<<"Request End ------>";
|
||||
|
@ -67,11 +67,13 @@ public:
|
||||
Q_INVOKABLE NetworkParams* setCacheMode(int val);
|
||||
Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false);
|
||||
Q_INVOKABLE NetworkParams* bind(QObject* target);
|
||||
Q_INVOKABLE NetworkParams* openLog(QVariant val);
|
||||
Q_INVOKABLE void go(NetworkCallable* result);
|
||||
QString buildCacheKey();
|
||||
QString method2String();
|
||||
int getTimeout();
|
||||
int getRetry();
|
||||
bool getOpenLog();
|
||||
public:
|
||||
DownloadParam* _downloadParam = nullptr;
|
||||
QObject* _target = nullptr;
|
||||
@ -85,6 +87,7 @@ public:
|
||||
QMap<QString, QVariant> _fileMap;
|
||||
int _timeout = -1;
|
||||
int _retry = -1;
|
||||
QVariant _openLog;
|
||||
int _cacheMode = FluNetworkType::CacheMode::NoCache;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user