* 释放资源
()
| 244 | * 释放资源 |
| 245 | */ |
| 246 | public dispose(): void { |
| 247 | // 卸载所有插件(逆序,先卸载依赖项) |
| 248 | const plugins = Array.from(this._plugins.values()).reverse(); |
| 249 | |
| 250 | for (const plugin of plugins) { |
| 251 | try { |
| 252 | logger.info(`Disposing plugin: ${plugin.name}`); |
| 253 | plugin.uninstall(); |
| 254 | } catch (error) { |
| 255 | logger.error(`Error disposing plugin ${plugin.name}:`, error); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | this._plugins.clear(); |
| 260 | this._metadata.clear(); |
| 261 | this._core = null; |
| 262 | this._services = null; |
| 263 | |
| 264 | logger.info('PluginManager disposed'); |
| 265 | } |
| 266 | } |