> ## Documentation Index
> Fetch the complete documentation index at: https://docs.2024921.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# 功能开关

> 后台 Feature switches 的覆盖范围与存储方式

后台「设置 → 功能开关」把原本只能改 `config.js` 或源代码的开关搬到网页端，保存到 D1 `site_settings.features`。

## 开关列表

| 字段 | 默认 | 作用 |
| - | - | - |
| `pageSize` | `5` | 首页每页文章数，`0` = 不分页 |
| `ads` | `{}` | 广告总开关、AdSense Client ID 与列表上方 / 列表间隔 / 文章底部三个广告位 |
| `errorReport` | `true` | 前端错误上报；关闭后浏览器不再上报错误日志 |
| `commentGuard` | `true` | 评论蜜罐 + 时间戳反机器人；关闭后仍保留其它评论安全机制 |
| `richContent` | `true` | Mermaid / KaTeX 按需加载；关闭后正文不再加载这两个库 |

## 读取与保存

```http theme={null}
GET /api/settings
```

`features` 是 JSON 字符串，读取端需要 `JSON.parse`。保存使用 `PUT /api/settings`，请求体是合并式 upsert：

```json theme={null}
{
  "features": {
    "pageSize": 8,
    "ads": { "enabled": false },
    "errorReport": true,
    "commentGuard": true,
    "richContent": true
  }
}
```

保存后立即生效，无需改代码或重新部署；界面加载后仍会与 `config.js` 的静态默认值合并。

相关页面：[站点设置](/settings) · [配置参考](/configuration) · [可观测性](/observability)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.