✨ Support opening with window.open
This commit is contained in:
@@ -27,7 +27,7 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
|||||||
.fullscreen(window_config.fullscreen)
|
.fullscreen(window_config.fullscreen)
|
||||||
.inner_size(window_config.width, window_config.height)
|
.inner_size(window_config.width, window_config.height)
|
||||||
.initialization_script(include_str!("../inject/style.js"))
|
.initialization_script(include_str!("../inject/style.js"))
|
||||||
.initialization_script(include_str!("../inject/index.js"))
|
.initialization_script(include_str!("../inject/event.js"))
|
||||||
.initialization_script(include_str!("../inject/component.js"));
|
.initialization_script(include_str!("../inject/component.js"));
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -137,6 +137,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setDefaultZoom();
|
setDefaultZoom();
|
||||||
|
|
||||||
|
// Rewrite the window.open function.
|
||||||
|
const originalWindowOpen = window.open;
|
||||||
|
window.open = function (url, name, specs) {
|
||||||
|
console.log('window.open called with URL:', url);
|
||||||
|
// Call Rust code to open a browser.
|
||||||
|
invoke('open_browser', { url });
|
||||||
|
|
||||||
|
// Call the original window.open function to maintain its normal functionality.
|
||||||
|
return originalWindowOpen.call(window, url, name, specs);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function setDefaultZoom() {
|
function setDefaultZoom() {
|
||||||
Reference in New Issue
Block a user