Struct dioxus_desktop::Config
source · pub struct Config { /* private fields */ }Expand description
The configuration for the desktop application.
Implementations§
source§impl Config
impl Config
sourcepub fn with_resource_directory(self, path: impl Into<PathBuf>) -> Self
pub fn with_resource_directory(self, path: impl Into<PathBuf>) -> Self
set the directory from which assets will be searched in release mode
sourcepub fn with_data_directory(self, path: impl Into<PathBuf>) -> Self
pub fn with_data_directory(self, path: impl Into<PathBuf>) -> Self
set the directory where data will be stored in release mode.
Note: This must be set when bundling on Windows.
Set whether or not the right-click context menu should be disabled.
sourcepub fn with_prerendered(self, content: String) -> Self
pub fn with_prerendered(self, content: String) -> Self
Set the pre-rendered HTML content
sourcepub fn with_window(self, window: WindowBuilder) -> Self
pub fn with_window(self, window: WindowBuilder) -> Self
Set the configuration for the window.
sourcepub fn with_close_behaviour(self, behaviour: WindowCloseBehaviour) -> Self
pub fn with_close_behaviour(self, behaviour: WindowCloseBehaviour) -> Self
Sets the behaviour of the application when the last window is closed.
sourcepub fn with_custom_protocol<F>(self, name: impl ToString, handler: F) -> Self
pub fn with_custom_protocol<F>(self, name: impl ToString, handler: F) -> Self
Set a custom protocol
sourcepub fn with_asynchronous_custom_protocol<F>(
self,
name: impl ToString,
handler: F,
) -> Self
pub fn with_asynchronous_custom_protocol<F>( self, name: impl ToString, handler: F, ) -> Self
Set an asynchronous custom protocol
Example Usage
let cfg = Config::new()
.with_asynchronous_custom_protocol("asset", |request, responder| {
tokio::spawn(async move {
responder.respond(
HTTPResponse::builder()
.status(404)
.body(Cow::Borrowed("404 - Not Found".as_bytes()))
.unwrap()
);
});
});note a key difference between Dioxus and Wry, the protocol name doesn’t explicitly need to be a
String, but needs to implement ToString.
See wry for more details on implementation
sourcepub fn with_custom_head(self, head: String) -> Self
pub fn with_custom_head(self, head: String) -> Self
Inject additional content into the document’s HEAD.
This is useful for loading CSS libraries, JS libraries, etc.
sourcepub fn with_custom_index(self, index: String) -> Self
pub fn with_custom_index(self, index: String) -> Self
Use a custom index.html instead of the default Dioxus one.
Make sure your index.html is valid HTML.
Dioxus injects some loader code into the closing body tag. Your document must include a body element!
sourcepub fn with_root_name(self, name: impl Into<String>) -> Self
pub fn with_root_name(self, name: impl Into<String>) -> Self
Set the name of the element that Dioxus will use as the root.
This is akin to calling React.render() on the element with the specified name.
sourcepub fn with_background_color(self, color: (u8, u8, u8, u8)) -> Self
pub fn with_background_color(self, color: (u8, u8, u8, u8)) -> Self
Sets the background color of the WebView. This will be set before the HTML is rendered and can be used to prevent flashing when the page loads. Accepts a color in RGBA format
Sets the menu the window will use. This will override the default menu bar.
Note: Menu will be hidden if
with_decorationsis set to false and passed intowith_window