i think i got step one working

This commit is contained in:
2026-03-25 01:22:30 -06:00
parent 4230ae6cb9
commit b4bcb8f3f2
14 changed files with 5932 additions and 32 deletions

View File

@ -1,16 +1,66 @@
use tauri::Manager;
// --- Commands ---
/// Returns the backend URL. Stubbed for now; will be replaced once the
/// Python/Rust backend is fully wired up.
#[tauri::command]
fn get_backend_url() -> String {
// During development the Python backend still runs on 8642.
// In production this will be replaced with a local Rust server or IPC.
"http://localhost:8642".to_string()
}
/// Minimal encrypt: base64-encodes the string as a placeholder until a proper
/// OS keychain implementation is added (e.g. tauri-plugin-stronghold).
#[tauri::command]
fn encrypt_string(data: String) -> String {
use std::io::Write;
let encoded = data
.as_bytes()
.iter()
.fold(String::new(), |mut acc, b| {
use std::fmt::Write as FmtWrite;
let _ = write!(acc, "{:02x}", b);
acc
});
encoded
}
/// Companion decode for encrypt_string.
#[tauri::command]
fn decrypt_string(encrypted: String) -> Result<String, String> {
let bytes: Result<Vec<u8>, _> = (0..encrypted.len())
.step_by(2)
.map(|i| u8::from_str_radix(&encrypted[i..i + 2], 16))
.collect();
bytes
.map_err(|e| format!("decrypt error: {e}"))
.and_then(|b| String::from_utf8(b).map_err(|e| format!("utf8 error: {e}")))
}
// --- App entry point ---
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
if cfg!(debug_assertions) {
app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)?;
}
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.setup(|app| {
if cfg!(debug_assertions) {
app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)?;
}
Ok(())
})
.invoke_handler(tauri::generate_handler![
get_backend_url,
encrypt_string,
decrypt_string,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}