* 添加存储
(storage: StorageList)
| 184 | * 添加存储 |
| 185 | */ |
| 186 | add(storage: StorageList): void { |
| 187 | // 检查是否已存在 |
| 188 | if (this.exists(storage.name)) { |
| 189 | throw AppError.validation(`Storage "${storage.name}" already exists`, { |
| 190 | name: storage.name, |
| 191 | }) |
| 192 | } |
| 193 | |
| 194 | this.cache.push(storage) |
| 195 | |
| 196 | if (this.config.enableEventEmitter) { |
| 197 | this.emit(STORAGE_EVENTS.ADDED, { |
| 198 | type: 'added', |
| 199 | storage, |
| 200 | timestamp: new Date(), |
| 201 | }) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * 移除存储 |
no test coverage detected