فهرست منبع

feat: `open_browser` bool attribute

YuKun Liu 3 سال پیش
والد
کامیت
9e04ce5342
2فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 1 0
      examples/link.rs
  2. 9 4
      packages/desktop/src/index.js

+ 1 - 0
examples/link.rs

@@ -16,6 +16,7 @@ fn app(cx: Scope) -> Element {
             p {
                 a {
                     href: "http://dioxuslabs.com/",
+                    "browser-open": "false",
                     onclick: |_| {
                         println!("Hello Dioxus");
                     },

+ 9 - 4
packages/desktop/src/index.js

@@ -414,10 +414,15 @@ class Interpreter {
               const target = event.target;
               const real_id = target.getAttribute(`dioxus-id`);
 
-              rpc.call("browser_open", {
-                mounted_dom_id: parseInt(real_id),
-                href: target.getAttribute("browser-href"),
-              })
+              if (target.getAttribute("browser-open") != "false") {
+                rpc.call("browser_open", {
+                  mounted_dom_id: parseInt(real_id),
+                  href: target.getAttribute("browser-href"),
+                });
+              } else {
+                window.location = target.getAttribute("browser-href");
+              }
+
             })
 
           } else {