概述`navigator.storage` 提供配额估算与持久化接口,帮助应用在离线场景保障数据不被自动清理。需在用户交互下合理申请并提示用途。示例const { usage, quota } = await navigator.storage.estimate() const allowed = await navigator.storage.persisted() if (!allowed) { const ok = await navigator.storage.persist() } 工程建议数据策略:结合 IndexedDB/OPFS 分层存储;定期清理与压缩。申请时机:在重要数据写入前或设置页中发起;说明用途与影响。兼容:不支持时回退到轻量缓存与云同步方案。参考与验证MDN StorageManager 文档:https://developer.mozilla.org/docs/Web/API/StorageManagerweb.dev 持久化与配额指南:https://web.dev/articles/persistent-storageChrome 平台文档:https://developer.chrome.com/docs/web-platform/storage-estimate/

发表评论 取消回复