在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特有的。所以我的问题是:
- 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