This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp

24 lines
586 B
C++
Raw Permalink Normal View History

#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());
2021-06-10 11:05:31 +08:00
QString script = DoricUtils::readAssetFile("/" + assetPath);
std::shared_ptr<DoricAsyncResult> asyncResult =
std::make_shared<DoricAsyncResult>();
2021-06-10 11:05:31 +08:00
asyncResult->setResult(script);
return asyncResult;
}