electron-egg electron-egg
首页
  • v4.x
  • v3.x
  • v2.x
插件
  • v4.x
  • v3.x
demo
支持
知识点
案例
交流
  • GitHub (opens new window)
  • Gitee (opens new window)
首页
  • v4.x
  • v3.x
  • v2.x
插件
  • v4.x
  • v3.x
demo
支持
知识点
案例
交流
  • GitHub (opens new window)
  • Gitee (opens new window)
❤️成为赞助商
  • 框架

  • 操作系统

    • 文件
    • 视图
    • 窗口
    • 桌面通知
    • 电源监控
    • 屏幕信息
      • 系统主题
    • 特效

    • 硬件

    • 优惠券
    • 异常处理
    目录

    屏幕信息

    电脑显示器信息

    # 屏幕信息

    • 获取当前鼠标位置
    • 获取主屏幕
    • 获取所有屏幕
      // frontend/src/views/os/screen/Index.vue
      <script>
        getScreen (index) {
          this.$ipc.invoke(ipcApiRoute.getScreen, index).then(result => {
            this.data = result;
          })
        },
      </script> 
      
      // electron/controller/os.js
      /**
       * 获取屏幕信息
       */
      getScreen(args) {
        let data = [];
        let res = {};
        if (args == 0) {
          let res = screen.getCursorScreenPoint();
          data = [
            {
              title: '横坐标',
              desc: res.x
            },
            {
              title: '纵坐标',
              desc: res.y
            },
          ]
          return data;
        }
        if (args == 1) {
          res = screen.getPrimaryDisplay();
        }
        if (args == 2) {
          let resArr = screen.getAllDisplays();
          res = resArr[0];
        }
        data = [
          {
            title: '分辨率',
            desc: res.bounds.width + ' x ' + res.bounds.height
          },
          {
            title: '单色显示器',
            desc: res.monochrome ? '是' : '否'
          },
          {
            title: '色深',
            desc: res. colorDepth
          },
          {
            title: '色域',
            desc: res.colorSpace
          },
          {
            title: 'scaleFactor',
            desc: res.scaleFactor
          },
          {
            title: '加速器',
            desc: res.accelerometerSupport
          },
          {
            title: '触控',
            desc: res.touchSupport == 'unknown' ? '不支持' : '支持'
          },
        ]
        return data;
      }
      
      // Make sure to add code blocks to your code group

      # 完整代码

      • github前端代码 (opens new window)
      • github主进程代码 (opens new window)
      • gitee前端代码 (opens new window)
      • gitee主进程代码 (opens new window)
      上次更新: 2025/06/06, 07:21:49
      电源监控
      系统主题

      ← 电源监控 系统主题→

      Theme by Vdoing | Copyright © 2023-2025 哆啦好梦 | 京ICP备15041380号-2
      • 跟随系统
      • 浅色模式
      • 深色模式
      • 阅读模式
      ×