Upload fastsearch-tauri/src-tauri/src/main.rs
Browse files
fastsearch-tauri/src-tauri/src/main.rs
CHANGED
|
@@ -8,10 +8,9 @@ use once_cell::sync::Lazy;
|
|
| 8 |
use tauri::{
|
| 9 |
menu::{MenuBuilder, MenuItemBuilder},
|
| 10 |
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
| 11 |
-
Manager,
|
| 12 |
};
|
| 13 |
-
use tauri_plugin_global_shortcut::ShortcutState;
|
| 14 |
-
use tauri_plugin_shell::ShellExt;
|
| 15 |
use serde::{Serialize, Deserialize};
|
| 16 |
|
| 17 |
use fastsearch_core::index::store::IndexStore;
|
|
@@ -108,19 +107,18 @@ fn cmd_toggle_window(window: tauri::WebviewWindow) {
|
|
| 108 |
}
|
| 109 |
|
| 110 |
#[tauri::command]
|
| 111 |
-
fn cmd_open_file(path: String
|
| 112 |
-
let _ =
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
}
|
| 117 |
|
| 118 |
#[tauri::command]
|
| 119 |
-
fn cmd_open_folder(path: String
|
| 120 |
-
let _ =
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
);
|
| 124 |
}
|
| 125 |
|
| 126 |
#[tauri::command]
|
|
@@ -366,7 +364,7 @@ fn init_index() {
|
|
| 366 |
fn main() {
|
| 367 |
tauri::Builder::default()
|
| 368 |
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
| 369 |
-
.plugin(
|
| 370 |
.setup(|app| {
|
| 371 |
// Initialize index in background
|
| 372 |
init_index();
|
|
@@ -408,7 +406,7 @@ fn main() {
|
|
| 408 |
app.handle().plugin(
|
| 409 |
tauri_plugin_global_shortcut::Builder::new()
|
| 410 |
.with_handler(|app, shortcut, event| {
|
| 411 |
-
if shortcut.
|
| 412 |
if event.state == ShortcutState::Pressed {
|
| 413 |
if let Some(win) = app.get_webview_window("main") {
|
| 414 |
toggle_window(&win);
|
|
@@ -423,15 +421,6 @@ fn main() {
|
|
| 423 |
let shortcut_manager = app.global_shortcut();
|
| 424 |
let _ = shortcut_manager.register("Super+Space");
|
| 425 |
|
| 426 |
-
// ββ Window Events ββββββββββββββββββββββββββββββββββββββ
|
| 427 |
-
let win = app.get_webview_window("main").unwrap();
|
| 428 |
-
win.on_window_event(|win, event| {
|
| 429 |
-
if let tauri::WindowEvent::Focused(false) = event {
|
| 430 |
-
// Optional: hide on blur (click outside)
|
| 431 |
-
// let _ = win.hide();
|
| 432 |
-
}
|
| 433 |
-
});
|
| 434 |
-
|
| 435 |
Ok(())
|
| 436 |
})
|
| 437 |
.invoke_handler(tauri::generate_handler![
|
|
|
|
| 8 |
use tauri::{
|
| 9 |
menu::{MenuBuilder, MenuItemBuilder},
|
| 10 |
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
| 11 |
+
Manager, PhysicalPosition,
|
| 12 |
};
|
| 13 |
+
use tauri_plugin_global_shortcut::{GlobalShortcutExt, ShortcutState};
|
|
|
|
| 14 |
use serde::{Serialize, Deserialize};
|
| 15 |
|
| 16 |
use fastsearch_core::index::store::IndexStore;
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
#[tauri::command]
|
| 110 |
+
fn cmd_open_file(path: String) {
|
| 111 |
+
let _ = std::process::Command::new("explorer")
|
| 112 |
+
.arg("/select,")
|
| 113 |
+
.arg(&path)
|
| 114 |
+
.spawn();
|
| 115 |
}
|
| 116 |
|
| 117 |
#[tauri::command]
|
| 118 |
+
fn cmd_open_folder(path: String) {
|
| 119 |
+
let _ = std::process::Command::new("explorer")
|
| 120 |
+
.arg(&path)
|
| 121 |
+
.spawn();
|
|
|
|
| 122 |
}
|
| 123 |
|
| 124 |
#[tauri::command]
|
|
|
|
| 364 |
fn main() {
|
| 365 |
tauri::Builder::default()
|
| 366 |
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
| 367 |
+
.plugin(tauri_plugin_opener::init())
|
| 368 |
.setup(|app| {
|
| 369 |
// Initialize index in background
|
| 370 |
init_index();
|
|
|
|
| 406 |
app.handle().plugin(
|
| 407 |
tauri_plugin_global_shortcut::Builder::new()
|
| 408 |
.with_handler(|app, shortcut, event| {
|
| 409 |
+
if shortcut.matches(tauri_plugin_global_shortcut::Modifiers::SUPER, tauri_plugin_global_shortcut::Code::Space) {
|
| 410 |
if event.state == ShortcutState::Pressed {
|
| 411 |
if let Some(win) = app.get_webview_window("main") {
|
| 412 |
toggle_window(&win);
|
|
|
|
| 421 |
let shortcut_manager = app.global_shortcut();
|
| 422 |
let _ = shortcut_manager.register("Super+Space");
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
Ok(())
|
| 425 |
})
|
| 426 |
.invoke_handler(tauri::generate_handler![
|