shly / Blog-New

学习笔记
0 stars 0 forks source link

electron使用记录 #12

Open shly opened 6 years ago

shly commented 6 years ago

禁止触屏放大缩小界面 在渲染进程中

const {webFrame} = require('electron')
webFrame.setVisualZoomLevelLimits(1, 1)
shly commented 6 years ago

保证只有一个实例在运行

const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
  // Someone tried to run a second instance, we should focus our window.
  if (win) {
    if (win.isMinimized()) win.restore()
    win.focus()
  }
})

if (isSecondInstance) {
  app.quit()
}