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

feat(core): add `set_skip_taskbar` API

Lucas Nogueira 4 жил өмнө
parent
commit
e06aa27738

+ 5 - 0
.changes/api-set-skip-taskbar.md

@@ -0,0 +1,5 @@
+---
+"api": patch
+---
+
+Adds `setSkipTaskbar` to the window API.

+ 7 - 0
.changes/set-skip-taskbar.md

@@ -0,0 +1,7 @@
+---
+"tauri": patch
+"tauri-runtime": patch
+"tauri-runtime-wry": patch
+---
+
+Adds `set_skip_taskbar` API on Window.

+ 15 - 0
core/tauri-runtime-wry/src/lib.rs

@@ -439,6 +439,7 @@ enum WindowMessage {
   SetFullscreen(bool),
   SetFocus,
   SetIcon(WindowIcon),
+  SetSkipTaskbar(bool),
   DragWindow,
 }
 
@@ -801,6 +802,17 @@ impl Dispatch for WryDispatcher {
       .map_err(|_| Error::FailedToSendMessage)
   }
 
+  fn set_skip_taskbar(&self, skip: bool) -> Result<()> {
+    self
+      .context
+      .proxy
+      .send_event(Message::Window(
+        self.window_id,
+        WindowMessage::SetSkipTaskbar(skip),
+      ))
+      .map_err(|_| Error::FailedToSendMessage)
+  }
+
   fn start_dragging(&self) -> Result<()> {
     self
       .context
@@ -1227,6 +1239,9 @@ fn handle_event_loop(
             WindowMessage::SetIcon(icon) => {
               window.set_window_icon(Some(icon));
             }
+            WindowMessage::SetSkipTaskbar(skip) => {
+              window.set_skip_taskbar(skip);
+            }
             WindowMessage::DragWindow => {
               let _ = window.drag_window();
             }

+ 3 - 0
core/tauri-runtime/src/lib.rs

@@ -298,6 +298,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
   /// Updates the window icon.
   fn set_icon(&self, icon: Icon) -> crate::Result<()>;
 
+  /// Whether to show the window icon in the task bar or not.
+  fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()>;
+
   /// Starts dragging the window.
   fn start_dragging(&self) -> crate::Result<()>;
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
core/tauri/scripts/bundle.js


+ 2 - 0
core/tauri/src/endpoints/window.rs

@@ -74,6 +74,7 @@ pub enum Cmd {
   SetIcon {
     icon: IconDto,
   },
+  SetSkipTaskbar(bool),
   StartDragging,
   Print,
 }
@@ -158,6 +159,7 @@ impl Cmd {
         Self::SetFullscreen(fullscreen) => window.set_fullscreen(fullscreen)?,
         Self::SetFocus => window.set_focus()?,
         Self::SetIcon { icon } => window.set_icon(icon.into())?,
+        Self::SetSkipTaskbar(skip) => window.set_skip_taskbar(skip)?,
         Self::StartDragging => window.start_dragging()?,
         Self::Print => window.print()?,
       }

+ 9 - 0
core/tauri/src/window.rs

@@ -543,6 +543,15 @@ impl<P: Params> Window<P> {
     self.window.dispatcher.set_icon(icon).map_err(Into::into)
   }
 
+  /// Whether to show the window icon in the task bar or not.
+  pub fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()> {
+    self
+      .window
+      .dispatcher
+      .set_skip_taskbar(skip)
+      .map_err(Into::into)
+  }
+
   /// Starts dragging the window.
   pub fn start_dragging(&self) -> crate::Result<()> {
     self.window.dispatcher.start_dragging().map_err(Into::into)

+ 16 - 0
tooling/api/src/window.ts

@@ -745,6 +745,22 @@ class WindowManager {
     })
   }
 
+  /**
+   * Whether to show the window icon in the task bar or not.
+   *
+   * @param skip true to hide window icon, false to show it.
+   * @returns A promise indicating the success or failure of the operation.
+   */
+  async setSkipTaskbar(skip: boolean): Promise<void> {
+    return invokeTauriCommand({
+      __tauriModule: 'Window',
+      message: {
+        cmd: 'setSkipTaskbar',
+        data: skip
+      }
+    })
+  }
+
   /**
    * Starts dragging the window.
    *

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 140 - 480
tooling/api/yarn.lock


+ 4 - 1
tooling/cli.js/test/jest/__tests__/template.spec.js

@@ -25,7 +25,10 @@ describe('[CLI] cli.js template', () => {
 
     const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
     const manifestFile = readFileSync(manifestPath).toString()
-    writeFileSync(manifestPath, `workspace = { }\n\n${manifestFile}`)
+    writeFileSync(
+      manifestPath,
+      `workspace = { }\n[patch.crates-io]\ntao = { git = "https://github.com/tauri-apps/tao", rev = "a3f533232df25dc30998809094ed5431b449489c" }\n\n${manifestFile}`
+    )
 
     const { promise: buildPromise } = await build({
       config: {

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно