From e32bfd9aaba8959c0ed625ebb3e3b65bcf02086f Mon Sep 17 00:00:00 2001
From: GyDi <segydi@foxmail.com>
Date: Tue, 4 Jan 2022 21:29:04 +0800
Subject: [PATCH] feat: Window Send and Sync

---
 src-tauri/src/utils/server.rs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src-tauri/src/utils/server.rs b/src-tauri/src/utils/server.rs
index ea13ce6..e930964 100644
--- a/src-tauri/src/utils/server.rs
+++ b/src-tauri/src/utils/server.rs
@@ -1,7 +1,6 @@
 extern crate warp;
 
 use port_scanner::local_port_available;
-use std::sync::{Arc, Mutex};
 use tauri::{AppHandle, Manager};
 use warp::Filter;
 
@@ -23,13 +22,12 @@ pub fn check_singleton() -> Result<(), ()> {
 /// The embed server only be used to implement singleton process
 /// maybe it can be used as pac server later
 pub fn embed_server(app: &AppHandle) {
-  let window = Arc::new(Mutex::new(app.get_window("main").unwrap()));
+  let window = app.get_window("main").unwrap();
 
   tauri::async_runtime::spawn(async move {
     let commands = warp::path!("commands" / "visible").map(move || {
-      let win = window.lock().unwrap();
-      win.show().unwrap();
-      win.set_focus().unwrap();
+      window.show().unwrap();
+      window.set_focus().unwrap();
       return format!("ok");
     });
 
-- 
GitLab