Update the browser, editor, settings, and installer

This commit is contained in:
Knotty Wyvern
2026-10-12 14:46:21 -07:00
parent 909894b9c8
commit f6eaa52949
163 changed files with 146260 additions and 534 deletions
+14
View File
@@ -0,0 +1,14 @@
use tauri_plugin_dialog::DialogExt;
#[tauri::command]
pub async fn theme_export(app: tauri::AppHandle, contents: String, default_name: String) -> Result<Option<String>, String> {
if contents.len() > 1_048_576 { return Err("The theme exceeds the 1 MB limit.".into()); }
serde_json::from_str::<serde_json::Value>(&contents).map_err(|_| "The theme contains invalid JSON.".to_string())?;
let name = std::path::Path::new(&default_name).file_name().and_then(|name| name.to_str()).unwrap_or("theme.json").to_string();
tauri::async_runtime::spawn_blocking(move || {
let Some(file) = app.dialog().file().set_title("Export theme").add_filter("Theme JSON", &["json"]).set_file_name(name).blocking_save_file() else { return Ok(None); };
let path = file.into_path().map_err(|error| error.to_string())?;
std::fs::write(&path, contents).map_err(|error| format!("Could not export the theme: {error}"))?;
Ok(Some(path.to_string_lossy().into_owned()))
}).await.map_err(|error| error.to_string())?
}