没有如何将ELECTRON JS应用定位到特定区域的明确示例。唯一的语法在GitHub上可用,并且不能很好地描述它。
xtren2008 回答:如何使用电子定位器
这很简单。考虑一下在 ready 事件触发后定位mainWindow的代码。您应该可以在下面的“就绪”事件中进行展示以演示定位器。
// load the module
const Positioner = require('electron-positioner');
let mainWindow = null;
// create the main window
async function createWindow () {
mainWindow = new BrowserWindow({
height: 420,width: 600,x: 0,// default position left
y: 0,// default position top
show: false,webPreferences: {
nodeIntegration: true,preload: path.join(__dirname,'node_modules','electron','dist','electron-bridge.js')
}
});
// reposition after creating the window.
app.on('ready',async () => {
await createWindow();
let positioner = new Positioner(mainWindow);
positioner.move('bottomRight');
});
当然,可以通过BrowserWindow构造函数使用x和y值来实现这种影响,但是由模块提供固定位置非常方便。