| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef APPEVENT_H
- #define APPEVENT_H
- #include <QIODevice>
- #include <QObject>
- #include <QVariant>
- class AppEvent : public QObject
- {
- Q_OBJECT
- explicit AppEvent(QObject *parent = nullptr);
- ~AppEvent();
- public:
- static AppEvent *instance(); // 静态方法返回单例实例
- static qint64 time();
- static QString formatElapsedTime(qint64 ms);
- static void captureDesktop(QIODevice *device, const char *format = nullptr, int quality = -1);
- static void captureDesktop(const QString &path);
- static void saveTimeFile(qint64 elapsed, const QString &path);
- QString machineCode() const;
- // 语言设置
- QString locale() const;
- void setLocale(const QString &locale);
- //判断是否登录
- bool isLogin();
- void setJwtToken(const QString &token);
- QString jwtToken() const;
- bool isRefreshToken() const;
- void setRefreshTime(qint64 time) const;
- // 是否启用自动刷新令牌
- bool isEnableRefreshToken() const;
- void setEnableRefreshToken(bool enable);
- void setUserId(const QString &id);
- QString userId() const;
- void setUserName(const QString &id);
- QString userName() const;
- void setRoles(const QStringList &roles);
- QStringList roles() const;
- bool hasRole(const QString &role);
- // 配置
- bool setConfigValue(const QString &key, const QVariant &value);
- QVariant configValue(const QString &key);
- QVariant configReadValue(const QString &key, bool *isok = nullptr);
- bool configLoadJson(const QJsonObject &object);
- bool configLoad();
- bool configSave();
- QJsonObject config() const;
- void serverLink(bool);
- void unLockScreen();
- signals:
- void refreshTokenNeeded(); // 通知需要刷新 token
- void serverLinkSignals(int time);
- void unLockScreenSignals();
- void connectionStateChanged(bool); // websocket 在线标识
- // 登录过期的信号
- void loginExpired(bool expired);
- // 错误消息信号
- void errorMessage(const QString &message);
- private:
- class AppEventPrivate *d;
- };
- #endif // APPEVENT_H
|