Support opening with window.open

This commit is contained in:
Tw93
2023-04-09 15:12:49 +08:00
parent acdbd73c13
commit ecb0568ffb
2 changed files with 12 additions and 1 deletions

View File

@@ -137,6 +137,17 @@ document.addEventListener('DOMContentLoaded', () => {
});
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() {