diff --git a/doric-android/doric/src/main/java/pub/doric/plugin/NavigatorPlugin.java b/doric-android/doric/src/main/java/pub/doric/plugin/NavigatorPlugin.java index a4695293..dc9525e2 100644 --- a/doric-android/doric/src/main/java/pub/doric/plugin/NavigatorPlugin.java +++ b/doric-android/doric/src/main/java/pub/doric/plugin/NavigatorPlugin.java @@ -25,6 +25,7 @@ import com.github.pengfeizhou.jscore.JSValue; import com.github.pengfeizhou.jscore.JavaValue; import pub.doric.Doric; +import pub.doric.DoricActivity; import pub.doric.DoricContext; import pub.doric.extension.bridge.DoricMethod; import pub.doric.extension.bridge.DoricPlugin; @@ -53,6 +54,7 @@ public class NavigatorPlugin extends DoricJavaPlugin { String alias = source; String extra = ""; JSValue config = jsObject.getProperty("config"); + boolean singlePage = false; if (config.isObject()) { JSValue aliasJS = config.asObject().getProperty("alias"); if (aliasJS.isString()) { @@ -62,11 +64,23 @@ public class NavigatorPlugin extends DoricJavaPlugin { if (extraJS.isString()) { extra = extraJS.asString().value(); } + JSValue singlePageJS = config.asObject().getProperty("singlePage"); + if (singlePageJS.isBoolean()) { + singlePage = singlePageJS.asBoolean().value(); + } + } + if (singlePage) { + navigator.push(jsObject.getProperty("source").asString().value(), + alias, + extra + ); + } else { + Intent intent = new Intent(getDoricContext().getContext(), DoricActivity.class); + intent.putExtra("source", source); + intent.putExtra("alias", alias); + intent.putExtra("extra", extra); + getDoricContext().getContext().startActivity(intent); } - navigator.push(jsObject.getProperty("source").asString().value(), - alias, - extra - ); promise.resolve(); } catch (ArchiveException e) { e.printStackTrace(); diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 9082763e..01f087e4 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -818,6 +818,7 @@ declare module 'doric/lib/src/native/navigator' { alias?: string | undefined; animated?: boolean | undefined; extra?: object | undefined; + singlePage?: boolean | undefined; } | undefined) => Promise; pop: (animated?: boolean) => Promise; openUrl: (url: string) => Promise; diff --git a/doric-js/lib/src/native/navigator.d.ts b/doric-js/lib/src/native/navigator.d.ts index 9224739b..be065872 100644 --- a/doric-js/lib/src/native/navigator.d.ts +++ b/doric-js/lib/src/native/navigator.d.ts @@ -4,6 +4,7 @@ export declare function navigator(context: BridgeContext): { alias?: string | undefined; animated?: boolean | undefined; extra?: object | undefined; + singlePage?: boolean | undefined; } | undefined) => Promise; pop: (animated?: boolean) => Promise; openUrl: (url: string) => Promise; diff --git a/doric-js/src/native/navigator.ts b/doric-js/src/native/navigator.ts index 2d596375..9d8ff547 100644 --- a/doric-js/src/native/navigator.ts +++ b/doric-js/src/native/navigator.ts @@ -22,6 +22,7 @@ export function navigator(context: BridgeContext) { alias?: string, animated?: boolean, extra?: object, + singlePage?: boolean, }) => { if (config && config.extra) { (config as any).extra = JSON.stringify(config.extra)