User 69e88e27
发布于:2026-03-02
schema 中配置 batch_create_url 来实现。
使站点在管理端中可以按需提供批量创建页面的功能。1. 用户在页面管理界面中点击"批量创建"按钮
↓
2. 系统获取该页面的模板及其子模板信息
↓
3. 如果子模板的 schema 中配置了 batch_create_url,则显示批量创建选项
↓
4. 用户点击某个模板的批量创建选项
↓
5. 系统生成包含认证信息的 batch_create_url 并在 iframe 中打开
↓
6. 用户在 iframe 中进行批量导入操作
↓
7. iframe 中的页面通过 API 调用创建页面
batch_create_url.liquid 模板文件中,在 {% schema %} 部分添加 batch_create_url 配置:{% schema %}
{
"name": "页面模板名称",
"description": "页面模板描述",
"batch_create_url": "https://your-import-service.com/batch_import", // 或者 "/s/batch_import"(模版中静态地址)
"settings": [
// ... 其他模板设置
]
}
{% endschema %}
batch_create_url 的两种形式{
"batch_create_url": "https://external-service.com/batch_import"
}
token: 用户的临时 API token(JWT 格式)
- site_id: 当前站点 ID
- full_path: 父页面的完整路径
- template_name: 模板名称
- template_style: 模板风格https://external-service.com/batch_import?
token=JWT+eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE3NzAyOTY1NTh9...
&site_id=34
&full_path=%2F80ec12
&template_name=page
&template_style=style
{
"batch_create_url": "/s/batch_import"
}
http://site-demo.baklib.localhost:3000/s/batch_import?
token=JWT+eyJhbGciOiJIUzI1NiJ9...
&site_id=34
&full_path=%2Fparent
&template_name=page
&template_style=style
{%
# 模板的 HTML/Liquid 内容
%}
{% schema %}
{
"name": "数据批量导入页面",
"description": "支持批量创建页面的模板",
"thumb_url": "images/theme/batch_import_page.png",
"batch_create_url": "https://api.example.com/pages/batch_import",
"settings": [
{
"id": "title",
"type": "text",
"label": "页面标题"
},
{
"id": "description",
"type": "richtext",
"label": "页面描述"
},
{
"id": "enable_batch_import",
"type": "checkbox",
"label": "启用批量导入",
"default": true
}
]
}
{% endschema %}
| 参数 | 说明 | 示例 |
|---|---|---|
token |
JWT 格式的 API 认证 token | JWT eyJhbGciOiJIUzI1NiJ9... |
site_id |
站点的数字 ID | 34 |
full_path |
父页面的完整路径(URL 编码) | %2F80ec12 |
template_name |
模板名称 | page |
template_style |
模板风格 | style |
/ 开头)token 是临时 API token,有过期时间限制site_id 和 full_path 参数的有效性batch_create_url 指向的页面中提供清晰的导入说明template_name: 模板的基础名称(如 page, article)template_style: 模板的风格变体(如 default, dark, compact)batch_create_url
- batch_create_url 值为空或 null
- 子模板没有正确关联到父模板schema 部分
2. 确保 batch_create_url 有有效的值
3. 验证模板的 sub_page_templates 配置