diff --git a/docs/developer-guide/theme/finder-apis/plugin.md b/docs/developer-guide/theme/finder-apis/plugin.md index a77ec2d3..8585e584 100644 --- a/docs/developer-guide/theme/finder-apis/plugin.md +++ b/docs/developer-guide/theme/finder-apis/plugin.md @@ -31,3 +31,33 @@ pluginFinder.available(pluginName) ``` + +## available(pluginName, requiresVersion) + +```js +pluginFinder.available('fake-plugin', '>=2.3.0') +``` + +### 描述 + +判断一个插件是否可用,会同时判断插件是否安装和启用且插件的版本符合 `requiresVersion` 要求, + +### 参数 + +1. `pluginName:string` - 插件的唯一标识 `metadata.name`,不能为空。 +2. `requiresVersion:string` - 插件的版本要求,不能为空,例如:`>1.2.0`,`requiresVersion` 的格式遵循 [Semantic Range Expressions](https://github.com/zafarkhaja/jsemver#range-expressions)。 + +### 返回值 + +`boolean` - 插件是否可用 + +### 示例 + +```html + +
  • + + 搜索 + +
  • +``` diff --git a/versioned_docs/version-2.17/developer-guide/theme/finder-apis/plugin.md b/versioned_docs/version-2.17/developer-guide/theme/finder-apis/plugin.md index a77ec2d3..8585e584 100644 --- a/versioned_docs/version-2.17/developer-guide/theme/finder-apis/plugin.md +++ b/versioned_docs/version-2.17/developer-guide/theme/finder-apis/plugin.md @@ -31,3 +31,33 @@ pluginFinder.available(pluginName) ``` + +## available(pluginName, requiresVersion) + +```js +pluginFinder.available('fake-plugin', '>=2.3.0') +``` + +### 描述 + +判断一个插件是否可用,会同时判断插件是否安装和启用且插件的版本符合 `requiresVersion` 要求, + +### 参数 + +1. `pluginName:string` - 插件的唯一标识 `metadata.name`,不能为空。 +2. `requiresVersion:string` - 插件的版本要求,不能为空,例如:`>1.2.0`,`requiresVersion` 的格式遵循 [Semantic Range Expressions](https://github.com/zafarkhaja/jsemver#range-expressions)。 + +### 返回值 + +`boolean` - 插件是否可用 + +### 示例 + +```html + +
  • + + 搜索 + +
  • +```