首页 > nwjs中参数node-remote能被动态的设置吗?

nwjs中参数node-remote能被动态的设置吗?

看使用说明,没提及到可以动态的在运行时设置这个参数的方法。
只能是应用启动时配置一个或多个url。

https://github.com/nwjs/nw.js/wiki/Manifest-format#user-content-node-r...


可以变通一下,获取到新的地址之后写入package.json然后重启

var manifest = gui.App.manifest;
manifest['node-remote'] = 'xxxxx.com';

fs.writeFileSync('package.json',JSON.stringify(manifest));

然后下一次启动的时候就使用新的值了,如果不想下一次使用就手动重启,重启代码

var child, child_process,
    executable = process.execPath;
child_process  = require("child_process");
child          = child_process.spawn(executable, ['--restart'], {
    detached: true,
    cwd     : path.dirname(executable)
});
child.unref();
【热门文章】
【热门文章】