feat: add force quit command
This commit is contained in:
@@ -219,21 +219,6 @@ pub fn open_window(window: Window, app_handle: tauri::AppHandle) -> Result<(), S
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn set_badge(count: i32) {
|
||||
#[cfg(target_os = "macos")]
|
||||
unsafe {
|
||||
let label = if count == 0 {
|
||||
nil
|
||||
} else {
|
||||
NSString::alloc(nil).init_str(&format!("{}", count))
|
||||
};
|
||||
let dock_tile: cocoa::base::id = msg_send![NSApp(), dockTile];
|
||||
let _: cocoa::base::id = msg_send![dock_tile, setBadgeLabel: label];
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn open_main_window(app: tauri::AppHandle) {
|
||||
@@ -255,3 +240,24 @@ pub fn open_main_window(app: tauri::AppHandle) {
|
||||
window.make_transparent().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn force_quit() {
|
||||
std::process::exit(0)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn set_badge(count: i32) {
|
||||
#[cfg(target_os = "macos")]
|
||||
unsafe {
|
||||
let label = if count == 0 {
|
||||
nil
|
||||
} else {
|
||||
NSString::alloc(nil).init_str(&format!("{}", count))
|
||||
};
|
||||
let dock_tile: cocoa::base::id = msg_send![NSApp(), dockTile];
|
||||
let _: cocoa::base::id = msg_send![dock_tile, setBadgeLabel: label];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ fn main() {
|
||||
commands::window::reload_column,
|
||||
commands::window::open_window,
|
||||
commands::window::open_main_window,
|
||||
commands::window::force_quit,
|
||||
commands::window::set_badge
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user