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

时间:2017-03-12 16:31:30

标签: github electron auto-update electron-builder

到目前为止我的代码。

的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>
&#13;
&#13;
&#13;

当我在dist / win目录中运行命令npm run build时,我得到了这些文件:

  • 在dist里面,我有文件latest.yml和setup.exe
  • 并且在dist / win中,我的应用程序已解压缩。

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

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

0 个答案:

没有答案