没有明确的例子说明如何将您的电子JS应用程序定位到特定区域。GitHub上仅有的语法可用,但它并没有很好地描述它。
发布于 2019-12-20 00:20:59
这是非常直接的。考虑下面这段代码,它在ready事件触发后定位mainWindow。您应该能够在下面的“ready”事件中演示定位器。
// 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值来实现,但是使用模块提供的固定位置非常方便。
https://stackoverflow.com/questions/59412647
复制相似问题