Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion packages/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,39 @@ pub fn run() {
.hidden_title(true);

#[cfg(windows)]
let window_builder = window_builder.decorations(false);
let window_builder = {
let app_handle = app.clone();
window_builder
.decorations(false)
.on_navigation(move |url| {
let scheme = url.scheme();

// Allow internal Tauri protocols
if scheme == "tauri" || scheme == "app" || scheme == "file" {
return true;
}

// Allow localhost (dev server & local sidecar)
if scheme == "http" || scheme == "https" {
if let Some(host) = url.host_str() {
if host == "localhost" || host == "127.0.0.1" || host == "::1" {
return true;
}
}
// External URL - open in system browser
let _ = app_handle.opener().open_url(url.as_str(), None::<&str>);
return false;
}

// Handle special protocols (mailto, tel, etc.)
if scheme == "mailto" || scheme == "tel" {
let _ = app_handle.opener().open_url(url.as_str(), None::<&str>);
return false;
}

true
})
};

let window = window_builder.build().expect("Failed to create window");

Expand Down
10 changes: 10 additions & 0 deletions packages/desktop/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,18 @@ render(() => {

onMount(() => {
document.addEventListener("click", handleClick)

// Disable WebView2 browser context menu on Windows (Back/Forward buttons)
const handleContextMenu = platform.os === "windows" ? (e: MouseEvent) => e.preventDefault() : null
if (handleContextMenu) {
document.addEventListener("contextmenu", handleContextMenu, true)
}

onCleanup(() => {
document.removeEventListener("click", handleClick)
if (handleContextMenu) {
document.removeEventListener("contextmenu", handleContextMenu, true)
}
})
})

Expand Down
Loading