【发布时间】:2022-01-31 08:50:30
【问题描述】:
我目前有一个 Angular 应用程序在浏览器和我的 Mac 上的桌面应用程序中运行良好。但是,从桌面应用程序运行时的所有链接都会打开一个新窗口,该窗口不是我的默认浏览器(chrome)。我希望在 chrome 中打开所有链接(如果可用,最好使用已打开的 chrome 实例)我的应用程序中的所有<a> 都使用target="_blank"。我在我的 main.js 文件中找到了我尝试过的这种方法
win.webContents.setWindowOpenHandler(({ url }) => {
console.log(url);
shell.openExternal(url);
return { action: 'allow' };
});
在我的 app.component.html 中,我只是将其作为测试:
<a href="https://google.com target="_blank">Google Link Test</a>
然而,当我从电子运行时单击此链接时,我的屏幕变红了,应用程序崩溃了,我在控制台中遇到了这个问题:
https://google.com
MY_PATH/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGSEGV
我做错了什么导致我的应用程序崩溃?
【问题讨论】:
标签: angular hyperlink electron href anchor