update banner via gitea releases

This commit is contained in:
2026-05-12 00:20:49 +03:00
parent 5a916d2ad2
commit 297f307588
5 changed files with 209 additions and 0 deletions
+33
View File
@@ -2,6 +2,7 @@ mod bootstrap;
mod capture;
mod config;
mod encode;
mod updates;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
@@ -459,6 +460,16 @@ fn reveal_in_explorer(path: String) -> Result<(), String> {
Ok(())
}
#[tauri::command]
fn open_url(url: String) -> Result<(), String> {
use std::process::Command;
Command::new("cmd")
.args(["/C", "start", "", &url])
.spawn()
.map_err(|e| format!("opening url: {e}"))?;
Ok(())
}
#[tauri::command]
fn export(state: State<'_, AppState>, request: ExportRequest) -> Result<ExportResult, String> {
let cfg = state.config.lock().expect("config mutex").clone();
@@ -548,6 +559,27 @@ pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.manage(state)
.setup(|app| {
let check_on_launch = {
let st = app.state::<AppState>();
let cfg = st.config.lock().expect("config mutex");
cfg.updates.check_on_launch
};
if check_on_launch {
let handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
match updates::check_for_update().await {
Ok(Some(info)) => {
tracing::info!(version = info.version, "update available");
let _ = handle.emit("update-available", &info);
}
Ok(None) => tracing::debug!("no update available"),
Err(e) => tracing::warn!("update check failed: {e:#}"),
}
});
}
Ok(())
})
.invoke_handler(tauri::generate_handler![
get_status,
get_config,
@@ -560,6 +592,7 @@ pub fn run() {
export,
extract_thumbnails,
reveal_in_explorer,
open_url,
show_overlay,
hide_overlay,
get_overlay_rect,