FIx:
- asset hotreloading for desktop, - asset dir for dxserve on desktop, - extend features with platform
This commit is contained in:
12 files changed
+101
-33
No files matched your search
@@ -278,8 +278,11 @@ impl App {
|
||||
self.control_flow = ControlFlow::Exit;
|
||||
}
|
||||
|
||||
// todo: enable asset hotreloading in desktop
|
||||
dioxus_hot_reload::HotReloadMsg::UpdateAsset(_) => {}
|
||||
dioxus_hot_reload::HotReloadMsg::UpdateAsset(_) => {
|
||||
for webview in self.webviews.values_mut() {
|
||||
webview.kick_stylsheets();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,10 @@ fn get_asset_root() -> Option<PathBuf> {
|
||||
// If running under cargo, there's no bundle!
|
||||
// There might be a smarter/more resilient way of doing this
|
||||
if std::env::var_os("CARGO").is_some() {
|
||||
return None;
|
||||
return dioxus_cli_config::CURRENT_CONFIG
|
||||
.as_ref()
|
||||
.map(|c| c.out_dir())
|
||||
.ok();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
|
||||
@@ -221,4 +221,12 @@ impl WebviewInstance {
|
||||
self.desktop_context.send_edits();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn kick_stylsheets(&self) {
|
||||
// run eval in the webview to kick the stylesheets by appending a query string
|
||||
// we should do something less clunky than this
|
||||
_ = self.desktop_context
|
||||
.webview
|
||||
.evaluate_script("document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((el) => el.href = el.href + \"?\" + Math.random());");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user