add asset js loader & export doric classes
This commit is contained in:
19
doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp
Normal file
19
doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "DoricAssetJSLoader.h"
|
||||
|
||||
#include "utils/DoricUtils.h"
|
||||
|
||||
DoricAssetJSLoader::DoricAssetJSLoader() {}
|
||||
|
||||
bool DoricAssetJSLoader::filter(QString source) {
|
||||
return source.startsWith("assets");
|
||||
}
|
||||
|
||||
std::shared_ptr<DoricAsyncResult> DoricAssetJSLoader::request(QString source) {
|
||||
QString protocol = "assets://";
|
||||
QString assetPath = source.mid(protocol.length());
|
||||
|
||||
std::shared_ptr<DoricAsyncResult> asyncResult =
|
||||
std::make_shared<DoricAsyncResult>();
|
||||
|
||||
return asyncResult;
|
||||
}
|
17
doric-Qt/example/doric/loader/DoricAssetJSLoader.h
Normal file
17
doric-Qt/example/doric/loader/DoricAssetJSLoader.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DORICASSETJSLOADER_H
|
||||
#define DORICASSETJSLOADER_H
|
||||
|
||||
#include "DoricExport.h"
|
||||
|
||||
#include "DoricInterfaceLoader.h"
|
||||
|
||||
class DORIC_EXPORT DoricAssetJSLoader : public DoricInterfaceLoader {
|
||||
public:
|
||||
DoricAssetJSLoader();
|
||||
|
||||
virtual bool filter(QString source) override;
|
||||
|
||||
virtual std::shared_ptr<DoricAsyncResult> request(QString source) override;
|
||||
};
|
||||
|
||||
#endif // DORICASSETJSLOADER_H
|
@@ -1,11 +1,13 @@
|
||||
#ifndef DORICINTERFACELOADER_H
|
||||
#define DORICINTERFACELOADER_H
|
||||
|
||||
#include "async/DoricAsyncResult.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class DoricInterfaceLoader {
|
||||
#include "DoricExport.h"
|
||||
|
||||
#include "async/DoricAsyncResult.h"
|
||||
|
||||
class DORIC_EXPORT DoricInterfaceLoader {
|
||||
public:
|
||||
virtual bool filter(QString source) = 0;
|
||||
|
||||
|
@@ -1,7 +1,10 @@
|
||||
#include "DoricJSLoaderManager.h"
|
||||
#include "DoricAssetJSLoader.h"
|
||||
|
||||
DoricJSLoaderManager::DoricJSLoaderManager() {
|
||||
qDebug() << "DoricJSLoaderManager constructor";
|
||||
|
||||
addJSLoader(new DoricAssetJSLoader());
|
||||
}
|
||||
|
||||
void DoricJSLoaderManager::addJSLoader(DoricInterfaceLoader *jsLoader) {
|
||||
|
@@ -3,9 +3,11 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "DoricExport.h"
|
||||
|
||||
#include "DoricInterfaceLoader.h"
|
||||
|
||||
class DoricJSLoaderManager {
|
||||
class DORIC_EXPORT DoricJSLoaderManager {
|
||||
private:
|
||||
static DoricJSLoaderManager *local_instance;
|
||||
|
||||
|
Reference in New Issue
Block a user