# anian-plugin-equipments > 基于原作者v1.0.2代码修改 #### v1.0.2-1 1. 修改前台路由为/qiyu # plugin-equipment Halo 2.0 的装备管理插件, 支持在 Console 进行管理以及为主题端提供 `/equipments` 页面路由。 插件由 [图库管理](https://www.halo.run/store/apps/app-BmQJW) 插件 改编而来 ## 使用方式 1. 安装,插件安装和更新方式可参考: 2. 安装完成之后,访问 Console 左侧的**装备**菜单项,即可进行管理。 3. 内置模板,无需主题支持,但也可以通过主题自定义模板。 4. 前台访问地址为 `/equipments`,主题提供模板(equipments.html)。 ## 交流群 * 添加企业微信 (备注进群) * QQ群 ## 开发环境 ```bash git clone git@github.com:chengzhongxue/plugin-equipment.git # 或者当你 fork 之后 git clone git@github.com:{your_github_id}/plugin-equipment.git ``` ```bash cd path/to/plugin-equipment ``` ```bash # macOS / Linux ./gradlew pnpmInstall # Windows ./gradlew.bat pnpmInstall ``` ```bash # macOS / Linux ./gradlew build # Windows ./gradlew.bat build ``` 修改 Halo 配置文件: ```yaml halo: plugin: runtime-mode: development classes-directories: - "build/classes" - "build/resources" lib-directories: - "libs" fixedPluginPath: - "/path/to/plugin-equipment" ``` ## 主题适配 目前此插件为主题端提供了 `/equipments` 路由,模板为 `equipments.html`,也提供了 [Finder API](https://docs.halo.run/developer-guide/theme/finder-apis),可以将装备列表渲染到任何地方。 ### 模板变量 #### 路由信息 - 模板路径:/templates/equipments.html - 访问路径:/equipments | /equipments/page/{page} #### 路由可选参数 group: 图片分组名称, 对应 [#EquipmentGroupVo](#equipmentgroupvo).metadata.name 示例:/equipments?group=equipment-group-UEcvi | /equipments/page/1?group=equipment-group-UEcvi #### 变量 groups ##### 变量类型 List<[#EquipmentGroupVo](#equipmentgroupvo)> ##### 示例 ```html

``` #### 变量 equipments ##### 变量类型 [#UrlContextListResult\](#urlcontextlistresult) ##### 示例 ```html
上一页 下一页
``` ### Finder API #### groupBy() ##### 描述 获取全部分组内容。 ##### 参数 无 ##### 返回值 List<[#EquipmentGroupVo](#equipmentgroupvo)> ##### 示例 ```html

``` #### listAll() ##### 描述 获取全部装备内容。 ##### 参数 无 ##### 返回值 List<[#EquipmentVo](#equipmentvo)> ##### 示例 ```html ``` #### listBy(group) ##### 描述 根据分组获取装备列表。 ##### 参数 1. `group: string` - 装备分组名称, 对应 EquipmentGroupVo.metadata.name ##### 返回值 List<[#EquipmentVo](#equipmentvo)> ##### 示例 ```html ``` #### list(page, size) ##### 描述 根据分页参数获取装备列表。 ##### 参数 1. `page: int` - 分页页码,从 1 开始 2. `size: int` - 分页条数 ##### 返回值 [ListResult\](#listresult-equipmentvo) ##### 示例 ```html
``` #### list(page, size, group) ##### 描述 根据分页参数及装备所在组获取装备列表。 ##### 参数 1. `page: int` - 分页页码,从 1 开始 2. `size: int` - 分页条数 3. `group: string` - 装备分组名称, 对应 EquipmentGroupVo.metadata.name ##### 返回值 [ListResult\](#listresult-equipmentvo) ##### 示例 ```html
``` ### 类型定义 #### EquipmentVo ```json { "metadata": { "name": "string", // 唯一标识 "labels": { "additionalProp1": "string" }, "annotations": { "additionalProp1": "string" }, "creationTimestamp": "2022-11-20T13:06:38.512Z", // 创建时间 }, "spec": { "displayName": "string", // 装备名称 "specification": "string", // 装备规格 "description": "string", // 装备描述 "cover": "string", // 封面链接 "url": "string", // 装备链接 "priority": 0, // 优先级 "groupName": "string", // 分组名称,对应分组 metadata.name }, } ``` #### EquipmentGroupVo ```json { "metadata": { "name": "string", // 唯一标识 "labels": { "additionalProp1": "string" }, "annotations": { "additionalProp1": "string" }, "creationTimestamp": "2022-11-20T13:06:38.512Z", // 创建时间 }, "spec": { "displayName": "string", // 分组名称 "description": "string", // 分组描述 "priority": 0, // 分组优先级 }, "status": { "equipmentCount": 0, // 分组下装备数量 }, "equipments": "List<#EquipmentVo>", // 分组下所有装备列表 } ``` #### ListResult ```json { "page": 0, // 当前页码 "size": 0, // 每页条数 "total": 0, // 总条数 "items": "List<#EquipmentVo>", // 装备列表数据 "first": true, // 是否为第一页 "last": true, // 是否为最后一页 "hasNext": true, // 是否有下一页 "hasPrevious": true, // 是否有上一页 "totalPages": 0 // 总页数 } ``` #### UrlContextListResult ```json { "page": 0, // 当前页码 "size": 0, // 每页条数 "total": 0, // 总条数 "items": "List<#EquipmentVo>", // 装备列表数据 "first": true, // 是否为第一页 "last": true, // 是否为最后一页 "hasNext": true, // 是否有下一页 "hasPrevious": true, // 是否有上一页 "totalPages": 0, // 总页数 "prevUrl": "string", // 上一页链接 "nextUrl": "string" // 下一页链接 } ``` ### Annotations 元数据适配 根据 Halo 的[元数据表单定义文档](https://docs.halo.run/developer-guide/annotations-form/)和[模型元数据文档](https://docs.halo.run/developer-guide/theme/annotations),Halo 支持为部分模型的表单添加元数据表单,此插件同样适配了此功能,如果你作为主题开发者,需要为链接或者链接分组添加额外的字段,可以参考上述文档并结合下面的 TargetRef 列表进行适配。 | 对应模型 | group | kind | | ---------- | ---------------- | ---------- | | 装备 | equipment.kunkunyu.com | Equipment | | 装备分组 | equipment.kunkunyu.com | EquipmentGroup |