Files
Alfred/docs/user/config.md
lanyuanxiaoyao 34071a421a refactor: 品牌重塑 my-app → Alfred·阿福
将项目从模板标识 my-app 全部替换为产品标识 Alfred·阿福,
去掉所有模板措辞,文档语态转为产品视角。

核心标识替换:
- name: my-app → alfred
- title: My App → Alfred·阿福
- subtitle: Bun 全栈应用 → 智能信息处理中枢
- description: 全栈开发框架 → 基于 AI 的信息综合处理平台
- 日志路径: my-app.log → alfred.log
- 构建产物: dist/my-app → dist/alfred(由 APP.name 自动适配)

文档更新:
- README.md 重写为产品介绍
- docs/README.md 去掉模板段落
- docs/user/ 从模板使用指南改为产品手册
- docs/development/ 标识替换 + 去模板措辞
- openspec/config.yaml 去模板项目描述
- LICENSE 填入 Copyright 2025 lanyuanxiaoyao
2026-05-27 09:38:57 +08:00

107 lines
3.4 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.
# 配置文件
项目使用 YAML 配置文件,配置文件为启动时的必传参数,支持通过 JSON Schema 编辑器提示和显式变量引用。配置中的相对路径均基于配置文件所在目录解析,绝对路径保持不变。
## 配置文件
复制 config.example.yaml 为 config.yaml或任意名称根据需要修改
```yaml
# yaml-language-server: $schema=./config.schema.json
server:
listen:
host: "127.0.0.1"
port: 3000
storage:
dataDir: ./data
logging:
level: info
console:
level: info
file:
level: info
path: "./logs/alfred.log"
rotation:
size: 50MB
frequency: daily
maxFiles: 14
```
## server.listen
| 字段 | 类型 | 说明 |
| ---- | ------ | ------------------------ |
| host | string | 监听地址,默认 127.0.0.1 |
| port | number | 监听端口,默认 3000 |
## server.storage
| 字段 | 类型 | 说明 |
| ------- | ------ | --------------------------------------------------- |
| dataDir | string | 数据目录,默认 ./data相对路径基于配置文件目录解析 |
## server.logging
| 字段 | 类型 | 说明 |
| ----- | ------ | ------------------------------------------------------------ |
| level | string | 全局日志级别trace/debug/info/warn/error/fatal默认 info |
### server.logging.console
| 字段 | 类型 | 说明 |
| ----- | ------ | ------------------------------------------------- |
| level | string | 控制台日志级别,未设置时继承 server.logging.level |
### server.logging.file
| 字段 | 类型 | 说明 |
| ----- | ------ | ----------------------------------------------- |
| level | string | 文件日志级别,未设置时继承 server.logging.level |
| path | string | 日志文件路径,默认 <dataDir>/logs/alfred.log |
### server.logging.file.rotation
| 字段 | 类型 | 说明 |
| --------- | ------ | --------------------------------------------- |
| size | string | 按大小轮转,支持 B/KB/MB/GB 单位,默认 50MB |
| frequency | string | 按时间轮转hourly/daily/weekly默认 daily |
| maxFiles | number | 最大归档文件数,默认 14 |
## JSON Schema
根目录 config.schema.json 为配置文件的 JSON Schema支持 IDE 自动补全和校验。
```bash
bun run schema # 重新生成 config.schema.json
bun run schema:check # 校验 config.schema.json 是否同步
```
## 变量语法
YAML 配置中支持显式变量引用:
```text
${KEY} 引用变量,未定义时报错
${KEY|value} 引用变量,未定义时使用默认值
${KEY|} 引用变量,未定义时使用空字符串
$${KEY} 转义,输出 ${KEY} 原文字面量
```
变量解析优先级variables 字段 > process.env > 默认值 > unresolved 报错
完整变量引用(整个值只有 ${...})保留原始类型:${PORT|3000} 解析为 number 3000。部分拼接统一转为 string。
## 配置优先级
```
variables 字段 > 环境变量 > 默认值 > unresolved 报错
```
环境变量不会隐式覆盖配置,只有通过 ${KEY} 显式引用时才生效。
## 使用自定义配置
```bash
bun run dev custom-config.yaml
```