mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 06:00:21 +00:00
add platform specific functions for launching apps for workspaces
This commit is contained in:
parent
71a08678a6
commit
db35a9b48c
53 changed files with 127 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::{events::*, html::MouseEvent, prelude::*};
|
use dioxus::{events::*, html::MouseEvent, prelude::*};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_signals::use_signal;
|
use dioxus_signals::use_signal;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dioxus::prelude::*;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type alias that reprsents a shared context between components
|
/// A type alias that reprsents a shared context between components
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_desktop::{use_asset_handler, wry::http::Response};
|
use dioxus_desktop::{use_asset_handler, wry::http::Response};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::{dioxus_core::CapturedError, prelude::*};
|
use dioxus::{dioxus_core::CapturedError, prelude::*};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use dioxus_desktop::{Config, WindowBuilder};
|
||||||
fn main() {
|
fn main() {
|
||||||
LaunchBuilder::new(app)
|
LaunchBuilder::new(app)
|
||||||
.cfg(Config::new().with_window(WindowBuilder::new().with_resizable(true)))
|
.cfg(Config::new().with_window(WindowBuilder::new().with_resizable(true)))
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
const _STYLE: &str = manganis::mg!(file("./examples/assets/fileexplorer.css"));
|
const _STYLE: &str = manganis::mg!(file("./examples/assets/fileexplorer.css"));
|
||||||
|
|
|
@ -4,7 +4,7 @@ use dioxus::prelude::*;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(App);
|
launch_desktop(App);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn App() -> Element {
|
fn App() -> Element {
|
||||||
|
|
|
@ -7,7 +7,7 @@ fn main() {
|
||||||
println!("{e:?}");
|
println!("{e:?}");
|
||||||
true
|
true
|
||||||
}))
|
}))
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
.with_resizable(false),
|
.with_resizable(false),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Routable, Clone)]
|
#[derive(Routable, Clone)]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::fmt::Display;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn main() {
|
||||||
// We then launch the app with the pre-rendered HTML
|
// We then launch the app with the pre-rendered HTML
|
||||||
dioxus_ssr::pre_render(&pre_rendered_dom)
|
dioxus_ssr::pre_render(&pre_rendered_dom)
|
||||||
}))
|
}))
|
||||||
.launch();
|
.launch_desktop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FIELDS: &[(&str, &str)] = &[
|
const FIELDS: &[(&str, &str)] = &[
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(App);
|
launch_desktop(App);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(Route::Home {});
|
launch_desktop(Route::Home {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ANCHOR: router
|
// ANCHOR: router
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
todo!()
|
todo!()
|
||||||
// launch(App);
|
//launch_desktop(App);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use core::{fmt, str::FromStr};
|
// use core::{fmt, str::FromStr};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use dioxus_desktop::use_global_shortcut;
|
use dioxus_desktop::use_global_shortcut;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn main() {
|
||||||
.with_module_level("dioxus", log::LevelFilter::Trace)
|
.with_module_level("dioxus", log::LevelFilter::Trace)
|
||||||
.init()
|
.init()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
launch(Route::Home {});
|
launch_desktop(Route::Home {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Routable, Clone)]
|
#[derive(Routable, Clone)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn Nav() -> Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(Route::Blog {
|
launch_desktop(Route::Blog {
|
||||||
id: "hello".to_string(),
|
id: "hello".to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use futures_util::{future, stream, Stream, StreamExt};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
||||||
.with_inner_size(LogicalSize::new(600.0, 800.0)),
|
.with_inner_size(LogicalSize::new(600.0, 800.0)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use dioxus::prelude::*;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -79,5 +79,5 @@ fn app() -> Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ const _STYLE: &str = manganis::mg!(file("./public/tailwind.css"));
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
dioxus_web::launch(app);
|
dioxus_web::launch(app);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dioxus::prelude::*;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use dioxus_elements::input_data::keyboard_types::Key;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
.with_decorations(false),
|
.with_decorations(false),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dioxus_desktop::{Config, WindowCloseBehaviour};
|
||||||
fn main() {
|
fn main() {
|
||||||
LaunchBuilder::new(app)
|
LaunchBuilder::new(app)
|
||||||
.cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
|
.cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
|
||||||
.launch()
|
.launch_desktop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
launch(app);
|
launch_desktop(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|
|
@ -12,18 +12,20 @@ pub struct LaunchBuilder<
|
||||||
Component: ComponentFunction<Phantom, Props = Props>,
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
Props: Clone + 'static,
|
Props: Clone + 'static,
|
||||||
Phantom: 'static,
|
Phantom: 'static,
|
||||||
|
Platform: PlatformBuilder<Props> = CurrentPlatform,
|
||||||
> {
|
> {
|
||||||
cross_platform_config: CrossPlatformConfig<Component, Props, Phantom>,
|
cross_platform_config: CrossPlatformConfig<Component, Props, Phantom>,
|
||||||
platform_config: Option<<CurrentPlatform as PlatformBuilder<Props>>::Config>,
|
platform_config: Option<<Platform as PlatformBuilder<Props>>::Config>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default platform builder
|
||||||
impl<
|
impl<
|
||||||
Component: ComponentFunction<Phantom, Props = Props>,
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
Props: Clone + 'static,
|
Props: Clone + 'static,
|
||||||
Phantom: 'static,
|
Phantom: 'static,
|
||||||
> LaunchBuilder<Component, Props, Phantom>
|
> LaunchBuilder<Component, Props, Phantom>
|
||||||
{
|
{
|
||||||
/// Create a new builder for your application.
|
/// Create a new builder for your application. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate.
|
||||||
pub fn new(component: Component) -> Self
|
pub fn new(component: Component) -> Self
|
||||||
where
|
where
|
||||||
Props: Default,
|
Props: Default,
|
||||||
|
@ -37,7 +39,15 @@ impl<
|
||||||
platform_config: None,
|
platform_config: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<
|
||||||
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
|
Props: Clone + 'static,
|
||||||
|
Phantom: 'static,
|
||||||
|
Platform: PlatformBuilder<Props>,
|
||||||
|
> LaunchBuilder<Component, Props, Phantom, Platform>
|
||||||
|
{
|
||||||
/// Pass some props to your application.
|
/// Pass some props to your application.
|
||||||
pub fn props(mut self, props: Props) -> Self {
|
pub fn props(mut self, props: Props) -> Self {
|
||||||
self.cross_platform_config.props = props;
|
self.cross_platform_config.props = props;
|
||||||
|
@ -55,7 +65,7 @@ impl<
|
||||||
/// Provide a platform-specific config to the builder.
|
/// Provide a platform-specific config to the builder.
|
||||||
pub fn cfg(
|
pub fn cfg(
|
||||||
mut self,
|
mut self,
|
||||||
config: impl Into<Option<<CurrentPlatform as PlatformBuilder<Props>>::Config>>,
|
config: impl Into<Option<<Platform as PlatformBuilder<Props>>::Config>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
if let Some(config) = config.into() {
|
if let Some(config) = config.into() {
|
||||||
self.platform_config = Some(config);
|
self.platform_config = Some(config);
|
||||||
|
@ -66,7 +76,39 @@ impl<
|
||||||
#[allow(clippy::unit_arg)]
|
#[allow(clippy::unit_arg)]
|
||||||
/// Launch the app.
|
/// Launch the app.
|
||||||
pub fn launch(self) {
|
pub fn launch(self) {
|
||||||
CurrentPlatform::launch(
|
Platform::launch(
|
||||||
|
self.cross_platform_config,
|
||||||
|
self.platform_config.unwrap_or_default(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "web")]
|
||||||
|
impl<
|
||||||
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
|
Props: Clone + 'static,
|
||||||
|
Phantom: 'static,
|
||||||
|
> LaunchBuilder<Component, Props, Phantom, dioxus_web::WebPlatform>
|
||||||
|
{
|
||||||
|
/// Launch your web application.
|
||||||
|
pub fn launch_web(self) {
|
||||||
|
dioxus_web::WebPlatform::launch(
|
||||||
|
self.cross_platform_config,
|
||||||
|
self.platform_config.unwrap_or_default(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "desktop")]
|
||||||
|
impl<
|
||||||
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
|
Props: Clone + 'static,
|
||||||
|
Phantom: 'static,
|
||||||
|
> LaunchBuilder<Component, Props, Phantom, dioxus_desktop::DesktopPlatform>
|
||||||
|
{
|
||||||
|
/// Launch your desktop application.
|
||||||
|
pub fn launch_desktop(self) {
|
||||||
|
dioxus_desktop::DesktopPlatform::launch(
|
||||||
self.cross_platform_config,
|
self.cross_platform_config,
|
||||||
self.platform_config.unwrap_or_default(),
|
self.platform_config.unwrap_or_default(),
|
||||||
);
|
);
|
||||||
|
@ -75,7 +117,7 @@ impl<
|
||||||
|
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
type CurrentPlatform = dioxus_desktop::DesktopPlatform;
|
type CurrentPlatform = dioxus_desktop::DesktopPlatform;
|
||||||
#[cfg(feature = "web")]
|
#[cfg(all(feature = "web", not(feature = "desktop")))]
|
||||||
type CurrentPlatform = dioxus_web::WebPlatform;
|
type CurrentPlatform = dioxus_web::WebPlatform;
|
||||||
#[cfg(not(any(feature = "desktop", feature = "web")))]
|
#[cfg(not(any(feature = "desktop", feature = "web")))]
|
||||||
type CurrentPlatform = ();
|
type CurrentPlatform = ();
|
||||||
|
@ -92,3 +134,31 @@ pub fn launch<
|
||||||
{
|
{
|
||||||
LaunchBuilder::new(component).launch()
|
LaunchBuilder::new(component).launch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "web")]
|
||||||
|
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
|
||||||
|
pub fn launch_web<
|
||||||
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
|
Props: Clone + 'static,
|
||||||
|
Phantom: 'static,
|
||||||
|
>(
|
||||||
|
component: Component,
|
||||||
|
) where
|
||||||
|
Props: Default,
|
||||||
|
{
|
||||||
|
LaunchBuilder::new(component).launch_web()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "desktop")]
|
||||||
|
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
|
||||||
|
pub fn launch_desktop<
|
||||||
|
Component: ComponentFunction<Phantom, Props = Props>,
|
||||||
|
Props: Clone + 'static,
|
||||||
|
Phantom: 'static,
|
||||||
|
>(
|
||||||
|
component: Component,
|
||||||
|
) where
|
||||||
|
Props: Default,
|
||||||
|
{
|
||||||
|
LaunchBuilder::new(component).launch_desktop()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue