feat(desktop): 添加悬浮球 Quick Ask 功能
- 实现浅灰色玻璃拟态悬浮球,带机器人头图标 - 支持点击展开对话框,淡入淡出动画 - 支持窗口拖拽,区分点击和拖拽操作 - macOS 透明窗口支持 (macOSPrivateApi) - 悬浮球 hover 放大效果,不溢出窗口 - 添加系统托盘 Toggle Quick Ask 菜单
This commit is contained in:
@@ -21,16 +21,22 @@ pub fn run() {
|
||||
commands::open_directory_dialog,
|
||||
commands::read_local_file,
|
||||
commands::list_directory,
|
||||
commands::toggle_floating_window,
|
||||
commands::show_floating_window,
|
||||
commands::hide_floating_window,
|
||||
commands::show_main_window,
|
||||
commands::set_floating_window_size,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
fn setup_tray<R: Runtime>(app: &tauri::App<R>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let show_item = MenuItem::with_id(app, "show", "Show Window", true, None::<&str>)?;
|
||||
let show_item = MenuItem::with_id(app, "show", "Show Main Window", true, None::<&str>)?;
|
||||
let floating_item = MenuItem::with_id(app, "floating", "Toggle Quick Ask", true, None::<&str>)?;
|
||||
let quit_item = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
|
||||
|
||||
let menu = Menu::with_items(app, &[&show_item, &quit_item])?;
|
||||
let menu = Menu::with_items(app, &[&show_item, &floating_item, &quit_item])?;
|
||||
|
||||
let _tray = TrayIconBuilder::new()
|
||||
.menu(&menu)
|
||||
@@ -42,6 +48,16 @@ fn setup_tray<R: Runtime>(app: &tauri::App<R>) -> Result<(), Box<dyn std::error:
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
"floating" => {
|
||||
if let Some(window) = app.get_webview_window("floating") {
|
||||
if window.is_visible().unwrap_or(false) {
|
||||
let _ = window.hide();
|
||||
} else {
|
||||
let _ = window.show();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
"quit" => {
|
||||
app.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user