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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9c60d18528
commit
a442fbbe62
@@ -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"]
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
@@ -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": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user