Get background file using API

This commit is contained in:
KingRainbow44
2022-05-14 02:02:52 -04:00
parent a3cbf50164
commit d7cadc1603
3 changed files with 18 additions and 2 deletions

7
src-tauri/Cargo.lock generated
View File

@@ -641,6 +641,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"hudsucker", "hudsucker",
"json",
"lazy_static", "lazy_static",
"open", "open",
"registry", "registry",
@@ -1759,6 +1760,12 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "json"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
[[package]] [[package]]
name = "json-patch" name = "json-patch"
version = "0.2.6" version = "0.2.6"

View File

@@ -26,6 +26,8 @@ lazy_static = "1.4.0"
registry = "1.2.1" registry = "1.2.1"
# Program opener. # Program opener.
open = "2.1.2" open = "2.1.2"
# JSON parser.
json = "0.12.4"
# Dependencies for the HTTP(S) proxy. # Dependencies for the HTTP(S) proxy.
hudsucker = "0.17.2" hudsucker = "0.17.2"

View File

@@ -8,6 +8,7 @@ use open;
mod downloader; mod downloader;
mod lang; mod lang;
mod proxy; mod proxy;
mod web;
fn main() { fn main() {
tauri::Builder::default() tauri::Builder::default()
@@ -20,14 +21,14 @@ fn main() {
downloader::stop_download, downloader::stop_download,
lang::get_lang lang::get_lang
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
} }
#[tauri::command] #[tauri::command]
async fn connect(port: u16) { async fn connect(port: u16) {
// Log message to console. // Log message to console.
println!("Connecting to proxy..."); println!("Connecting to proxy...");
// Create and start a proxy. // Create and start a proxy.
proxy::create_proxy(port).await; proxy::create_proxy(port).await;
@@ -58,4 +59,10 @@ fn run_jar(path: String, execute_in: String) {
Ok(_) => (), Ok(_) => (),
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e), Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
}; };
}
#[tauri::command]
async fn get_bg_file() -> String {
let query = web::query("https://api.grasscutters.xyz/cultivation/query").await;
let response_data = object!json::parse(&query);
} }