FluentUI/src/FluApp.h
2023-07-20 18:26:47 +08:00

99 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef FLUAPP_H
#define FLUAPP_H
#include <QObject>
#include <QWindow>
#include <QtQml/qqml.h>
#include <QJsonArray>
#include <QQmlContext>
#include <QJsonObject>
#include <QQmlEngine>
#include "FluRegister.h"
#include "FluHttpInterceptor.h"
#include "stdafx.h"
/**
* @brief The FluApp class
*/
class FluApp : public QObject
{
Q_OBJECT
/**
* @brief initialRoute 初始路由
*/
Q_PROPERTY_AUTO(QString,initialRoute);
/**
* @brief routes 路由表
*/
Q_PROPERTY_AUTO(QJsonObject,routes);
/**
* @brief http拦截器
*/
Q_PROPERTY_AUTO(FluHttpInterceptor*,httpInterceptor);
QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON
private:
/**
* @brief FluApp 将默认构造函数设置为私有则qml创建单例就会走create工厂方法创建单例
* @param parent
*/
explicit FluApp(QObject *parent = nullptr);
public:
~FluApp();
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
static FluApp *getInstance();
/**
* @brief run
*/
Q_INVOKABLE void run();
/**
* @brief navigate
* @param route
* @param argument
* @param fluRegister
*/
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
/**
* @brief init
* @param window
*/
Q_INVOKABLE void init(QQuickWindow *window);
/**
* @brief awesomelist
* @param keyword
* @return
*/
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
/**
* @brief closeApp
*/
Q_INVOKABLE void closeApp();
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
public:
/**
* @brief wnds
*/
QMap<quint64, QQuickWindow*> wnds;
private:
static FluApp* m_instance;
/**
* @brief appWindow
*/
QWindow *appWindow;
};
#endif // FLUAPP_H