Files
maoxiang d36050cff7 初始化仓库
初始化仓库
2026-09-09 13:19:09 +08:00

262 lines
9.3 KiB
JavaScript
Raw Permalink 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.
const fs = require('fs');
let c = fs.readFileSync('settings.yaml', 'utf8');
const block = ` # ============ 首页模块(拖拽排序)============
- group: homepage
label: 首页
formSchema:
- $formkit: array
name: modules
label: 首页模块
help: 拖拽调整模块顺序,每个模块设置类型后填写对应字段
sortable: true
addLabel: 添加模块
value:
- type: hero-carousel
title: Hero
hc_title: "源蝶工作室 文档中心"
hc_subtitle: "源蝶工作室官方文档站,提供产品使用指南、开发者文档与解决方案。"
hc_primary_text: 快速开始
hc_primary_url: "/categories/quick-start"
hc_primary_color: ""
hc_secondary_text: 浏览文档
hc_secondary_url: "/categories"
hc_install_options:
- label: Docker
url: "/categories/install-docker"
- label: 1Panel
url: "/categories/install-1panel"
- label: 宝塔面板
url: "/categories/install-baota"
- label: 更多方式
url: "/categories/install"
hc_carousel_enabled: false
hc_carousel_speed: 5000
hc_carousel_show_dots: true
hc_carousel_images: []
- type: quick-start
title: 快速开始
qs_layout: default
qs_more_text: 查看使用指南
qs_more_url: "/categories/use-guide"
qs_cards:
- title: 初始化站点
subtitle: 安装之后
description: "完成首次访问、创建管理员账号和基础设置。"
url: "/categories/init"
primary: true
- title: 发布第一篇文章
subtitle: 熟悉内容编辑
description: "熟悉内容编辑和发布流程。"
url: "/categories/first-post"
- title: 探索应用市场
subtitle: 主题与插件
description: "发现丰富的主题、插件以扩展站点能力。"
url: "/categories/marketplace"
itemLabels:
- type: text
label: $value.title
children:
- $formkit: select
name: type
label: 模块类型
value: hero-carousel
options:
- label: 轮播图模块(Hero)
value: hero-carousel
- label: 快速开始模块
value: quick-start
- label: 卡片模块
value: cards
- label: Docsme 适配
value: plugin-docsme
- label: MiniDocs 适配
value: plugin-minidocs
- $formkit: text
name: title
label: 模块标题
value: ""
- $formkit: text
name: hc_title
label: "Hero 主标题(仅 hero-carousel"
value: ""
- $formkit: textarea
name: hc_subtitle
label: "Hero 副标题"
value: ""
- $formkit: text
name: hc_primary_text
label: 主按钮文字
value: 快速开始
- $formkit: text
name: hc_primary_url
label: 主按钮链接
value: ""
- $formkit: color
name: hc_primary_color
label: 主按钮颜色(留空用主题色)
value: ""
- $formkit: text
name: hc_secondary_text
label: 次按钮文字
value: 浏览文档
- $formkit: text
name: hc_secondary_url
label: 次按钮链接
value: ""
- $formkit: array
name: hc_install_options
label: 安装方式标签
value: []
itemLabels:
- type: text
label: $value.label
children:
- $formkit: text
name: label
label: 名称
value: ""
- $formkit: text
name: url
label: 链接
value: ""
- $formkit: switch
name: hc_carousel_enabled
label: 启用轮播图
value: false
- $formkit: number
name: hc_carousel_speed
label: 轮播速度(毫秒)
value: 5000
- $formkit: switch
name: hc_carousel_show_dots
label: 显示导航点
value: true
- $formkit: array
name: hc_carousel_images
label: 轮播图图片组
value: []
itemLabels:
- type: attachment
label: $value.src
children:
- $formkit: attachment
name: src
label: 图片
value: ""
- $formkit: text
name: alt
label: 描述
value: ""
- $formkit: text
name: href
label: 跳转链接
value: ""
- $formkit: select
name: qs_layout
label: "快速开始布局(仅 quick-start"
value: default
options:
- label: 默认三项
value: default
- label: 彩色三项
value: colorful
- label: 标题列表
value: titled-list
- $formkit: text
name: qs_more_text
label: 标题右侧按钮文字
value: 查看使用指南
- $formkit: text
name: qs_more_url
label: 标题右侧按钮链接
value: ""
- $formkit: array
name: qs_cards
label: 快速开始卡片
value: []
itemLabels:
- type: text
label: $value.title
children:
- $formkit: text
name: title
label: 标题
value: ""
- $formkit: text
name: subtitle
label: 副标题
value: ""
- $formkit: textarea
name: description
label: 描述
value: ""
- $formkit: text
name: url
label: 链接
value: ""
- $formkit: switch
name: primary
label: 设为主推卡片
value: false
- $formkit: select
name: cards_layout
label: "卡片布局(仅 cards"
value: type1
options:
- label: 样式1(背景+标题+描述)
value: type1
- label: 样式2(图标+标题+列表)
value: type2
- label: 样式3(简洁图标+标题)
value: type3
- $formkit: array
name: cards_items
label: 卡片项
value: []
itemLabels:
- type: text
label: $value.title
children:
- $formkit: attachment
name: cover
label: 封面图
value: ""
- $formkit: text
name: title
label: 标题
value: ""
- $formkit: textarea
name: description
label: 描述
value: ""
- $formkit: text
name: url
label: 链接
value: ""
- $formkit: switch
name: show_description
label: 显示描述
value: true
- $formkit: select
name: plugin_layout
label: 插件模块布局
value: cards
options:
- label: 卡片网格
value: cards
- label: 卡片+文档列表
value: cards-list
- label: 简洁卡片
value: simple
- $formkit: text
name: plugin_collection
label: 插件集合标识
value: ""
`;
c = c.replace(' # ============ 首页设置 ============\n - group: home', block + ' # ============ 首页设置(兼容旧版)============\n - group: home');
if (c.indexOf('group: homepage') === -1) { console.log('未匹配'); process.exit(1); }
fs.writeFileSync('settings.yaml', c);
const Y = require('./node_modules/.pnpm/yaml@2.9.0/node_modules/yaml');
const s = Y.parse(fs.readFileSync('settings.yaml','utf8'));
console.log('✓ 语法正确,分组:', s.spec.forms.map(x=>x.group).join(', '));