From 59c09f90f9dc73829260cb4d142219f980946528 Mon Sep 17 00:00:00 2001 From: GyDi Date: Sun, 16 Jan 2022 03:09:36 +0800 Subject: [PATCH] feat: rm some commands --- src-tauri/src/cmds.rs | 24 +----------------------- src-tauri/src/main.rs | 5 ++--- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs index efa3818b59..ddefc0dd16 100644 --- a/src-tauri/src/cmds.rs +++ b/src-tauri/src/cmds.rs @@ -8,7 +8,7 @@ use crate::{ }, }; use serde_yaml::Mapping; -use tauri::{AppHandle, Manager, State}; +use tauri::State; /// get all profiles from `profiles.yaml` /// do not acquire the lock of ProfileLock @@ -231,25 +231,3 @@ pub async fn patch_verge_config( let mut verge = verge_state.0.lock().unwrap(); verge.patch_config(payload) } - -/// start dragging window -#[tauri::command] -pub fn win_drag(app_handle: AppHandle) { - let window = app_handle.get_window("main").unwrap(); - window.start_dragging().unwrap(); -} - -/// hide the window -#[tauri::command] -pub fn win_hide(app_handle: AppHandle) { - let window = app_handle.get_window("main").unwrap(); - window.hide().unwrap(); -} - -/// mini the window -#[tauri::command] -pub fn win_mini(app_handle: AppHandle) { - let window = app_handle.get_window("main").unwrap(); - // todo: these methods still has bug on Windows - window.minimize().unwrap(); -} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index efeb61cdbb..af0aa3b285 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,6 +37,7 @@ fn main() -> std::io::Result<()> { SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() { "open_window" => { let window = app_handle.get_window("main").unwrap(); + window.unminimize().unwrap(); window.show().unwrap(); window.set_focus().unwrap(); } @@ -63,6 +64,7 @@ fn main() -> std::io::Result<()> { }, SystemTrayEvent::LeftClick { .. } => { let window = app_handle.get_window("main").unwrap(); + window.unminimize().unwrap(); window.show().unwrap(); window.set_focus().unwrap(); } @@ -73,9 +75,6 @@ fn main() -> std::io::Result<()> { cmds::restart_sidecar, cmds::get_sys_proxy, cmds::get_cur_proxy, - cmds::win_drag, - cmds::win_hide, - cmds::win_mini, // clash cmds::get_clash_info, cmds::patch_clash_config,