在this Electron issue中,@ zcbenz评论说:“ 我们在Chrome浏览器中具有相同的大小限制,即可用磁盘空间的1/3””。该回复来自2016年初。
我已运行此代码:
const estimation = await navigator.storage.estimate();
console.log(`Quota: ${estimation.quota}`);
console.log(`Usage: ${estimation.usage}`);
它告诉我,我有100%的可用磁盘空间作为配额,所以我很困惑,找不到比2016年评论更新的东西,这也是Electron特定的。
所以我的问题:
-电子v3.0.4
确定。我可以向这个2019年保证,您现在可以完全控制indexdb数据了。根据Google的这篇文章:https://developers.google.com/web/updates/2017/08/estimating-available-storage-space上面的代码应返回正确的配额大小。但除此之外,现在调用此代码将使您的数据无法被“逐出”]
if (navigator.storage && navigator.storage.persist)
navigator.storage.persist().then(function(persistent) {
if (persistent)
console.log("Storage will not be cleared except by explicit user action");
else
console.log("Storage may be cleared by the UA under storage pressure.");
});
https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/persist