Get background file name

This commit is contained in:
KingRainbow44 2022-05-14 02:18:20 -04:00
parent d7cadc1603
commit 73138cb686
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
8 changed files with 19 additions and 14 deletions

View File

@ -12,6 +12,7 @@ trim_trailing_whitespace = false
[*.rs]
max_line_length = 100
indent_size = 2
[{*.ats,*.cts,*.mts,*.ts}]
indent_size = 2

View File

@ -2,5 +2,6 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="JSIgnoredPromiseFromCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
</profile>
</component>

7
src-tauri/Cargo.lock generated
View File

@ -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"

View File

@ -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"

View File

@ -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();

View File

@ -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;
}

8
src-tauri/src/structs.rs Normal file
View File

@ -0,0 +1,8 @@
#![allow(non_snake_case)]
use serde::Deserialize;
#[derive(Deserialize)]
pub(crate) struct APIQuery {
pub backgroundFile: String,
}

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2020",
"lib": [
"dom",
"dom.iterable",