Files
BlackFruit-UI/plugins/addon/theme_configurator/README.md
yiqiu a9864b0cd0
All checks were successful
continuous-integration/drone/push Build is passing
feat: 为主题配置器插件新增文件上传功能及相关路由配置
2025-12-28 12:06:00 +08:00

56 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Theme Configurator 插件
此插件演示如何通过后台插件的方式为 BlackFruit-UI 主题提供可配置能力支持设置导航、页脚、站点信息、SEO、首页轮播、友情链接、荣誉资质、反馈类型以及右侧浮窗并提供 `/console/v1/theme/config` 接口与前端联动。
## 功能
- **图片上传**: 插件自带独立的上传接口 `POST /{DIR_ADMIN}/v1/upload`,支持jpg、png、gif、webp、svg等格式,最大10MB
- 后台界面(`template/admin/index.html`)通过表单 + JSON 的方式维护主题参数:
- SEO、站点基础信息企业名称、电话、备案、协议链接、产品链接等
- 首页轮播 Banner支持图片上传
- 友情链接friendly_link
- 企业荣誉honor支持图片上传
- 反馈类型feedback_type
- 右侧浮窗side / side_floating_window支持图标上传
- 复杂导航结构header_nav/footer_nav可在"高级配置 (JSON)"中维护,子菜单支持图标上传。
- 接口 `GET/POST /{DIR_ADMIN}/v1/theme/config` 提供配置读取与保存;
- 前台接口 `GET /console/v1/theme/config` 输出与 `/console/v1/common` 同结构的数据BlackFruit-UI 可以直接接入;
- 插件安装时创建 `addon_theme_configurator` 表并写入默认配置。
## 目录
```
plugins/addon/theme_configurator
├── ThemeConfigurator.php # 插件主文件
├── controller/
│ ├── ThemeController.php # 后台 API
│ └── clientarea/ThemeController.php # 前台 API
├── model/ThemeConfigModel.php # 主题配置模型
├── template/admin/index.html # 后台可视化页面
├── route.php # 自定义路由定义
├── sidebar*.php # 前后台导航
├── auth.php # 权限配置
└── lang/zh-cn.php # 多语言
```
## 使用步骤
1. 将目录复制到业务系统的 `public/plugins/addon` 下;
2. 在后台启用插件,安装脚本会自动创建 `addon_theme_configurator` 表;
3. 进入“插件 > 主题配置”页(`index.html`),按 JSON 结构维护导航、SEO、轮播、侧边栏等
4. 前端 BlackFruit-UI 请求 `/console/v1/theme/config` 以获取运行时配置。若需要兼容现有 `/console/v1/common`,可在 Nginx 或网关层做转发。
### banner 字段示例
```json
"banner": [
{
"title": "中小企业的云计算底座",
"description": "自定义文案",
"img": "/upload/banner-1.png",
"url": "/cloud.html",
"blank": false,
"button_text": "立即查看",
"button_link": "/cloud.html",
"button_blank": false
}
]
```
BlackFruit-UI 会在首页读取 `banner` 数组动态渲染轮播图,`url/blank` 控制整张 Banner 的跳转,`button_*` 控制右下角按钮。