#pragma once #include #include #include #include "EventModule.h" /** * @brief 消息分发器 */ class WEBQT_EXPORT WebEventDispatch : public QObject { Q_OBJECT public: /** * @brief WebEngineView 消息分发器 * @param parent原生父类对象 */ WebEventDispatch(QObject* parent); ~WebEventDispatch(); signals: void signalToWeb(const QString& json); // QT给JS发送数据 public slots: QString msgToQt(const QString& msg); /** * @brief 添加事件处理模块 * @param eventModule 事件处理模块 */ void addEventModule(EventModule* eventModule, bool deleted = true); private: struct EventData { EventModule* eventModule; bool deleted; }; static void brostcastToWeb(const QString& json); std::unordered_map _events; friend class EventModule; };