* 卸载插件 * * @param name - 插件名称 * @throws 如果插件未安装或卸载失败
(name: string)
| 121 | * @throws 如果插件未安装或卸载失败 |
| 122 | */ |
| 123 | public async uninstall(name: string): Promise<void> { |
| 124 | const plugin = this._plugins.get(name); |
| 125 | if (!plugin) { |
| 126 | throw new Error(`Plugin ${name} is not installed`); |
| 127 | } |
| 128 | |
| 129 | // 检查是否有其他插件依赖此插件 |
| 130 | this._checkDependents(name); |
| 131 | |
| 132 | try { |
| 133 | logger.info(`Uninstalling plugin: ${name}`); |
| 134 | await plugin.uninstall(); |
| 135 | |
| 136 | // 从注册表中移除 |
| 137 | this._plugins.delete(name); |
| 138 | this._metadata.delete(name); |
| 139 | |
| 140 | logger.info(`Plugin ${name} uninstalled successfully`); |
| 141 | } catch (error) { |
| 142 | logger.error(`Failed to uninstall plugin ${name}:`, error); |
| 143 | throw error; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * 获取插件实例 |