feat: add About dialog with version and license info
This commit is contained in:
@@ -5,10 +5,21 @@
|
||||
mod state;
|
||||
|
||||
use log::LevelFilter;
|
||||
use serde::Serialize;
|
||||
use state::{AppState, FrontendState};
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
use tauri_plugin_log::{Target, TargetKind};
|
||||
|
||||
/// Metadata and legal text displayed by the frontend "About" dialog.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
struct AboutInfo {
|
||||
app_name: String,
|
||||
version: String,
|
||||
identifier: String,
|
||||
license_name: String,
|
||||
license_text: String,
|
||||
}
|
||||
|
||||
/// Returns the current frontend snapshot without mutating any state. Used for
|
||||
/// the initial UI bootstrap.
|
||||
#[tauri::command]
|
||||
@@ -107,6 +118,21 @@ fn reset_stopwatch(app_state: tauri::State<AppState>) -> FrontendState {
|
||||
app_state.reset_stopwatch()
|
||||
}
|
||||
|
||||
/// Returns static application metadata and the bundled MIT license text for
|
||||
/// display in the About dialog.
|
||||
#[tauri::command]
|
||||
fn get_about_info(app: tauri::AppHandle) -> AboutInfo {
|
||||
let package = app.package_info();
|
||||
let identifier = app.config().identifier.clone();
|
||||
AboutInfo {
|
||||
app_name: package.name.clone(),
|
||||
version: package.version.to_string(),
|
||||
identifier,
|
||||
license_name: "MIT".to_string(),
|
||||
license_text: include_str!("../../LICENSE").trim().to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the Tauri runtime, configures plugins, and wires shared
|
||||
/// application state into every window.
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -139,7 +165,8 @@ pub fn run() {
|
||||
reset_timer,
|
||||
toggle_stopwatch,
|
||||
add_lap,
|
||||
reset_stopwatch
|
||||
reset_stopwatch,
|
||||
get_about_info
|
||||
])
|
||||
.setup(move |_| {
|
||||
log::info!("Tauclock backend ready; storage_path={}", storage_display);
|
||||
|
||||
Reference in New Issue
Block a user