运行使用先打包成win32程序,在win7上运行exe启动。
electron app脚本中写下:
win.on('show',()=>{
let feedurl=`http://10.8.3.31:1337/update/windows_32/stable`;
autoUpdater.setFeedURL(feedurl);
autoUpdater.checkForUpdates(); // <------ 调用这里出错,没有进行网络连接就出错了
});
其中1337是连接的我本机的ip,跑的electron官方说明里的electron-release-servermaster
服务,也配置并测试了api正常
查看stackoverflow上给出的解释是这个app没有被安装 https://github.com/electron/electron/issues/4535 但,实际上我用inno setup 打包并安装之后安装也是同样的问题。
哪位给解释一下怎么回事
On Windows, you have to install your app into a user’s machine before you can use the autoUpdater, so it is recommended that you use the electron-winstaller, electron-builder or the grunt-electron-installer package to generate a Windows installer.
The installer generated with Squirrel will create a shortcut icon with an Application User Model ID in the format of com.squirrel.PACKAGE_ID.YOUR_EXE_WITHOUT_DOT_EXE, examples are com.squirrel.slack.Slack and com.squirrel.code.Code. You have to use the same ID for your app with app.setAppUserModelId API, otherwise Windows will not be able to pin your app properly in task bar.
The server-side setup is also different from macOS. You can read the documents of Squirrel.Windows to get more details.
http://electron.atom.io/docs/api/auto-updater/
没用过autoUpdater,但是inno setup和electron-winstaller打包出来的安装文件安装方式不一样(electron-winstaller是直接就装上了,完全没有提示).可以参见官方的electron-api-demos,里面有个script/installer.js
@baka397 果然,换上winstaller就可以了,用inno 是因为原来在electron文档中看到过可以用这种方式打包,没仔细看,谢谢你。
楼主,electron资源文件路径是不是只能用相对路径?electron本身不能设置虚拟根目录吧?
(907).toString(32)
@hyper-god 尽量用相对路径,因为宿主机路径不一致问题,要想用绝对路径只能用__dirname
解决.
electron没看到过设置虚拟根目录的方法