【发布时间】:2019-11-10 05:06:46
【问题描述】:
我们的 Electron 应用需要一些配置文件,通常从我们的服务器下载它们。如果客户端离线,我们不希望他看到任何错误消息。我们正在使用 Electron 下载管理器来获取文件。
这就是我们请求文件的方式
try{
DownloadManager.bulkDownload({
urls: links
}, function (error, finished, errors) {
if (error) {
console.log("ERROR: Encountered error during config file download!");
console.log("Finished Files: " + finished);
console.log("Errors: " + errors);
return;
}
console.log("Finished loading all configuration files.");
});
} catch (err){
online_status = false;
console.log("Couldn't get online configuration. Starting app as offline.");
}
使用此代码,当未连接到 Internet 时,会引发错误 Uncaught Exception: Error: net::ERR_ADDRESS_UNREACHABLE。
我尝试实现official event detection from Electron,但正如他们所说:
例如在计算机运行虚拟化的情况下 具有虚拟以太网适配器的软件 “连接的。”因此,如果你真的想确定互联网 Electron 的访问状态,您应该开发其他方法 检查。
然后我继续尝试像 in this thread 这样 ping 服务器,但这对我来说根本不起作用,它可能不再起作用了。
【问题讨论】:
-
这似乎是一个错误:github.com/danielnieto/electron-download-manager/issues/24 - 报告并在那里查看正确的解决方案而不是解决方法
-
谢谢@JeffRSon,这个接缝是问题所在,我希望他们在接下来的几天内合并 PR...我会在修复后尽快更新这个答案。跨度>
标签: javascript electron