mirror of
https://github.com/halo-dev/docs.git
synced 2025-10-20 01:17:19 +00:00
docs: add docs for check plugin availability by version (#383)
### What this PR does? 添加插件 Finder API 中通过插件名称和版本判断某插件是否可用的 API 的文档 see also https://github.com/halo-dev/halo/pull/6236 ```release-note None ```
This commit is contained in:
@@ -31,3 +31,33 @@ pluginFinder.available(pluginName)
|
||||
</a>
|
||||
</li>
|
||||
```
|
||||
|
||||
## 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
|
||||
<!-- https://github.com/halo-sigs/plugin-search-widget -->
|
||||
<li th:if="${pluginFinder.available('PluginSearchWidget', '>=2.3.0')}">
|
||||
<a href="javascript:SearchWidget.open()" title="搜索">
|
||||
搜索
|
||||
</a>
|
||||
</li>
|
||||
```
|
||||
|
@@ -31,3 +31,33 @@ pluginFinder.available(pluginName)
|
||||
</a>
|
||||
</li>
|
||||
```
|
||||
|
||||
## 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
|
||||
<!-- https://github.com/halo-sigs/plugin-search-widget -->
|
||||
<li th:if="${pluginFinder.available('PluginSearchWidget', '>=2.3.0')}">
|
||||
<a href="javascript:SearchWidget.open()" title="搜索">
|
||||
搜索
|
||||
</a>
|
||||
</li>
|
||||
```
|
||||
|
Reference in New Issue
Block a user