Add ability to get item list

This commit is contained in:
Ethan O'Brien
2026-02-06 14:03:05 -06:00
parent db46013ee0
commit f4fcbf30ed
3 changed files with 1059 additions and 5 deletions

View File

@@ -219,6 +219,7 @@ pub async fn request(req: HttpRequest, body: String) -> HttpResponse {
"/api/webui/listCards" => webui::get_card_info(req),
"/api/webui/listMusic" => webui::get_music_info(req),
"/api/webui/listLoginBonus" => webui::list_login_bonus(req),
"/api/webui/listItems" => webui::list_items(req),
_ => api_req(req, body).await
}
}

View File

@@ -5,6 +5,7 @@ use actix_web::{
http::header::ContentType
};
use json::{JsonValue, object};
use lazy_static::lazy_static;
use crate::include_file;
use crate::router::{userdata, items};
@@ -37,7 +38,6 @@ fn error(msg: &str) -> HttpResponse {
//.insert_header(("Access-Control-Allow-Origin", FRONTEND_DOMAIN))
.insert_header(ContentType::json())
.body(json::stringify(resp))
}
pub fn login(_req: HttpRequest, body: String) -> HttpResponse {
@@ -324,12 +324,21 @@ pub fn get_music_info(req: HttpRequest) -> HttpResponse {
.body(json::stringify(resp))
}
lazy_static! {
static ref ITEM: JsonValue = json::parse(&include_file!("src/router/webui/item.json")).unwrap();
static ref LOGIN_BONUS: JsonValue = json::parse(&include_file!("src/router/webui/login_bonus.json")).unwrap();
}
pub fn list_login_bonus(_req: HttpRequest) -> HttpResponse {
let resp = json::parse(&include_file!("src/router/webui/login_bonus.json")).unwrap();
HttpResponse::Ok()
.content_type(ContentType::json())
//.insert_header(("Access-Control-Allow-Origin", FRONTEND_DOMAIN))
.body(json::stringify(resp))
.body(json::stringify(LOGIN_BONUS.clone()))
}
pub fn list_items(_req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.content_type(ContentType::json())
//.insert_header(("Access-Control-Allow-Origin", FRONTEND_DOMAIN))
.body(json::stringify(ITEM.clone()))
}

1044
src/router/webui/item.json Normal file

File diff suppressed because it is too large Load Diff