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

    • 通信
    • http服务
    • socket服务
    • json数据库
    • sqlite数据库
    • 任务
    • 自动更新
      • 软件调用
      • Java服务
    • 操作系统

    • 特效

    • 硬件

    • 优惠券
    • 异常处理
    目录

    自动更新

    应用客户端自动更新

    # 自动更新

      // frontend/src/views/framework/updater/Index.vue
      <script>
        checkForUpdater () {
          this.$ipc.invoke(ipcApiRoute.checkForUpdater).then(r => {
            console.log(r);
          })
        },
      </script> 
      
      // electron/controller/framework.js
      /**
       * 检查是否有新版本
       */
      checkForUpdater() { 
        const autoUpdaterAddon = this.app.addon.autoUpdater;
        autoUpdaterAddon.checkUpdate();  
        return;
      }
      
      // Make sure to add code blocks to your code group

      # 下载 & 进度

        // frontend/src/views/framework/updater/Index.vue
        <script>
          init () {
            this.$ipc.removeAllListeners(specialIpcRoute.appUpdater);
            this.$ipc.on(specialIpcRoute.appUpdater, (event, result) => {
              result = JSON.parse(result);
              this.status = result.status;
              if (result.status == 3) {
                this.progress = result.desc;
                this.percentNumber = result.percentNumber;
              } else {
                this.$message.info(result.desc);
              }
            })
          },
          download () {
            if (this.status !== 1) {
              this.$message.info('没有可用版本');
              return
            }
            this.$ipc.invoke(ipcApiRoute.downloadApp).then(r => {
              console.log(r);
            })
          },
        </script> 
        
        // electron/controller/framework.js
        /**
         * 下载新版本
         */
        downloadApp() {
          const autoUpdaterAddon = this.app.addon.autoUpdater;
          autoUpdaterAddon.download();
          return;
        }
        
        // 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
        • 跟随系统
        • 浅色模式
        • 深色模式
        • 阅读模式
        ×