0

有没有办法在 Angular/Electron 应用程序中创建无模式对话框?

我正在查看下面的示例,它们都是模态的:

https://material.angular.io/components/dialog/overview

我需要能够同时打开多个窗口并移动它们。但我找不到任何样品。

谢谢。


编辑1:

我尝试了以下方法,但它以某种方式引导我进入默认页面 index.html:

window.open('/app/shared/settings/user-preferences.html'); 

编辑2:

我也尝试了以下方法,但它没有编译。

const { BrowserWindow } = require('electron'); //does not compile!!?
let win = new BrowserWindow({ width: 800, height: 600 });
win.on('closed', () => {
  win = null;
});

win.loadURL(`file://${__dirname}/app/shared/settings/user-preferences.html`);

但这不会编译并给我错误消息:

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\projects\...\MyApp\node_modules\electron'
ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'path' in 'C:\projects\...\MyApp\node_modules\electron'
4

1 回答 1

1

您可以使用window.open() API 来打开窗口的新窗口实例,方法是提供这样的 URL 并在其中使用对话框上下文:

window.open('https://www.angular.io', 'nameOfWindow');

这是一个工作示例

编辑1:

考虑到电子 API设置,您还需要执行以下操作:

如果要使用 Chrome 的内置 window.open() 实现,请在 webPreferences 选项对象中将 nativeWindowOpen 设置为 true。

编辑2:

考虑到本地文件,您可以这样做:

window.open(`file://${__dirname}/app/shared/settings/user-preferences.html`, 'nameOfWindow')
于 2020-01-28T08:07:24.817 回答