Système de base pour la création de projets #1

Merged
tipragot merged 6 commits from base into main 2024-01-26 12:07:02 +00:00
3 changed files with 21 additions and 30 deletions
Showing only changes of commit a53eafe352 - Show all commits

View file

@ -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 = "*"

View file

@ -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");

View file

@ -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}"
}
}
}