Node-Webkit应用程序-如何更新? [英] Node-webkit app- how to update it?

查看:110
本文介绍了Node-Webkit应用程序-如何更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用node-webkit为我的学生开发应用程序,并提供一站式解决方案,我需要每月更新一次node-webkit存档.有办法可以做到吗? 基本上,我每个月只需要替换一个html文件,例如"page1.html". 我用谷歌搜索,但不知道从哪里开始.

I am using node-webkit to develop apps for my students, and to provide one stop solution I would need to update node-webkit archive once in a month. Is there a way I can accomplish that? Basically I need to replace just one html file every month, say "page1.html". I googled but have no idea where to start.

推荐答案

在Mac上,您可以访问自己应用的文件系统,例如

On Mac, you can access the filesystem of the own app e.g.

$ ls -lh /Applications/Shock.app/Contents/Resources/app.nw/
[...]
-rw-r--r--  1 jordi  staff   2,3K 29 gen 01:47 index.html
-rw-r--r--  1 jordi  staff   467B 29 gen 01:47 lecturenotes.html
[...]

因此,如果您将新版本放在特定的URL上,则可以获取它并在应用程序内重写HTML文件:

So if you put a new version on a specific URL, you could fetch it and rewrite the HTML file inside the app:

var request = require('request');
request('http://www.your-own-server.com/app/lecturenotes.html', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var fs = require('fs');
    fs.writeFileSync('/Applications/Shock.app/Contents/Resources/app.nw/lecturenotes.html', body);
  }
});

我认为在Linux上也会发生类似的情况.不幸的是,Windows版本与exe中的二进制包一起工作,因此该技巧在最后一种情况下不起作用.

I think something similar happens on Linux. Unfortunately, the Windows version works with a binary package into the exe, so this trick won't work for the last case.

这篇关于Node-Webkit应用程序-如何更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆