From a442fbbe62b21e5c55beff1c94c2c1dc6190a941 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 3 Mar 2026 21:07:22 +0000 Subject: [PATCH] feat(app): add Tauri desktop build scaffold Create src-tauri/ with tauri.conf.json (frameless transparent window, 1200x800 default, system tray), Cargo.toml with tauri v2 dependencies, and main.rs with tray icon click-to-show and global shortcut (Cmd+Shift+A) to toggle window visibility. Auto-updater plugin enabled. Co-Authored-By: Claude Opus 4.6 --- packages/app/src-tauri/Cargo.toml | 21 ++++++++++ packages/app/src-tauri/build.rs | 3 ++ packages/app/src-tauri/src/main.rs | 50 +++++++++++++++++++++++ packages/app/src-tauri/tauri.conf.json | 56 ++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 packages/app/src-tauri/Cargo.toml create mode 100644 packages/app/src-tauri/build.rs create mode 100644 packages/app/src-tauri/src/main.rs create mode 100644 packages/app/src-tauri/tauri.conf.json diff --git a/packages/app/src-tauri/Cargo.toml b/packages/app/src-tauri/Cargo.toml new file mode 100644 index 00000000..b6558158 --- /dev/null +++ b/packages/app/src-tauri/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "aiui" +version = "0.1.0" +description = "AIUI Desktop Application" +authors = ["AIUI"] +edition = "2021" + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [ + "tray-icon", + "global-shortcut", +] } +tauri-plugin-updater = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +[features] +custom-protocol = ["tauri/custom-protocol"] diff --git a/packages/app/src-tauri/build.rs b/packages/app/src-tauri/build.rs new file mode 100644 index 00000000..d860e1e6 --- /dev/null +++ b/packages/app/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/packages/app/src-tauri/src/main.rs b/packages/app/src-tauri/src/main.rs new file mode 100644 index 00000000..2bf269cc --- /dev/null +++ b/packages/app/src-tauri/src/main.rs @@ -0,0 +1,50 @@ +// Prevents additional console window on Windows in release. +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use tauri::{ + tray::TrayIconBuilder, + Manager, +}; + +fn main() { + tauri::Builder::default() + .setup(|app| { + // Create system tray + let _tray = TrayIconBuilder::new() + .tooltip("AIUI") + .on_tray_icon_event(|tray, event| { + use tauri::tray::TrayIconEvent; + if let TrayIconEvent::Click { .. } = event { + let app = tray.app_handle(); + if let Some(window) = app.get_webview_window("main") { + let _ = window.show(); + let _ = window.set_focus(); + } + } + }) + .build(app)?; + + // Register global shortcut (Cmd+Shift+A / Ctrl+Shift+A) + #[cfg(target_os = "macos")] + let shortcut = "CommandOrControl+Shift+A"; + #[cfg(not(target_os = "macos"))] + let shortcut = "Ctrl+Shift+A"; + + let app_handle = app.handle().clone(); + app.global_shortcut().on_shortcut(shortcut, move |_app, _shortcut, _event| { + if let Some(window) = app_handle.get_webview_window("main") { + if window.is_visible().unwrap_or(false) { + let _ = window.hide(); + } else { + let _ = window.show(); + let _ = window.set_focus(); + } + } + })?; + + Ok(()) + }) + .plugin(tauri_plugin_updater::Builder::new().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/packages/app/src-tauri/tauri.conf.json b/packages/app/src-tauri/tauri.conf.json new file mode 100644 index 00000000..7deea1c1 --- /dev/null +++ b/packages/app/src-tauri/tauri.conf.json @@ -0,0 +1,56 @@ +{ + "$schema": "https://raw.githubusercontent.com/nicolgit/tauri-docs/v2/tooling/cli/schema.json", + "productName": "AIUI", + "version": "0.1.0", + "identifier": "com.aiui.app", + "build": { + "frontendDist": "../dist", + "devUrl": "http://localhost:5173", + "beforeDevCommand": "pnpm dev:app", + "beforeBuildCommand": "pnpm build:app" + }, + "app": { + "windows": [ + { + "title": "AIUI", + "width": 1200, + "height": 800, + "minWidth": 800, + "minHeight": 600, + "decorations": false, + "transparent": true, + "resizable": true, + "center": true + } + ], + "security": { + "csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' https: wss:" + }, + "trayIcon": { + "iconPath": "icons/icon.png", + "iconAsTemplate": true + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "macOS": { + "minimumSystemVersion": "10.15" + } + }, + "plugins": { + "updater": { + "active": true, + "endpoints": [], + "pubkey": "" + }, + "global-shortcut": {} + } +}