change navigator source acquire

This commit is contained in:
王劲鹏 2021-06-10 11:16:20 +08:00 committed by osborn
parent e6cff004d0
commit a48dd1de2f

View File

@ -2,6 +2,7 @@
#include "DoricPanel.h" #include "DoricPanel.h"
#include "engine/DoricPromise.h" #include "engine/DoricPromise.h"
#include "loader/DoricJSLoaderManager.h"
#include "utils/DoricUtils.h" #include "utils/DoricUtils.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -26,9 +27,11 @@ void DoricNavigatorPlugin::push(QString jsValueString, QString callbackId) {
} }
getContext()->getDriver()->asyncCall( getContext()->getDriver()->asyncCall(
[this, alias] { [this, source, alias] {
QString name = alias; std::shared_ptr<DoricAsyncResult> asyncResult =
QString script = DoricUtils::readAssetFile("/doric/bundles", name); DoricJSLoaderManager::getInstance()->request(source);
QString script = asyncResult->getResult();
QQmlComponent component(getContext()->getQmlEngine()); QQmlComponent component(getContext()->getQmlEngine());
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml")); const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
@ -39,7 +42,7 @@ void DoricNavigatorPlugin::push(QString jsValueString, QString callbackId) {
new DoricPanel(getContext()->getQmlEngine(), quickItem); new DoricPanel(getContext()->getQmlEngine(), quickItem);
quickItem->setWidth(600); quickItem->setWidth(600);
quickItem->setHeight(800); quickItem->setHeight(800);
panel->config(script, name, NULL); panel->config(script, alias, NULL);
QObject *window = getContext()->getQmlEngine()->rootObjects().at(0); QObject *window = getContext()->getQmlEngine()->rootObjects().at(0);
QVariant arg = QVariant::fromValue(object); QVariant arg = QVariant::fromValue(object);