Эх сурвалжийг харах

feat(core): add dev function (#9113)

Lucas Fernandes Nogueira 1 жил өмнө
parent
commit
9dc9ca6e38

+ 5 - 0
.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.

+ 5 - 0
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

+ 1 - 1
core/tauri/src/manager/mod.rs

@@ -320,7 +320,7 @@ impl<R: Runtime> AppManager<R> {
   }
 
   fn csp(&self) -> Option<Csp> {
-    if cfg!(feature = "custom-protocol") {
+    if !crate::dev() {
       self.config.app.security.csp.clone()
     } else {
       self