Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用vue-router + window.open 打开多个窗口的时候,渲染进程使用Nodejs Api报错 #441

Open
suka233333 opened this issue Nov 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@suka233333
Copy link

Describe the bug

这里是提供的最小复现仓库

做的改动概述
添加了vue-router,并将electron/main/index.ts 文件中的win.webContents.setWindowOpenHandler方法设置为允许

复现步骤
window.open打开新窗口,然后在新窗口中打开dev工具箱就会显示如下报错信息
image

其它信息
如果把这行代码注释掉,即在渲染进程中不使用nodejs的方法,那么此报错消失。。但是我是需要在渲染进程中使用nodejs的方法的。

请看看这是为什么呢,感谢。

@suka233333 suka233333 added the bug Something isn't working label Nov 9, 2023
@caoxiemeihao
Copy link
Member

  win.webContents.setWindowOpenHandler(({ url }) => {
    // if (url.startsWith('https:')) shell.openExternal(url)
    // return { action: 'deny' }
    return { action: 'allow' }
  })

不确定这里是否使用的普通的 iframe or webview(如果是就不能用 node.js), 而不是 Electron 提供的 BrowserWindow,需要查下 Electron 文档

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants