Initial commit: Dioxus project scaffold
Add project configuration and main entry point. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
2dd53e3516
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/target
|
||||
/dist
|
||||
/.dioxus
|
||||
/.omc
|
||||
4064
Cargo.lock
generated
Normal file
4064
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "yggdrasil"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
dioxus = { version = "0.7.9", features = ["fullstack", "router"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.52", features = ["full"], optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
web = ["dioxus/web"]
|
||||
server = ["dioxus/server", "dep:tokio"]
|
||||
18
Dioxus.toml
Normal file
18
Dioxus.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[application]
|
||||
name = "yggdrasil"
|
||||
default_platform = "web"
|
||||
out_dir = "dist"
|
||||
|
||||
[web.app]
|
||||
title = "Yggdrasil - Dioxus SSR"
|
||||
|
||||
[web.watcher]
|
||||
watch_path = ["src", "Cargo.toml"]
|
||||
|
||||
[web.resource]
|
||||
style = []
|
||||
script = []
|
||||
|
||||
[web.resource.dev]
|
||||
style = []
|
||||
script = []
|
||||
44
src/main.rs
Normal file
44
src/main.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(App);
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App() -> Element {
|
||||
let mut count = use_signal(|| 0);
|
||||
let mut text = use_signal(|| "...".to_string());
|
||||
|
||||
rsx! {
|
||||
div { style: "padding: 2rem; font-family: system-ui, sans-serif;",
|
||||
h1 { "Dioxus SSR Fullstack" }
|
||||
|
||||
p { "This page is rendered on the server and hydrated on the client." }
|
||||
|
||||
div { style: "margin: 1rem 0;",
|
||||
h2 { "Counter: {count}" }
|
||||
button { onclick: move |_| count += 1, "Increment" }
|
||||
button { onclick: move |_| count -= 1, "Decrement" }
|
||||
}
|
||||
|
||||
div { style: "margin: 1rem 0;",
|
||||
h2 { "Server Function" }
|
||||
button {
|
||||
onclick: move |_| async move {
|
||||
match get_server_greeting().await {
|
||||
Ok(data) => text.set(data),
|
||||
Err(e) => text.set(format!("Error: {}", e)),
|
||||
}
|
||||
},
|
||||
"Call Server"
|
||||
}
|
||||
p { "Server said: {text}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[server]
|
||||
async fn get_server_greeting() -> Result<String, ServerFnError> {
|
||||
Ok("Hello from the server!".to_string())
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user