game thumbnails

This commit is contained in:
2025-11-14 09:03:05 +01:00
parent 567d293455
commit 833c8afedf
198 changed files with 129 additions and 71 deletions
@@ -268,6 +268,23 @@ async fn get_peer_count(state: tauri::State<'_, LanSpreadState>) -> tauri::Resul
Ok(0)
}
#[tauri::command]
async fn get_game_thumbnail(
game_id: String,
app_handle: tauri::AppHandle,
) -> tauri::Result<String> {
use base64::Engine;
let resource_path = app_handle.path().resolve(
format!("assets/{game_id}.jpg"),
tauri::path::BaseDirectory::Resource,
)?;
let image_data = std::fs::read(&resource_path)?;
let base64_data = base64::engine::general_purpose::STANDARD.encode(&image_data);
Ok(format!("data:image/jpeg;base64,{base64_data}"))
}
#[cfg(target_os = "windows")]
fn run_as_admin(file: &str, params: &str, dir: &str) -> bool {
use std::{ffi::OsStr, os::windows::ffi::OsStrExt};
@@ -817,7 +834,8 @@ pub fn run() {
run_game,
update_game_directory,
update_game,
get_peer_count
get_peer_count,
get_game_thumbnail
])
.manage(lanspread_state)
.setup({