wip: disable reload in production

This commit is contained in:
Jonathan Kelley committed 2022-02-19 22:36:55 -05:00
1 parent 93b4f745af
commit 5954bba975
2 files changed
+30 -12

No files matched your search

+12 -12
View File
@@ -1,15 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Dioxus app</title> <title>Dioxus app</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head> </head>
<body> <body>
<div id="main"></div> <div id="main"></div>
<script> <script>
import("./index.js").then(function (module) { import("./index.js").then(function (module) {
module.main(); module.main();
}); });
</script> </script>
</body> </body>
</html> </html>
+18
View File
@@ -174,7 +174,25 @@ pub fn launch_with_props<P: 'static + Send>(
} }
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
// in debug, we are okay with the reload menu showing and dev tool
webview = webview.with_dev_tool(true); webview = webview.with_dev_tool(true);
} else {
// in release mode, we don't want to show the dev tool or reload menus
webview = webview.with_initialization_script(
r#"
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
alert("You've tried to open context menu");
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
alert("You've tried to open context menu");
window.event.returnValue = false;
});
}
"#,
)
} }
desktop.webviews.insert(window_id, webview.build().unwrap()); desktop.webviews.insert(window_id, webview.build().unwrap());