2024-09-20 02:28:25 +08:00
|
|
|
#![cfg_attr(
|
|
|
|
|
all(not(debug_assertions), target_os = "windows"),
|
|
|
|
|
windows_subsystem = "windows"
|
|
|
|
|
)]
|
|
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
use tauri::Manager;
|
2024-09-20 09:52:13 +08:00
|
|
|
// Window Vibrancy
|
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
|
use window_vibrancy::apply_mica;
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial};
|
|
|
|
|
|
2024-09-20 02:28:25 +08:00
|
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
// System Tray
|
|
|
|
|
#[cfg(desktop)]
|
|
|
|
|
mod tray;
|
|
|
|
|
|
2024-09-20 09:52:13 +08:00
|
|
|
// Local Modules
|
|
|
|
|
mod cmds;
|
|
|
|
|
mod steam;
|
|
|
|
|
mod tool;
|
|
|
|
|
|
2024-09-20 02:28:25 +08:00
|
|
|
#[tauri::command]
|
|
|
|
|
fn on_button_clicked() -> String {
|
|
|
|
|
let start = SystemTime::now();
|
|
|
|
|
let since_the_epoch = start
|
|
|
|
|
.duration_since(UNIX_EPOCH)
|
|
|
|
|
.expect("Time went backwards")
|
|
|
|
|
.as_millis();
|
|
|
|
|
format!("on_button_clicked called from Rust! (timestamp: {since_the_epoch}ms)")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
tauri::Builder::default()
|
2025-03-12 11:22:32 +08:00
|
|
|
.plugin(tauri_plugin_valtio::init())
|
2024-09-26 16:58:40 +08:00
|
|
|
.plugin(tauri_plugin_store::Builder::new().build())
|
2024-09-20 10:14:36 +08:00
|
|
|
.plugin(tauri_plugin_notification::init())
|
|
|
|
|
.plugin(tauri_plugin_http::init())
|
|
|
|
|
.plugin(tauri_plugin_shell::init())
|
|
|
|
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
|
|
|
|
.plugin(tauri_plugin_clipboard_manager::init())
|
|
|
|
|
.plugin(tauri_plugin_fs::init())
|
|
|
|
|
.plugin(tauri_plugin_os::init())
|
|
|
|
|
.plugin(tauri_plugin_process::init())
|
|
|
|
|
.plugin(tauri_plugin_dialog::init())
|
2025-03-13 03:41:21 +08:00
|
|
|
.plugin(tauri_plugin_system_info::init())
|
2024-09-20 10:14:36 +08:00
|
|
|
// .plugin(tauri_plugin_store::Builder::default().build())
|
|
|
|
|
// .plugin(tauri_plugin_updater::Builder::new().build())
|
|
|
|
|
.setup(|app| {
|
|
|
|
|
// Tray
|
|
|
|
|
#[cfg(all(desktop))]
|
|
|
|
|
{
|
|
|
|
|
let handle = app.handle();
|
|
|
|
|
tray::create_tray(handle)?;
|
|
|
|
|
}
|
2024-09-20 09:52:13 +08:00
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
// Get Window
|
|
|
|
|
let window = app.get_webview_window("main").unwrap();
|
2024-09-20 09:52:13 +08:00
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
// Vibrant Window
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, Some(10.0))
|
|
|
|
|
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
|
2024-09-20 09:52:13 +08:00
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
|
apply_mica(&window, Some(false))
|
|
|
|
|
.expect("Unsupported platform! 'apply_mica' is only supported on Windows");
|
2024-09-20 09:52:13 +08:00
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
// apply_blur(&window, Some((18, 18, 18, 0)))
|
|
|
|
|
// .expect("Unsupported platform! 'apply_blur' is only supported on Windows");
|
2024-09-20 09:52:13 +08:00
|
|
|
|
2024-09-20 10:14:36 +08:00
|
|
|
Ok(())
|
|
|
|
|
})
|
|
|
|
|
.invoke_handler(tauri::generate_handler![
|
|
|
|
|
cmds::greet,
|
|
|
|
|
cmds::launch_game,
|
|
|
|
|
cmds::kill_game,
|
|
|
|
|
cmds::kill_steam,
|
|
|
|
|
cmds::get_steam_path,
|
|
|
|
|
cmds::set_auto_login_user,
|
|
|
|
|
cmds::check_file_exists,
|
|
|
|
|
on_button_clicked
|
|
|
|
|
])
|
|
|
|
|
.run(tauri::generate_context!())
|
|
|
|
|
.expect("error while running tauri application");
|
2024-09-20 02:28:25 +08:00
|
|
|
}
|