impl pop to root

This commit is contained in:
王劲鹏 2021-06-10 11:31:46 +08:00 committed by osborn
parent ab0ab98aaa
commit dbbc7db31a
2 changed files with 27 additions and 1 deletions

View File

@ -175,4 +175,16 @@ ApplicationWindow {
navbar.visible = false navbar.visible = false
} }
} }
function navigatorPopToRoot() {
while (stack.depth > 1) {
stack.pop()
}
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
}
} }

View File

@ -92,6 +92,20 @@ void DoricNavigatorPlugin::popSelf(QString jsValueString, QString callbackId) {
} }
void DoricNavigatorPlugin::popToRoot(QString jsValueString, void DoricNavigatorPlugin::popToRoot(QString jsValueString,
QString callbackId) {} QString callbackId) {
getContext()->getDriver()->asyncCall(
[this] {
QObject *window = getContext()->getQmlEngine()->rootObjects().at(0);
QMetaObject::invokeMethod(window, "navigatorPopToRoot");
},
DoricThreadMode::UI);
getContext()->getDriver()->asyncCall(
[this, callbackId] {
QVariantList args;
DoricPromise::resolve(getContext(), callbackId, args);
},
DoricThreadMode::JS);
}
void DoricNavigatorPlugin::openUrl(QString jsValueString, QString callbackId) {} void DoricNavigatorPlugin::openUrl(QString jsValueString, QString callbackId) {}