mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-11 21:32:27 +00:00
27 lines
707 B
Rust
27 lines
707 B
Rust
use dioxus::prelude::*;
|
|
use dioxus_desktop::{use_asset_handler, wry::http::Response};
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
use_asset_handler(cx, "logos", |request, response| {
|
|
// Note that the "logos" prefix is stripped from the URI
|
|
//
|
|
// However, the asset is absolute to its "virtual folder" - meaning it starts with a leading slash
|
|
if request.uri().path() != "/logo.png" {
|
|
return;
|
|
}
|
|
|
|
response.respond(Response::new(include_bytes!("./assets/logo.png").to_vec()));
|
|
});
|
|
|
|
cx.render(rsx! {
|
|
div {
|
|
img {
|
|
src: "/logos/logo.png"
|
|
}
|
|
}
|
|
})
|
|
}
|