Files
dusuniot/docs/admin-crm.md
T

46 lines
3.2 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.
# 后台(Admin / CRM)与 MCP 说明
> v0.11.0 起:后台按「功能接近原版 WordPress + 现代化 CRM 界面」重做一轮,并新增站点管理 MCP 服务器。
## 后台功能清单(/admin,React + Ant Design)
| 模块 | 路由 | 能力 |
| --- | --- | --- |
| Dashboard | `/admin/` | KPI 卡(30 天环比:订单/营收/新询盘)、近 30 天订单/询盘/营收三趋势图、询盘漏斗(new/read/replied/spam/archived 占比)、最近订单 + 最新询盘、快捷入口 |
| 页面 / 文章 | `/admin/contents/` | page/post/landing Tab、搜索、分页、删除;编辑页支持 **分类目录/标签绑定**(content_terms)、**Elementor JSON** 编辑(meta.elementor,前台 `/slug/` 通栏渲染)、**修订历史**(保存自动留档、查看/恢复)、已发布页面前台预览链接 |
| 菜单 | `/admin/menus/` | menus 4 个位置(menu-1/menu-2/max_mega_menu_1/max_mega_menu_2)+ menu_items 树编辑(父级/排序/新窗口),前台 Header/Footer 即时读取 |
| 媒体库 | `/admin/media/` | 列表/搜索/预览、alt 与标题编辑、**上传**(≤20MB,写入 uploads/YYYY/MM/,自动解析 PNG/JPEG/GIF/WebP 宽高) |
| 产品 | `/admin/products/` | CRUD + 属性/分类/特色图/图集 |
| 订单 | `/admin/orders/` | 列表/详情/状态流转 |
| 询盘 | `/admin/inquiries/` | 状态 Tab、关键字、详情抽屉、跟进流转(new→read→replied) |
| 语言 | `/admin/languages/` | 启用开关 |
| SEO / 重定向 | `/admin/seo/` | 重定向 CRUD(301/302/正则) |
| 筛选 | `/admin/filters/` | 前台产品筛选器配置 |
| 用户 | `/admin/users/` | 列表/搜索;admin 可新建用户、改角色、重置密码(最后一个 admin 防降级锁死) |
| 系统设置 | `/admin/settings/` | settings 表 kv JSON 编辑器(site/woocommerce/mail/seo),仅 admin 可保存 |
| 审计日志 | `/admin/audit/` | 全部后台写操作留痕(操作人/动作/实体/摘要),含 MCP 调用(actor 为空) |
规范:所有 server function 第一步 `requireAdmin()`;写操作落 `audit_logs`;图标全 SVG(lucide / antd icons)。
## MCP 服务器(dusuniot-cms)
- 入口:`mcp/server.ts`(Bun 直跑,stdio JSON-RPC,MCP 2024-11-05,无 SDK 依赖)
- 注册:`.zcode/config.json`(workspace 级,会话启动自动连接)
- 直连 PostgreSQL(`DATABASE_URL`,默认 `postgres://dusuniot:dusuniot@127.0.0.1:25432/dusuniot`),仅限受信任本机;写操作落审计日志(actor 为空 = MCP)
- 工具(17 个):
- `dashboard_stats` 看板统计
- `list_contents` / `get_content` / `create_content` / `update_content` / `delete_content`(自定义单页面:type=page + elementorJson,保存/更新自动留修订快照,slug 冲突自动加后缀)
- `list_revisions` / `restore_revision`
- `list_media` / `upload_media`(base64,≤20MB,自动解析宽高)
- `list_products` / `list_orders` / `update_order_status`
- `list_inquiries` / `update_inquiry_status`
- `get_setting` / `set_setting`
## 手动测试
```sh
bun mcp/server.ts # stdio;initialize → tools/list → tools/call
bun test # 11 pass
bun run build && bun scripts/prod-server.ts # 站点 + 后台 :3312
```