From 9dc9ca6e38be62ef2746c7a4c2b77b2d67c0d998 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Thu, 7 Mar 2024 11:02:53 -0300 Subject: [PATCH] feat(core): add dev function (#9113) --- .changes/dev-fn.md | 5 +++++ core/tauri/src/lib.rs | 5 +++++ core/tauri/src/manager/mod.rs | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changes/dev-fn.md diff --git a/.changes/dev-fn.md b/.changes/dev-fn.md new file mode 100644 index 000000000..7b0b12901 --- /dev/null +++ b/.changes/dev-fn.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:enhance +--- + +Added `tauri::dev()` to determine whether we are running in development mode or not. diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index 873d7b212..7c78fcf8d 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -333,6 +333,11 @@ macro_rules! tauri_build_context { pub use pattern::Pattern; +/// Whether we are running in development mode or not. +pub fn dev() -> bool { + !cfg!(feature = "custom-protocol") +} + /// User supplied data required inside of a Tauri application. /// /// # Stability diff --git a/core/tauri/src/manager/mod.rs b/core/tauri/src/manager/mod.rs index a1b49d09e..fa70ccd06 100644 --- a/core/tauri/src/manager/mod.rs +++ b/core/tauri/src/manager/mod.rs @@ -320,7 +320,7 @@ impl AppManager { } fn csp(&self) -> Option { - if cfg!(feature = "custom-protocol") { + if !crate::dev() { self.config.app.security.csp.clone() } else { self