如何为我的电子应用制作简单的更新程序

问题描述 投票:0回答:1

到目前为止,我的代码。

Package.json

    {
  "name": "myAppName",
  "version": "1.0.0",
  "description": "myAppName description",
  "main": "main.js",
  "scripts": {
    "start": "electron main.js",
    "build": "build --win"
  },
  "build": {
    "squirrelWindows": {
      "remoteReleases": "https://github.com/George/plx"
    },
    "win": {
      "certificateFile": "cert/myCerification.pfx",
      "certificatePassword": "123"
    },
    "appId": "myApp.id",
    "productName": "myAppName",
    "publish": [
      {
        "provider": "github",
        "owner": "George",
        "repo": "plx"
      }
    ]
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/George/plx.git"
  },
  "author": "George",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/George/plx/issues"
  },
  "homepage": "https://github.com/George/plx#readme",
  "devDependencies": {
    "electron": "^1.6.2",
    "electron-builder": "^15.3.0",
    "electron-squirrel-startup": "^1.0.0"
  },
  "dependencies": {
    "electron-log": "^1.3.0",
    "electron-updater": "^1.4.2" //delete
  }
}

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;




let mainWindow;

const createWindow = () => {
  mainWindow = new BrowserWindow({ 
    width: 800, 
    height: 600, 
    visible: true,
    icon: __dirname + 'build/icon.ico'
  });

  mainWindow.loadURL(`file://${__dirname}/index.html`);

  mainWindow.webContents.openDevTools();

  mainWindow.on('closed', () => {
    mainWindow = null;
  })
}

app.on('ready', createWindow)
app.on('window-all-closed', () => {
  app.quit()
});

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow();
  }
})

const squirrelCommand = process.argv[1];
switch (squirrelCommand) {
  case '--squirrel-install':
  case '--squirrel-updated':
  case '--squirrel-obsolete':
    app.quit();
  return true;
}
Body{
  background: dodgerblue;
  font-family: 'Roboto', sans-serif;
  text-align: center;
}

h1, h5 {
  color: white;
}

h1{

  margin-top: 20%;
  font-size: 100px;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>1.0.0</title>

  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  <link rel="stylesheet" href="main.css">

</head>
<body>
  
  <h1>Version 1.0.0</h1>
  
  <script src="index.js" type="text/javascript"></script>
</body>
</html>

当我在dist / win目录中运行命令npm run build时,会得到以下文件:

  • 在dist内部,我有文件Latest.yml和setup.exe
  • 并且在dist / win里面,我的应用程序已打开包装。

如何从GitHub存储库更新我的应用程序?

我试图在GitHub存储库上发布一个新版本1.0.1,但未更新我的应用程序。

github electron auto-update electron-builder
1个回答
0
投票

检查此使用电子生成器在Mac和Windows上创建和部署自动更新的电子应用程序:https://medium.com/@johndyer24/creating-and-deploying-an-auto-updating-electron-app-for-mac-and-windows-using-electron-builder-6a3982c0cee6

© www.soinside.com 2019 - 2024. All rights reserved.