The cookie import is gone. It worked mechanically - 43 cookies decrypted from Arc and verifiably visible to the page - but Google, Microsoft and Odoo all refused the imported sessions, because each binds a session to the browser that created it. Signing in once inside the app is simpler and actually works, so the whole path is deleted rather than kept as a feature that mostly fails. That takes rusqlite, aes, cbc, pbkdf2, hmac, sha1 and sha2 out of the build with it. Notifications are now raised through mac-notification-sys rather than Tauri's notification plugin, because the plugin cannot report that one was clicked. A click switches to the app that raised it and then runs the page's own click handler - the only thing that knows which message the notification was about. Zoom is per app, on a fixed ladder so Cmd+0 returns to exactly 100%. The shortcuts are menu-bar accelerators rather than a key listener, since the keystroke has to work while a remote page has focus. The hidden-element count is off the nav rows.
117 lines
4.3 KiB
Rust
117 lines
4.3 KiB
Rust
pub mod commands;
|
|
pub mod config;
|
|
pub mod routing;
|
|
pub mod webviews;
|
|
|
|
use tauri::menu::{AboutMetadata, Menu, MenuItem, PredefinedMenuItem, Submenu};
|
|
use tauri::Manager;
|
|
|
|
/// The macOS menu bar. Edit has no entry of its own, but its items live under
|
|
/// the app menu because they are what make ⌘X/⌘C/⌘V work in a text field.
|
|
fn build_menu(app: &tauri::AppHandle) -> tauri::Result<Menu<tauri::Wry>> {
|
|
let app_menu = Submenu::with_items(
|
|
app,
|
|
"Work",
|
|
true,
|
|
&[
|
|
&PredefinedMenuItem::about(app, None, Some(AboutMetadata::default()))?,
|
|
&PredefinedMenuItem::separator(app)?,
|
|
&PredefinedMenuItem::hide(app, None)?,
|
|
&PredefinedMenuItem::hide_others(app, None)?,
|
|
&PredefinedMenuItem::show_all(app, None)?,
|
|
&PredefinedMenuItem::separator(app)?,
|
|
&PredefinedMenuItem::cut(app, None)?,
|
|
&PredefinedMenuItem::copy(app, None)?,
|
|
&PredefinedMenuItem::paste(app, None)?,
|
|
&PredefinedMenuItem::select_all(app, None)?,
|
|
&PredefinedMenuItem::separator(app)?,
|
|
&PredefinedMenuItem::quit(app, None)?,
|
|
],
|
|
)?;
|
|
|
|
let window_menu = Submenu::with_items(
|
|
app,
|
|
"Window",
|
|
true,
|
|
&[
|
|
&PredefinedMenuItem::minimize(app, None)?,
|
|
&PredefinedMenuItem::maximize(app, None)?,
|
|
&PredefinedMenuItem::fullscreen(app, None)?,
|
|
&PredefinedMenuItem::separator(app)?,
|
|
&PredefinedMenuItem::close_window(app, None)?,
|
|
],
|
|
)?;
|
|
|
|
// Zoom lives in the menu bar rather than a key listener, because the
|
|
// keystroke has to work while an app's own webview has focus — and that
|
|
// webview is a remote page this app deliberately cannot script for input.
|
|
let view_menu = Submenu::with_items(
|
|
app,
|
|
"View",
|
|
true,
|
|
&[
|
|
&MenuItem::with_id(app, "zoom-in", "Zoom In", true, Some("CmdOrCtrl+="))?,
|
|
&MenuItem::with_id(app, "zoom-out", "Zoom Out", true, Some("CmdOrCtrl+-"))?,
|
|
&MenuItem::with_id(app, "zoom-reset", "Actual Size", true, Some("CmdOrCtrl+0"))?,
|
|
&PredefinedMenuItem::separator(app)?,
|
|
&MenuItem::with_id(app, "reload", "Reload", true, Some("CmdOrCtrl+R"))?,
|
|
],
|
|
)?;
|
|
|
|
Menu::with_items(app, &[&app_menu, &view_menu, &window_menu])
|
|
}
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.menu(build_menu)
|
|
.on_menu_event(|app, event| match event.id().as_ref() {
|
|
"zoom-in" => commands::adjust_zoom(app, Some(1)),
|
|
"zoom-out" => commands::adjust_zoom(app, Some(-1)),
|
|
"zoom-reset" => commands::adjust_zoom(app, None),
|
|
"reload" => commands::reload_active(app),
|
|
_ => {}
|
|
})
|
|
.plugin(tauri_plugin_opener::init())
|
|
.plugin(tauri_plugin_notification::init())
|
|
.setup(|app| {
|
|
let state = commands::build_state(&app.handle().clone())?;
|
|
app.manage(state);
|
|
|
|
// Asked for at startup rather than at the first notification, so
|
|
// the prompt does not arrive attached to someone else's message.
|
|
commands::ensure_notification_permission(&app.handle().clone());
|
|
Ok(())
|
|
})
|
|
.invoke_handler(tauri::generate_handler![
|
|
commands::get_config,
|
|
commands::bootstrap,
|
|
commands::set_stage,
|
|
commands::set_active,
|
|
commands::hide_stage,
|
|
commands::show_stage,
|
|
commands::navigate_app,
|
|
commands::history_go,
|
|
commands::current_url,
|
|
commands::open_external,
|
|
commands::add_app,
|
|
commands::update_app,
|
|
commands::delete_app,
|
|
commands::reorder_apps,
|
|
commands::add_group,
|
|
commands::update_group,
|
|
commands::delete_group,
|
|
commands::set_nav_collapsed,
|
|
commands::set_theme,
|
|
commands::focus_window,
|
|
commands::notification_click,
|
|
commands::set_zoom,
|
|
commands::set_hidden,
|
|
commands::pick_hidden,
|
|
commands::test_notification,
|
|
commands::notification_status,
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|