diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 673c7ac..30adf9b 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -113,6 +113,9 @@ QMessageBox::information(this, "错误", "获取http请求的token失败,程序即将退出"); QTimer::singleShot(100, qApp, SLOT(quit())); + } else { + connect(TimerCounterUtil::getInstance().tokenTimer, &QTimer::timeout, this, &CounterWindowRT::initHttpToken); + TimerCounterUtil::getInstance().tokenTimer->start(1000 * 3600 * 8); } // 初始化设备和通道 diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 673c7ac..30adf9b 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -113,6 +113,9 @@ QMessageBox::information(this, "错误", "获取http请求的token失败,程序即将退出"); QTimer::singleShot(100, qApp, SLOT(quit())); + } else { + connect(TimerCounterUtil::getInstance().tokenTimer, &QTimer::timeout, this, &CounterWindowRT::initHttpToken); + TimerCounterUtil::getInstance().tokenTimer->start(1000 * 3600 * 8); } // 初始化设备和通道 diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index d934324..b672cfc 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -59,7 +59,7 @@ QVector alarmChannel; QVector offlineChannel; - int initHttpToken(); + void getDeviceList(); QList getClockNumList(); void getChannelList(QString deviceId); @@ -71,6 +71,8 @@ private slots: void updateDateAndTime(); + int initHttpToken(); + void on_btnMenuMin_clicked(); void on_btnMenuSetting_clicked(); void onTrayIconActived(QSystemTrayIcon::ActivationReason reason); diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 673c7ac..30adf9b 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -113,6 +113,9 @@ QMessageBox::information(this, "错误", "获取http请求的token失败,程序即将退出"); QTimer::singleShot(100, qApp, SLOT(quit())); + } else { + connect(TimerCounterUtil::getInstance().tokenTimer, &QTimer::timeout, this, &CounterWindowRT::initHttpToken); + TimerCounterUtil::getInstance().tokenTimer->start(1000 * 3600 * 8); } // 初始化设备和通道 diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index d934324..b672cfc 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -59,7 +59,7 @@ QVector alarmChannel; QVector offlineChannel; - int initHttpToken(); + void getDeviceList(); QList getClockNumList(); void getChannelList(QString deviceId); @@ -71,6 +71,8 @@ private slots: void updateDateAndTime(); + int initHttpToken(); + void on_btnMenuMin_clicked(); void on_btnMenuSetting_clicked(); void onTrayIconActived(QSystemTrayIcon::ActivationReason reason); diff --git a/CounterRealTime/common/utils/TimerCounterUtil.h b/CounterRealTime/common/utils/TimerCounterUtil.h index 6aa645a..9847a0c 100644 --- a/CounterRealTime/common/utils/TimerCounterUtil.h +++ b/CounterRealTime/common/utils/TimerCounterUtil.h @@ -20,12 +20,14 @@ QTimer * clockCounter; // 界面刷新时间定时器 // QTimer * alamrCounter; // 请求报警定时器 QTimer * heartCounter; // 心跳定时器 + QTimer * tokenTimer; // timer for get http tokens private: TimerCounterUtil() { clockCounter = new QTimer(); heartCounter = new QTimer(); + tokenTimer = new QTimer(); } };