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

master^2
layhuts 2026-05-09 23:04:38 +08:00
parent 71f2e5f504
commit d23b246aee
1 changed files with 5 additions and 0 deletions

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.',
);
}
}
/**