ts commander root electron 开机直接启动 全屏

import { app, BrowserWindow, screen } from 'electron'
import { Command } from 'commander';

app.whenReady().then(() => {
  const command = new Command
  var width, height
  var options

  command
    .option('-m, --maximize', 'maximize window')
    .option('--no-sandbox', 'other') // root 执行或开机直接启动 electron 应用需要此传入此参数,但是此参数我不需要,但是要加进来,不然 commander 识别到不存在的命令会直接退出
    .parse()
  options = command.opts()

  if (options.maximize) {
  	// 全屏大小
    width = screen.getPrimaryDisplay().workAreaSize.width
    height = screen.getPrimaryDisplay().workAreaSize.height
  }
  else {
    width = 800
    height = 600
  }

  const win = new BrowserWindow({
    width: width,
    height: height,

    autoHideMenuBar: true,
    webPreferences: {
    }
  })

  win.loadFile('index.html')
  // win.webContents.openDevTools()
})

其他

https://blog.csdn.net/qq_41544116/article/details/131884282

你可能感兴趣的:(electron,javascript,前端)