UI Update
Some checks failed
Build and Release / Test (push) Has been cancelled
Build and Release / Build Windows (push) Has been cancelled
Build and Release / Build Linux (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
Build and Release / Create Release (push) Has been cancelled
Build and Release / Development Build (push) Has been cancelled

This commit is contained in:
2025-11-07 17:34:19 -05:00
parent ec77825fa6
commit 9c56f8f3f7
60 changed files with 3304 additions and 493 deletions

23
src-tauri/src/git/mod.rs Normal file
View File

@@ -0,0 +1,23 @@
pub fn git_check_installed() -> bool {
match std::process::Command::new("git").arg("--version").output() {
Ok(output) => output.status.success(),
Err(_) => false,
}
}
#[allow(dead_code)]
fn git_get_version() -> Result<String, String> {
match std::process::Command::new("git").arg("--version").output() {
Ok(output) => {
if output.status.success() {
let version = String::from_utf8_lossy(&output.stdout).trim().to_string();
Ok(version)
} else {
Err("Failed to get git version".to_string())
}
}
Err(e) => Err(e.to_string()),
}
}

View File

@@ -1,14 +1,74 @@
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
pub mod git;
#[tauri::command]
fn greet(name: &str) -> String {
git::git_check_installed();
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[tauri::command]
fn store_token(token: String) -> Result<(), String> {
// Persist token to the app config directory. For MVP this is plaintext storage.
// Replace with OS keychain plugin (tauri-plugin-keychain) for production.
let dir = dirs_next::config_dir().ok_or_else(|| "could not determine config directory".to_string())?;
let app_dir = dir.join("gitea-desktop");
std::fs::create_dir_all(&app_dir).map_err(|e| e.to_string())?;
let token_file = app_dir.join("token");
std::fs::write(token_file, token).map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
fn get_token() -> Result<String, String> {
let dir = dirs_next::config_dir().ok_or_else(|| "could not determine config directory".to_string())?;
let token_file = dir.join("gitea-desktop").join("token");
match std::fs::read_to_string(token_file) {
Ok(s) => Ok(s),
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Ok(String::new())
} else {
Err(e.to_string())
}
}
}
}
#[tauri::command]
fn store_base_url(base_url: String) -> Result<(), String> {
let dir = dirs_next::config_dir().ok_or_else(|| "could not determine config directory".to_string())?;
let app_dir = dir.join("gitea-desktop");
std::fs::create_dir_all(&app_dir).map_err(|e| e.to_string())?;
let url_file = app_dir.join("base_url");
std::fs::write(url_file, base_url).map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
fn get_base_url() -> Result<String, String> {
let dir = dirs_next::config_dir().ok_or_else(|| "could not determine config directory".to_string())?;
let url_file = dir.join("gitea-desktop").join("base_url");
match std::fs::read_to_string(url_file) {
Ok(s) => Ok(s),
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Ok(String::new())
} else {
Err(e.to_string())
}
}
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init())
.invoke_handler(tauri::generate_handler![greet, store_token, get_token, store_base_url, get_base_url])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}