Get background file name

This commit is contained in:
KingRainbow44
2022-05-14 02:18:20 -04:00
parent d7cadc1603
commit 73138cb686
8 changed files with 19 additions and 14 deletions

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,
}