diff --git a/.editorconfig b/.editorconfig index ad038d5..667b613 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,7 @@ trim_trailing_whitespace = false [*.rs] max_line_length = 100 +indent_size = 2 [{*.ats,*.cts,*.mts,*.ts}] indent_size = 2 diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 03d9549..8a3ab99 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,5 +2,6 @@ \ No newline at end of file diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 57c6bb8..6052185 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -641,7 +641,6 @@ version = "0.1.0" dependencies = [ "futures-util", "hudsucker", - "json", "lazy_static", "open", "registry", @@ -1760,12 +1759,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "json-patch" version = "0.2.6" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 305fcec..9316303 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -15,7 +15,6 @@ rust-version = "1.57" tauri-build = { version = "1.0.0-rc.8", features = [] } [dependencies] -serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } tauri = { version = "1.0.0-rc.9", features = ["api-all"] } @@ -26,8 +25,8 @@ lazy_static = "1.4.0" registry = "1.2.1" # Program opener. open = "2.1.2" -# JSON parser. -json = "0.12.4" +# Serialization library. +serde_json = "1" # Dependencies for the HTTP(S) proxy. hudsucker = "0.17.2" diff --git a/src-tauri/src/lang.rs b/src-tauri/src/lang.rs index df46440..0d47e91 100644 --- a/src-tauri/src/lang.rs +++ b/src-tauri/src/lang.rs @@ -1,4 +1,3 @@ - #[tauri::command] pub async fn get_lang(window: tauri::Window, lang: String) -> String { let lang = lang.to_lowercase(); @@ -15,7 +14,6 @@ pub async fn get_lang(window: tauri::Window, lang: String) -> String { return contents; } - pub fn emit_lang_err(window: tauri::Window, msg: std::string::String) { let mut res_hash = std::collections::HashMap::new(); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 86038bc..05114be 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,12 +3,15 @@ all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows" )] +use std::borrow::Borrow; use open; +use structs::{APIQuery}; mod downloader; mod lang; mod proxy; mod web; +mod structs; fn main() { tauri::Builder::default() @@ -17,6 +20,7 @@ fn main() { disconnect, run_program, run_jar, + get_bg_file, downloader::download_file, downloader::stop_download, lang::get_lang @@ -64,5 +68,6 @@ fn run_jar(path: String, execute_in: String) { #[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); + let response_data: APIQuery = serde_json::from_str(&query).unwrap(); + return response_data.backgroundFile; } \ No newline at end of file diff --git a/src-tauri/src/structs.rs b/src-tauri/src/structs.rs new file mode 100644 index 0000000..faac02d --- /dev/null +++ b/src-tauri/src/structs.rs @@ -0,0 +1,8 @@ +#![allow(non_snake_case)] + +use serde::Deserialize; + +#[derive(Deserialize)] +pub(crate) struct APIQuery { + pub backgroundFile: String, +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a273b0c..eab4d9e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es2020", "lib": [ "dom", "dom.iterable",