fix: 处理localStorage prefix === ''时提醒用户可能会全部删除数据

This commit is contained in:
layhuts
2026-05-09 23:04:38 +08:00
parent 71f2e5f504
commit d23b246aee

View File

@@ -20,6 +20,11 @@ class StorageManager {
constructor({driver, prefix = ''}: StorageManagerOptions = {}) {
this.driver = driver || this.createDefaultDriver();
this.prefix = prefix;
if (!this.prefix && this.driver instanceof LocalStorageDriver) {
console.warn(
'[StorageManager] empty prefix combined with LocalStorageDriver — clear()/keys() will affect every localStorage entry.',
);
}
}
/**