Home  >  Q&A  >  body text

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

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

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

PHP中文网PHP中文网2647 days ago319

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:42:48

    可以变通一下,获取到新的地址之后写入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();

    reply
    0
  • Cancelreply