From 7df3e61f9d917640b270b4f47e89cf5aeacdf240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Thu, 10 Jun 2021 11:36:34 +0800 Subject: [PATCH] impl open url --- .../example/doric/plugin/DoricNavigatorPlugin.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doric-Qt/example/doric/plugin/DoricNavigatorPlugin.cpp b/doric-Qt/example/doric/plugin/DoricNavigatorPlugin.cpp index 7f5b23e2..df7546a4 100644 --- a/doric-Qt/example/doric/plugin/DoricNavigatorPlugin.cpp +++ b/doric-Qt/example/doric/plugin/DoricNavigatorPlugin.cpp @@ -5,6 +5,7 @@ #include "loader/DoricJSLoaderManager.h" #include "utils/DoricUtils.h" +#include #include #include #include @@ -108,4 +109,15 @@ void DoricNavigatorPlugin::popToRoot(QString jsValueString, DoricThreadMode::JS); } -void DoricNavigatorPlugin::openUrl(QString jsValueString, QString callbackId) {} +void DoricNavigatorPlugin::openUrl(QString jsValueString, QString callbackId) { + getContext()->getDriver()->asyncCall( + [jsValueString] { QDesktopServices::openUrl(QUrl(jsValueString)); }, + DoricThreadMode::UI); + + getContext()->getDriver()->asyncCall( + [this, callbackId] { + QVariantList args; + DoricPromise::resolve(getContext(), callbackId, args); + }, + DoricThreadMode::JS); +}