refactor: move logic away from tauri commands

This commit is contained in:
2025-02-12 23:10:18 +01:00
parent 047b2e9f4a
commit fdf3679fbe
12 changed files with 181 additions and 156 deletions

33
rust/src/profile.rs Normal file
View File

@ -0,0 +1,33 @@
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use tokio::fs;
use crate::{model::misc, util};
// {game}-profile-{name}.json
#[derive(Deserialize, Serialize, Clone)]
#[allow(dead_code)]
pub struct Profile {
pub game: misc::Game,
pub path: PathBuf,
pub name: String,
pub mods: Vec<String>,
}
impl Profile {
pub fn new(path: PathBuf) -> Profile {
Profile {
game: misc::Game::Ongeki,
path: path,
name: "ongeki-default".to_owned(),
mods: [].to_vec()
}
}
pub async fn save(&self) {
let path = util::get_dirs().config_dir().join("profile-ongeki-default.json");
let s = serde_json::to_string_pretty(self).unwrap();
fs::write(&path, s).await.unwrap();
log::info!("Written to {}", path.to_string_lossy());
}
}