用electron下载游戏/用electron检测游戏版本

Download game with electron / detect game version with electron

我必须用电子构建一个游戏启动器。我有两个问题:

有了电子,您可以使用所有 API Node.js 除了 API Chrome 之外。 因此,您可以像在 Node.js 中那样使用 ftp 或 http 下载游戏,或使用 Ajax ($http)。 对于保存,您可以使用普通文件系统,对于版本,您可以使用文件系统或本地存储。 这是保存游戏的片段:

const http = require('http');
const fs   = require('fs');
const app  = require('remote').require('app');

var file = fs.createWriteStream(app.getDataPath() + "externalFiles/game.zip");
var request = http.get("http://dl.example.com/game.zip", response => {
  response.pipe(file);
});

在服务器上,您可以简单地请求返回最新版本的版本或哈希值,如果发生变化,它将重新下载游戏。