mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
expose data directory in desktop config
This commit is contained in:
parent
46cc07e048
commit
c8880fac36
2 changed files with 15 additions and 2 deletions
|
@ -18,6 +18,7 @@ pub struct Config {
|
|||
pub(crate) pre_rendered: Option<String>,
|
||||
pub(crate) disable_context_menu: bool,
|
||||
pub(crate) resource_dir: Option<PathBuf>,
|
||||
pub(crate) data_dir: Option<PathBuf>,
|
||||
pub(crate) custom_head: Option<String>,
|
||||
pub(crate) custom_index: Option<String>,
|
||||
pub(crate) root_name: String,
|
||||
|
@ -44,6 +45,7 @@ impl Config {
|
|||
pre_rendered: None,
|
||||
disable_context_menu: !cfg!(debug_assertions),
|
||||
resource_dir: None,
|
||||
data_dir: None,
|
||||
custom_head: None,
|
||||
custom_index: None,
|
||||
root_name: "main".to_string(),
|
||||
|
@ -56,6 +58,14 @@ impl Config {
|
|||
self
|
||||
}
|
||||
|
||||
/// set the directory where data will be stored in release mode.
|
||||
///
|
||||
/// > Note: This **must** be set when bundling on Windows.
|
||||
pub fn with_data_directory(mut self, path: impl Into<PathBuf>) -> Self {
|
||||
self.data_dir = Some(path.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Set whether or not the right-click context menu should be disabled.
|
||||
pub fn with_disable_context_menu(mut self, disable: bool) -> Self {
|
||||
self.disable_context_menu = disable;
|
||||
|
|
|
@ -7,7 +7,7 @@ use tao::event_loop::{EventLoopProxy, EventLoopWindowTarget};
|
|||
pub use wry;
|
||||
pub use wry::application as tao;
|
||||
use wry::application::window::Window;
|
||||
use wry::webview::{WebView, WebViewBuilder};
|
||||
use wry::webview::{WebContext, WebView, WebViewBuilder};
|
||||
|
||||
pub fn build(
|
||||
cfg: &mut Config,
|
||||
|
@ -33,6 +33,8 @@ pub fn build(
|
|||
));
|
||||
}
|
||||
|
||||
let mut web_context = WebContext::new(cfg.data_dir.clone());
|
||||
|
||||
let mut webview = WebViewBuilder::new(window)
|
||||
.unwrap()
|
||||
.with_transparent(cfg.window.window.transparent)
|
||||
|
@ -52,7 +54,8 @@ pub fn build(
|
|||
.as_ref()
|
||||
.map(|handler| handler(window, evet))
|
||||
.unwrap_or_default()
|
||||
});
|
||||
})
|
||||
.with_web_context(&mut web_context);
|
||||
|
||||
for (name, handler) in cfg.protocols.drain(..) {
|
||||
webview = webview.with_custom_protocol(name, handler)
|
||||
|
|
Loading…
Reference in a new issue