electron控制台打开切换,默认全屏

-

// 控制台切换
    window.addEventListener('keydown', (e) => {
      const { altKey, ctrlKey, keyCode } = e;
      console.log(keyCode, 'keyCode');
      //  alt + ctrl + (Command | Windows) + l
      if (keyCode === 123) {
        //获取当前窗体
        const currentWindow = window.require('electron').remote.getCurrentWindow();
        currentWindow && currentWindow.toggleDevTools();
        e.preventDefault();
      }
    }, false);

 默认全屏

app.whenReady().then(() => {
  // We cannot require the screen module until the app is ready.
  const { screen } = require('electron')

  // Create a window that fills the screen's available work area.
  const primaryDisplay = screen.getPrimaryDisplay()
  const { width, height } = primaryDisplay.workAreaSize

  mainWindow = new BrowserWindow({ width, height })
  mainWindow.loadURL('https://electronjs.org')
})

 

 

-

posted @ 2022-02-27 15:19  古墩古墩  Views(1513)  Comments(0Edit  收藏  举报