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)
❤️成为赞助商
  • 框架

  • 操作系统

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

    • 硬件

    • 优惠券
    • 异常处理
    目录

    系统主题

    电脑系统主题模式

    # 系统主题模式

    • system 跟随系统
    • light 明亮
    • dark 暗黑
      // frontend/src/views/os/theme/Index.vue
      <script>
        setTheme (e) {
          this.currentThemeMode = e.target.value;
          this.$ipc.invoke(ipcApiRoute.setTheme, this.currentThemeMode).then(result => {
            this.currentThemeMode = result;
          })      
        },
        getTheme () {
          this.$ipc.invoke(ipcApiRoute.getTheme).then(result => {
            this.currentThemeMode = result;
          })  
        },
      </script> 
      
      // electron/controller/os.js
      /**
       * 获取系统主题
       */
      getTheme() {
        let theme = 'system';
        if (nativeTheme.shouldUseHighContrastColors) {
          theme = 'light';
        } else if (nativeTheme.shouldUseInvertedColorScheme) {
          theme = 'dark';
        }
        return theme;
      }
      /**
       * 设置系统主题
       */
      setTheme(args) {
        nativeTheme.themeSource = args;
        return args;
      }
      
      // 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
      • 跟随系统
      • 浅色模式
      • 深色模式
      • 阅读模式
      ×