Fix some issues
This commit is contained in:
parent
6cdf71b5b6
commit
e8c92cf7f0
@ -6,7 +6,7 @@
|
|||||||
pub mod authentification;
|
pub mod authentification;
|
||||||
pub mod launcher;
|
pub mod launcher;
|
||||||
|
|
||||||
use std::sync::{Mutex, Arc};
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use authentification::{Authentification, Prompt, GameProfile};
|
use authentification::{Authentification, Prompt, GameProfile};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -27,47 +27,62 @@ async fn login(app: tauri::AppHandle, _window: tauri::Window, state: tauri::Stat
|
|||||||
match result {
|
match result {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
let name = val.name.clone();
|
let name = val.name.clone();
|
||||||
state.lock().unwrap().0.replace(val);
|
match state.lock() {
|
||||||
Ok(format!("Hello {}", name))
|
Ok(mut game_profile) => {
|
||||||
|
game_profile.0 = Some(val);
|
||||||
|
Ok(format!("Hello {}", name))
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
Err(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
Err(err) => Err(err.to_string())
|
Err(err) => Err(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn download(app: tauri::AppHandle, _window: tauri::Window, state: tauri::State<'_, Mutex<CustomState>>) -> Result<String, String> {
|
async fn download(state: tauri::State<'_, Mutex<CustomState>>) -> Result<String, String> {
|
||||||
if let Some(base_dir) = BaseDirs::new() {
|
if let Some(base_dir) = BaseDirs::new() {
|
||||||
let data_folder = base_dir.data_dir().join(".altarik");
|
let data_folder = base_dir.data_dir().join(".altarik");
|
||||||
let root_path = data_folder.as_path();
|
let root_path = data_folder.as_path();
|
||||||
match state.lock() {
|
match state.lock() {
|
||||||
Ok(game_profile) => {
|
Ok(game_profile) => {
|
||||||
let game_profile = game_profile.0.as_ref().unwrap();
|
match &game_profile.0 {
|
||||||
let java_path = root_path.join("java");
|
Some(game_profile) => {
|
||||||
let opts = ClientOptions {
|
let java_path = root_path.join("java");
|
||||||
authorization: &game_profile,
|
let opts = ClientOptions {
|
||||||
root_path,
|
authorization: game_profile,
|
||||||
java_path: &java_path.as_path(),
|
root_path,
|
||||||
version_number: "1.19.4".to_string(),
|
java_path: &java_path.as_path(),
|
||||||
version_type: launcher::VersionType::Release,
|
version_number: "1.19.4".to_string(),
|
||||||
memory_min: "2G".to_string(),
|
version_type: launcher::VersionType::Release,
|
||||||
memory_max: "4G".to_string(),
|
memory_min: "2G".to_string(),
|
||||||
};
|
memory_max: "4G".to_string(),
|
||||||
let client = MinecraftClient::new(&opts);
|
};
|
||||||
match client {
|
let client = MinecraftClient::new(&opts);
|
||||||
Ok(mut client) => {
|
match client {
|
||||||
match client.download_assets() {
|
Ok(mut client) => {
|
||||||
Ok(_) => {
|
match client.download_assets() {
|
||||||
Ok("Content downloaded".to_string())
|
Ok(_) => {
|
||||||
|
Ok("Content downloaded".to_string())
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
Err(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
Err(err.to_string())
|
Err(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
None => {
|
||||||
Err(err.to_string())
|
Err("You're not connected".to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
Err(err.to_string())
|
Err(err.to_string())
|
||||||
@ -82,7 +97,7 @@ async fn download(app: tauri::AppHandle, _window: tauri::Window, state: tauri::S
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.manage(Arc::new(CustomState(None)))
|
.manage(Mutex::new(CustomState(None)))
|
||||||
.invoke_handler(tauri::generate_handler![greet, login, download])
|
.invoke_handler(tauri::generate_handler![greet, login, download])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
@ -22,7 +22,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
download (e) {
|
download (e) {
|
||||||
|
e.preventDefault()
|
||||||
|
if(!this.hideDownloadButton) {
|
||||||
|
this.invoke("download", {}).then(value => {
|
||||||
|
this.greet_message = value
|
||||||
|
}).catch(err => {
|
||||||
|
this.greet_message = "Error: " + err
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
Reference in New Issue
Block a user