change to asset read

This commit is contained in:
王劲鹏
2021-06-10 11:05:31 +08:00
committed by osborn
parent 0b4b9c2ed6
commit e6cff004d0
7 changed files with 30 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
#include "DoricDemoBridge.h"
#include "DoricPanel.h"
#include "loader/DoricJSLoaderManager.h"
#include "utils/DoricDialogBridge.h"
#include "utils/DoricDraggableBridge.h"
#include "utils/DoricImageBridge.h"
@@ -36,9 +37,9 @@ DoricDemoBridge::DoricDemoBridge(QQmlApplicationEngine *engine, QObject *parent)
context->setContextProperty("draggableBridge", draggableBridge);
}
void DoricDemoBridge::navigate(QVariant route) {
void DoricDemoBridge::navigate(QVariant path, QVariant index) {
QString name;
switch (route.toInt()) {
switch (index.toInt()) {
case 0:
name = "ComponetDemo.js";
break;
@@ -109,7 +110,12 @@ void DoricDemoBridge::navigate(QVariant route) {
name = "TextDemo.js";
break;
}
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
QString resourcePath = path.toString();
std::shared_ptr<DoricAsyncResult> asyncResult =
DoricJSLoaderManager::getInstance()->request(resourcePath + name);
QString script = asyncResult->getResult();
QQmlComponent component(mEngine);
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));

View File

@@ -11,7 +11,7 @@ public:
QObject *parent = nullptr);
Q_INVOKABLE
void navigate(QVariant route);
void navigate(QVariant path, QVariant index);
private:
QQmlApplicationEngine *mEngine;