加个 favicon

This commit is contained in:
shenjack 2024-08-24 23:15:10 +08:00
parent 362a45d0a0
commit df5a71716c
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 9 additions and 0 deletions

BIN
sr_download/src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -5,6 +5,7 @@ use axum::{
routing::get, routing::get,
Json, Router, Json, Router,
}; };
use reqwest::header;
use sea_orm::{ActiveEnum, DatabaseConnection}; use sea_orm::{ActiveEnum, DatabaseConnection};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -233,6 +234,12 @@ async fn dashboard_page(State(db): State<DatabaseConnection>) -> Html<String> {
Html(page_content) Html(page_content)
} }
const FAVICON_FILE: &[u8] = include_bytes!("favicon.ico");
async fn favicon() -> impl IntoResponse {
([(header::CONTENT_TYPE, "image/x-icon")], FAVICON_FILE)
}
pub async fn web_main() -> anyhow::Result<()> { pub async fn web_main() -> anyhow::Result<()> {
let conf = crate::config::ConfigFile::try_read()?; let conf = crate::config::ConfigFile::try_read()?;
@ -254,6 +261,8 @@ pub async fn web_main() -> anyhow::Result<()> {
.route("/download/:id", get(get_data_by_id).post(get_data_by_id)) .route("/download/:id", get(get_data_by_id).post(get_data_by_id))
// info 页面 // info 页面
.route("/dashboard", get(dashboard_page).post(dashboard_page)) .route("/dashboard", get(dashboard_page).post(dashboard_page))
// favicon
.route("/favicon.ico", get(favicon).post(favicon))
// 其他所有路径, 直接跳转到 info 页面 // 其他所有路径, 直接跳转到 info 页面
.route("/*path", get(jump_to_dashboard).post(jump_to_dashboard)) .route("/*path", get(jump_to_dashboard).post(jump_to_dashboard))
// 包括根路径 // 包括根路径