在 this Electron issue ,@zcbenz 评论道:
We have the same size limitation with Chrome browser, which is '1/3 of the of available disk space'.
该回复来自 2016 年初。
我运行了这段代码:
const estimation = await navigator.storage.estimate();
console.log(`Quota: ${estimation.quota}`);
console.log(`Usage: ${estimation.usage}`);
它告诉我,我有 100% 的可用磁盘空间作为我的配额,所以我很困惑,找不到比 2016 年评论更新的内容,这也是特定于 Electron 的。
所以我的问题:
- 这是否已正式更改?
- 如果您尝试超出该限制(假设并非真正 100% 的可用空间),会发生什么情况?
- Electron/Chromium 会驱逐您的数据吗?
--- Electron v3.0.4
最佳答案
2019 年,我可以向您保证,您现在可以完全控制您的索引数据库数据。
根据谷歌的这篇文章:
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
关于Electron IndexedDb 限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52921552/