klren0312 / daliy_knowledge

知识积累,正确使用方式是watch
21 stars 4 forks source link

electron获取屏幕真实分辨率 #826

Open klren0312 opened 7 months ago

klren0312 commented 7 months ago
// 获取屏幕分辨率
  ipcMain.handle('getScreenPx', () => {
    const { size, scaleFactor } = screen.getPrimaryDisplay()
    return {
      width: size.width * scaleFactor,
      height: size.height * scaleFactor
    }
  })