generated from tipragot/rust
Système de base pour la création de projets #1
20
Cargo.toml
20
Cargo.toml
|
@ -6,18 +6,18 @@ description = ""
|
||||||
repository = "https://git.tipragot.fr/tipragot/tioxus.git"
|
repository = "https://git.tipragot.fr/tipragot/tioxus.git"
|
||||||
authors = ["tipragot"]
|
authors = ["tipragot"]
|
||||||
|
|
||||||
# [lints.rust]
|
[lints.rust]
|
||||||
# missing_docs = "warn"
|
missing_docs = "warn"
|
||||||
|
|
||||||
# [lints.rustdoc]
|
[lints.rustdoc]
|
||||||
# missing_doc_code_examples = "warn"
|
missing_doc_code_examples = "warn"
|
||||||
# private_doc_tests = "warn"
|
private_doc_tests = "warn"
|
||||||
|
|
||||||
# [lints.clippy]
|
[lints.clippy]
|
||||||
# missing_docs_in_private_items = "warn"
|
missing_docs_in_private_items = "warn"
|
||||||
# unwrap_in_result = "warn"
|
unwrap_in_result = "warn"
|
||||||
# unwrap_used = "warn"
|
unwrap_used = "warn"
|
||||||
# nursery = "warn"
|
nursery = "warn"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus = "*"
|
dioxus = "*"
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
//! Utilitaires permettant de lancer une application dioxus fullstack avec tailwind facilement.
|
||||||
|
|
||||||
pub use dioxus::prelude::*;
|
pub use dioxus::prelude::*;
|
||||||
pub use dioxus_fullstack::prelude::*;
|
pub use dioxus_fullstack::prelude::*;
|
||||||
|
@ -47,6 +47,14 @@ fn build_wasm() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Lance l'application dioxus.
|
||||||
|
///
|
||||||
|
/// Si l'application est lancée en mode debug, le projet sera compilé en webassembly
|
||||||
|
/// puis un fichier css sera généré automatiquement avec tailwind.
|
||||||
|
///
|
||||||
|
/// Si l'application est lancée en mode release, seul le serveur sera compilé.
|
||||||
|
/// Si l'on veut exporter la version finale du projet, il ne faut donc pas
|
||||||
|
/// oublier de le lancer en mode debug avant pour générer le webassembly.
|
||||||
pub fn launch<
|
pub fn launch<
|
||||||
Props: Clone + Default + serde::Serialize + serde::de::DeserializeOwned + Send + Sync + 'static,
|
Props: Clone + Default + serde::Serialize + serde::de::DeserializeOwned + Send + Sync + 'static,
|
||||||
>(
|
>(
|
||||||
|
@ -68,6 +76,8 @@ pub fn launch<
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), not(debug_assertions)))]
|
#[cfg(all(not(target_arch = "wasm32"), not(debug_assertions)))]
|
||||||
{
|
{
|
||||||
|
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||||
|
|
||||||
let config = ServeConfigBuilder::new(component, Props::default())
|
let config = ServeConfigBuilder::new(component, Props::default())
|
||||||
.index_path("web/index.html")
|
.index_path("web/index.html")
|
||||||
.assets_path("web");
|
.assets_path("web");
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,19 +0,0 @@
|
||||||
#![allow(non_snake_case)]
|
|
||||||
|
|
||||||
use tioxus::*;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
launch(App)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn App(cx: Scope) -> Element {
|
|
||||||
let mut counter = use_state(cx, || 0);
|
|
||||||
|
|
||||||
render! {
|
|
||||||
button {
|
|
||||||
class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-4 px-4 rounded",
|
|
||||||
onclick: move |_| counter += 1,
|
|
||||||
"{counter}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue