From d7dc9f7b6e870661273368de976b25f60ddaf52e Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Sat, 23 May 2026 02:06:17 +0300 Subject: [PATCH] =?UTF-8?q?smart-house-web:=20=D1=84=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=20=D1=8D=D1=81=D1=81=D0=BF=D0=B5=D1=80=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart-house-web/Cargo.toml | 1 + smart-house-web/frontend-old/Cargo.toml | 16 ++++ .../{frontend => frontend-old}/Dioxus.toml | 0 .../assets/favicon.ico | Bin .../assets/header.svg | 0 .../assets/main.css | 0 .../{frontend => frontend-old}/clippy.toml | 0 .../{frontend => frontend-old}/src/backend.rs | 0 .../src/components/favorites.rs | 0 .../src/components/mod.rs | 0 .../src/components/nav.rs | 0 .../src/components/view.rs | 0 smart-house-web/frontend-old/src/main.rs | 74 ++++++++++++++++++ smart-house-web/frontend/Cargo.toml | 13 +-- smart-house-web/frontend/index.html | 5 ++ smart-house-web/frontend/src/main.rs | 73 +---------------- 16 files changed, 100 insertions(+), 82 deletions(-) create mode 100644 smart-house-web/frontend-old/Cargo.toml rename smart-house-web/{frontend => frontend-old}/Dioxus.toml (100%) rename smart-house-web/{frontend => frontend-old}/assets/favicon.ico (100%) rename smart-house-web/{frontend => frontend-old}/assets/header.svg (100%) rename smart-house-web/{frontend => frontend-old}/assets/main.css (100%) rename smart-house-web/{frontend => frontend-old}/clippy.toml (100%) rename smart-house-web/{frontend => frontend-old}/src/backend.rs (100%) rename smart-house-web/{frontend => frontend-old}/src/components/favorites.rs (100%) rename smart-house-web/{frontend => frontend-old}/src/components/mod.rs (100%) rename smart-house-web/{frontend => frontend-old}/src/components/nav.rs (100%) rename smart-house-web/{frontend => frontend-old}/src/components/view.rs (100%) create mode 100644 smart-house-web/frontend-old/src/main.rs create mode 100644 smart-house-web/frontend/index.html diff --git a/smart-house-web/Cargo.toml b/smart-house-web/Cargo.toml index 7d13ab9..c9f562d 100644 --- a/smart-house-web/Cargo.toml +++ b/smart-house-web/Cargo.toml @@ -2,6 +2,7 @@ members = [ "backend", "frontend", + "frontend-old", ] resolver = "3" diff --git a/smart-house-web/frontend-old/Cargo.toml b/smart-house-web/frontend-old/Cargo.toml new file mode 100644 index 0000000..ef3b1d0 --- /dev/null +++ b/smart-house-web/frontend-old/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "frontend-old" +version = "0.1.0" +edition = "2021" + +[dependencies] +dioxus = { version = "0.7", features = ["fullstack", "router"] } +reqwest = { version = "0.13", features = ["json"] } +serde = { version = "1.0", features = ["derive"] } + +[features] +default = ["web"] +web = ["dioxus/web"] +desktop = ["dioxus/desktop"] +mobile = ["dioxus/mobile"] +server = ["dioxus/server"] diff --git a/smart-house-web/frontend/Dioxus.toml b/smart-house-web/frontend-old/Dioxus.toml similarity index 100% rename from smart-house-web/frontend/Dioxus.toml rename to smart-house-web/frontend-old/Dioxus.toml diff --git a/smart-house-web/frontend/assets/favicon.ico b/smart-house-web/frontend-old/assets/favicon.ico similarity index 100% rename from smart-house-web/frontend/assets/favicon.ico rename to smart-house-web/frontend-old/assets/favicon.ico diff --git a/smart-house-web/frontend/assets/header.svg b/smart-house-web/frontend-old/assets/header.svg similarity index 100% rename from smart-house-web/frontend/assets/header.svg rename to smart-house-web/frontend-old/assets/header.svg diff --git a/smart-house-web/frontend/assets/main.css b/smart-house-web/frontend-old/assets/main.css similarity index 100% rename from smart-house-web/frontend/assets/main.css rename to smart-house-web/frontend-old/assets/main.css diff --git a/smart-house-web/frontend/clippy.toml b/smart-house-web/frontend-old/clippy.toml similarity index 100% rename from smart-house-web/frontend/clippy.toml rename to smart-house-web/frontend-old/clippy.toml diff --git a/smart-house-web/frontend/src/backend.rs b/smart-house-web/frontend-old/src/backend.rs similarity index 100% rename from smart-house-web/frontend/src/backend.rs rename to smart-house-web/frontend-old/src/backend.rs diff --git a/smart-house-web/frontend/src/components/favorites.rs b/smart-house-web/frontend-old/src/components/favorites.rs similarity index 100% rename from smart-house-web/frontend/src/components/favorites.rs rename to smart-house-web/frontend-old/src/components/favorites.rs diff --git a/smart-house-web/frontend/src/components/mod.rs b/smart-house-web/frontend-old/src/components/mod.rs similarity index 100% rename from smart-house-web/frontend/src/components/mod.rs rename to smart-house-web/frontend-old/src/components/mod.rs diff --git a/smart-house-web/frontend/src/components/nav.rs b/smart-house-web/frontend-old/src/components/nav.rs similarity index 100% rename from smart-house-web/frontend/src/components/nav.rs rename to smart-house-web/frontend-old/src/components/nav.rs diff --git a/smart-house-web/frontend/src/components/view.rs b/smart-house-web/frontend-old/src/components/view.rs similarity index 100% rename from smart-house-web/frontend/src/components/view.rs rename to smart-house-web/frontend-old/src/components/view.rs diff --git a/smart-house-web/frontend-old/src/main.rs b/smart-house-web/frontend-old/src/main.rs new file mode 100644 index 0000000..7f853bf --- /dev/null +++ b/smart-house-web/frontend-old/src/main.rs @@ -0,0 +1,74 @@ +use dioxus::prelude::*; + +use crate::components::{Favorites, NavBar}; + +const FAVICON: Asset = asset!("/assets/favicon.ico"); +const MAIN_CSS: Asset = asset!("/assets/main.css"); + +mod backend; +mod components; + +fn main() { + dioxus::launch(App); +} + +#[derive(Clone)] +struct TitleState(String); + +#[component] +fn App() -> Element { + use_context_provider(|| TitleState("HotDog".to_string())); + rsx! { + document::Link { rel: "icon", href: FAVICON } + document::Stylesheet { href: MAIN_CSS } + Router:: { } + } +} + +#[component] +fn Title() -> Element { + let title = use_context::(); + rsx! { + div { id: "title", + h1 { "{title.0}! 🌭" } + } + } +} + +#[derive(serde::Deserialize)] +struct DogApi { + message: String, +} + +#[component] +fn DogView() -> Element { + let mut img_src = use_resource(|| async move { + reqwest::get("https://dog.ceo/api/breeds/image/random") + .await + .unwrap() + .json::() + .await + .unwrap() + .message + }); + + rsx! { + div { id: "dogview", + img { src: img_src.cloned().unwrap_or_default() } + } + div { id: "buttons", + button { onclick: move |_| img_src.restart(), id: "skip", "skip" } + button { onclick: move |_| img_src.restart(), id: "save", "save!" } + } + } +} + +#[derive(Routable, Clone, PartialEq)] +enum Route { + #[layout(NavBar)] + #[route("/")] + DogView, + + #[route("/favorites")] + Favorites, +} diff --git a/smart-house-web/frontend/Cargo.toml b/smart-house-web/frontend/Cargo.toml index fc2f171..1a91109 100644 --- a/smart-house-web/frontend/Cargo.toml +++ b/smart-house-web/frontend/Cargo.toml @@ -1,16 +1,7 @@ [package] name = "frontend" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] -dioxus = { version = "0.7", features = ["fullstack", "router"] } -reqwest = { version = "0.13", features = ["json"] } -serde = { version = "1.0", features = ["derive"] } - -[features] -default = ["web"] -web = ["dioxus/web"] -desktop = ["dioxus/desktop"] -mobile = ["dioxus/mobile"] -server = ["dioxus/server"] +leptos = { version = "0.8.19", features = ["csr"] } diff --git a/smart-house-web/frontend/index.html b/smart-house-web/frontend/index.html new file mode 100644 index 0000000..7f2ad66 --- /dev/null +++ b/smart-house-web/frontend/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/smart-house-web/frontend/src/main.rs b/smart-house-web/frontend/src/main.rs index 7f853bf..3bfc6b4 100644 --- a/smart-house-web/frontend/src/main.rs +++ b/smart-house-web/frontend/src/main.rs @@ -1,74 +1,5 @@ -use dioxus::prelude::*; - -use crate::components::{Favorites, NavBar}; - -const FAVICON: Asset = asset!("/assets/favicon.ico"); -const MAIN_CSS: Asset = asset!("/assets/main.css"); - -mod backend; -mod components; +use leptos::prelude::*; fn main() { - dioxus::launch(App); -} - -#[derive(Clone)] -struct TitleState(String); - -#[component] -fn App() -> Element { - use_context_provider(|| TitleState("HotDog".to_string())); - rsx! { - document::Link { rel: "icon", href: FAVICON } - document::Stylesheet { href: MAIN_CSS } - Router:: { } - } -} - -#[component] -fn Title() -> Element { - let title = use_context::(); - rsx! { - div { id: "title", - h1 { "{title.0}! 🌭" } - } - } -} - -#[derive(serde::Deserialize)] -struct DogApi { - message: String, -} - -#[component] -fn DogView() -> Element { - let mut img_src = use_resource(|| async move { - reqwest::get("https://dog.ceo/api/breeds/image/random") - .await - .unwrap() - .json::() - .await - .unwrap() - .message - }); - - rsx! { - div { id: "dogview", - img { src: img_src.cloned().unwrap_or_default() } - } - div { id: "buttons", - button { onclick: move |_| img_src.restart(), id: "skip", "skip" } - button { onclick: move |_| img_src.restart(), id: "save", "save!" } - } - } -} - -#[derive(Routable, Clone, PartialEq)] -enum Route { - #[layout(NavBar)] - #[route("/")] - DogView, - - #[route("/favorites")] - Favorites, + leptos::mount::mount_to_body(|| view! {

"Hello, world!"

}) }