Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(windows): add WebView2 sandbox compatibility override

James Leong2042a29315c2
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 329719ec91..341312d593 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -29,6 +29,8 @@ use tauri_plugin_deep_link::DeepLinkExt;
const DESKTOP_TRAY_ID: &str = "main-tray";
const APP_CLOSE_REQUESTED_EVENT: &str = "dbx-app-close-requested";
+#[cfg(target_os = "windows")]
+const WEBVIEW2_NO_SANDBOX_ENV: &str = "DBX_WEBVIEW2_NO_SANDBOX";
#[cfg(target_os = "macos")]
const APP_MENU_QUIT_ID: &str = "app-menu-quit";
#[cfg(target_os = "macos")]
@@ -142,6 +144,25 @@ fn should_show_main_window_after_setup() -> bool {
true
}
+#[cfg(target_os = "windows")]
+fn configure_webview2_sandbox_compat() {
+ if !matches!(std::env::var(WEBVIEW2_NO_SANDBOX_ENV).as_deref(), Ok("1")) {
+ return;
+ }
+
+ let mut args = std::env::var("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS").unwrap_or_default();
+ if !args.split_whitespace().any(|arg| arg == "--no-sandbox") {
+ if !args.is_empty() {
+ args.push(' ');
+ }
+ args.push_str("--no-sandbox");
+ }
+ std::env::set_var("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", args);
+}
+
+#[cfg(not(target_os = "windows"))]
+fn configure_webview2_sandbox_compat() {}
+
fn should_confirm_app_exit_request(target_os: &str, exit_code: Option<i32>, confirmed_exit: bool) -> bool {
should_hide_window_on_close(target_os) && exit_code != Some(tauri::RESTART_EXIT_CODE) && !confirmed_exit
}
@@ -1086,6 +1107,7 @@ mod tests {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
rustls::crypto::aws_lc_rs::default_provider().install_default().expect("Failed to install rustls crypto provider");
+ configure_webview2_sandbox_compat();
#[cfg(target_os = "linux")]
apply_linux_webkit_rendering_workarounds();