From fd4d12de0ff7bef883df83d030a31ec92e6d9dc9 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sat, 20 Aug 2022 10:20:09 +0200 Subject: [PATCH] Alternate behaviour for openUrlOnNewPage in Tauri --- src-tauri/Cargo.lock | 3 ++- src-tauri/tauri.conf.json | 2 +- src/Javascript/index.js | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ac3f9ed7..6bfacc36 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2762,7 +2762,8 @@ dependencies = [ [[package]] name = "tauri-plugin-localhost" version = "0.1.0" -source = "git+https://github.com/icidasset/tauri-plugin-localhost?branch=127.0.0.1#e12353ad5343066470b8d1cd5296f7a1974e9909" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f20786ccff879045f6bafec445fb5c6740c0c057372d2f992ae1281e4658c681" dependencies = [ "serde_json", "tauri", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dd9d10b3..5becfe73 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ "devPath": "../build", "beforeDevCommand": "", "beforeBuildCommand": "", - "withGlobalTauri": false + "withGlobalTauri": true }, "tauri": { "bundle": { diff --git a/src/Javascript/index.js b/src/Javascript/index.js index 4ea6baea..28d5239a 100644 --- a/src/Javascript/index.js +++ b/src/Javascript/index.js @@ -116,7 +116,15 @@ function initialise(reg) { // Other ports app.ports.openUrlOnNewPage.subscribe(url => { - window.open(url, "_blank") + if (__TAURI__) { + __TAURI__.shell.open( + url.includes("://") ? url : `${location.origin}/${url.replace(/^\.\//, "")}` + ) + + } else { + window.open(url, "_blank") + + } }) app.ports.reloadApp.subscribe(_ => { -- knotmirror 0.0.1