Merge branch 'xuhd' of http://192.168.0.200/knowledge-base-bj/deerflow-server into liuq
This commit is contained in:
commit
9afcacc223
549 files changed
+78425
-7062
No files matched your search
@@ -16,9 +16,17 @@ VITE_AIPI_GENERATE_CHAT_URL=https://ch1.b.uat.4.cn/jialai_b1_chat
|
||||
VITE_AIPI_TASK_CHAT_URL=https://ch1.b.uat.4.cn/qq_b1_chat
|
||||
VITE_AIPI_KNOWLEDGE_URL=https://chlib.b.uat.4.cn/knowlibrary
|
||||
VITE_AIPI_B1COH_URL=https://ch1.b.uat.4.cn/web
|
||||
VITE_AIPI_B2ACTOR_URL=htttps://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_URL=https://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_XWT_PATH=/fromB/toXWT?isFrame=1
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_API_URL=https://ch1.b.uat.4.cn/knowes/api/iframeKnowledgeUrl
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red
|
||||
VITE_AIPI_B2ACTOR_XWT_PATH=/fromB/toXWT?isFrame=1
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_API_URL=https://ch1.b.uat.4.cn/knowes/api/iframeKnowledgeUrl
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red
|
||||
VITE_AIPI_MOPECHAT_URL=https://ch1.b.uat.4.cn/likun_b1_mope
|
||||
VITE_AIPI_BACKENP_URL=https://knowledgetoolserver.b.uat.4.cn
|
||||
# 我的笔记前端
|
||||
VITE_AIPI_FRONTEND_URL= xxx
|
||||
VITE_AIPI_CONSUMER_URL=https://ch1.b.uat.4.cn/consumer
|
||||
VITE_AIPI_PGLINKTO_URL=https://pg.b.uat.4.cn
|
||||
VITE_AIPI_XKLINKTO_URL=https://kz.b.uat.4.cn
|
||||
|
||||
@@ -10,7 +10,10 @@ VITE_AIPI_GENERATE_CHAT_URL=https://ch1.b.uat.4.cn/jialai_b1_chat
|
||||
VITE_AIPI_TASK_CHAT_URL=https://ch1.b.uat.4.cn/qq_b1_chat
|
||||
VITE_AIPI_KNOWLEDGE_URL=https://chlib.b.uat.4.cn/knowlibrary
|
||||
VITE_AIPI_B1COH_URL=https://ch1.b.uat.4.cn/web
|
||||
VITE_AIPI_B2ACTOR_URL=htttps://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_URL=https://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_XWT_PATH=/fromB/toXWT?isFrame=1
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_API_URL=https://ch1.b.uat.4.cn/knowes/api/iframeKnowledgeUrl
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red
|
||||
VITE_AIPI_MOPECHAT_URL=https://ch1.b.uat.4.cn/likun_b1_mope
|
||||
VITE_AIPI_BACKENP_URL=https://knowledgetoolserver.b.uat.4.cn
|
||||
VITE_AIPI_CONSUMER_URL=https://ch1.b.uat.4.cn/consumer
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
# --- 生产打包(见 .env.production)---
|
||||
# 部署前修改 .env.production 中的地址,再执行 pnpm build
|
||||
|
||||
# VITE_AIPI_B2ACTOR_URL=https://ty.b.uat.4.cn
|
||||
# VITE_AIPI_B2ACTOR_XWT_PATH=/fromB/toXWT?isFrame=1
|
||||
# VITE_AIPI_KNOWLEDGE_IFRAME_API_URL=https://ch1.b.uat.4.cn/knowes/api/iframeKnowledgeUrl
|
||||
# VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red
|
||||
|
||||
# 可选
|
||||
# VITE_CANVAS_LANGGRAPH_BASE_URL=
|
||||
# VITE_STATIC_WEBSITE_ONLY=
|
||||
|
||||
@@ -14,7 +14,10 @@ VITE_AIPI_GENERATE_CHAT_URL=https://ch1.b.uat.4.cn/jialai_b1_chat
|
||||
VITE_AIPI_TASK_CHAT_URL=https://ch1.b.uat.4.cn/qq_b1_chat
|
||||
VITE_AIPI_KNOWLEDGE_URL=https://chlib.b.uat.4.cn/knowlibrary
|
||||
VITE_AIPI_B1COH_URL=https://ch1.b.uat.4.cn/web
|
||||
VITE_AIPI_B2ACTOR_URL=htttps://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_URL=https://ty.b.uat.4.cn
|
||||
VITE_AIPI_B2ACTOR_XWT_PATH=/fromB/toXWT?isFrame=1
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_API_URL=https://ch1.b.uat.4.cn/knowes/api/iframeKnowledgeUrl
|
||||
VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red
|
||||
VITE_AIPI_MOPECHAT_URL=https://ch1.b.uat.4.cn/likun_b1_mope
|
||||
VITE_AIPI_BACKENP_URL=https://knowledgetoolserver.b.uat.4.cn
|
||||
VITE_AIPI_CONSUMER_URL=https://ch1.b.uat.4.cn/consumer
|
||||
|
||||
@@ -12,14 +12,15 @@
|
||||
|
||||
- 三个圆桌 Router(`intent / recommend / multi_agent`)**通过 httpx ASGITransport 进程内直调本机 ASGI app**,复用既有 `/api/threads`、`/api/agents`、`/api/threads/{id}/runs/stream` 路由——**不走 TCP / 不经过网络栈**。所有 client 都由 `multi_agent._make_loopback_client(request)` 工厂统一构造。
|
||||
- 历史包袱:早期实现走 `httpx.AsyncClient(trust_env=False)` + `127.0.0.1:<port>`,遇到开发机 `HTTP_PROXY` / `HTTPS_PROXY` 时仍可能把回环走代理(症状 `headers_in=42.160s`)。**改用 ASGITransport 后此问题不再存在**,相关 `trust_env=False` workaround 全部移除。
|
||||
- **席位 agent 持久注册**(磁盘 `.deer-flow/agents/` + `_sync_legacy_agents`),**协调智能体每次新建**(命名 `roundtable-coordinator-{timestamp36}`,DB 累积,需后续 GC)。
|
||||
- **`.deer-flow/` 整个目录被 git ignore**(仓库根 `.gitignore` 第 64 / 74 行),`git clone` 后内置 agent 目录在部署机上**不会存在**——任何环境都必须把 `roundtable-intent` + `roundtable-recommender` 两个**功能型 agent** 持久化进发布物,否则 `/api/intent/stream` 报 500。**互联网 demo 还需要 6 个示例研讨席位**(`roundtable-intelligence` 等),**内网部署用客户自有 agent 替代**这些席位,无需打包。详见 §11.7。
|
||||
- **席位 agent 持久注册**(磁盘 `.deer-flow/agents/` + `_sync_legacy_agents`),**协调智能体也是持久单例**(id 固定为 `roundtable-coordinator`,与 intent/recommender 同样走 `_roundtable_seed.ensure_roundtable_functional_agents()` 缺失自动落地)。2026-05 之前曾按 `roundtable-coordinator-{timestamp36}` 每会话新建并把动态席位列表写进 SOUL,导致 `.deer-flow/agents/` 累积大量壳目录;改造后 SOUL 是静态通用版本,「本次可调度席位列表」由 `multi_agent.init` 在 coordinator thread 创建后以 human 消息追加到对话历史,leader run 每轮都能看到。
|
||||
- **`.deer-flow/` 整个目录被 git ignore**(仓库根 `.gitignore` 第 64 / 74 行),`git clone` 后内置 agent 目录在部署机上**不会存在**。但功能型 agent 现在通过 `_roundtable_seed.ensure_roundtable_functional_agents()` **自动落地**(首次任何 intent/recommend/multi-agent 路由调用都会触发),因此**新部署不再需要手动准备** `roundtable-intent` / `roundtable-recommender` / `roundtable-coordinator` 三个目录——它们都是 seeder 自动写盘的。**互联网 demo 仍需要 6 个示例研讨席位**(`roundtable-intelligence` 等),**内网部署用客户自有 agent 替代**这些席位,无需打包。详见 §11.7。
|
||||
- **`init` 是 SSE 而非一次性 JSON**:用 `asyncio.as_completed` 按真实完成顺序推送 `seat_ready`,前端因此能逐个点亮席位。
|
||||
- **`init_done.thread_ids` 包含协调智能体自身**(`agent_threads[main_agent_name] = coord_thread`),前端 Step 3 列文件时需自行过滤。
|
||||
- **澄清协议统一**:Step 1 与 Step 2 leader 都借 `ask_clarification` + 终态 `clarification` 帧驱动同一套选项卡片组件;`allow_multiple` 默认 false(单选、点击即发送)。
|
||||
- **leader 共识 = `status: []` 空数组**;澄清 = `status: "clarification"`(字符串);派活 = `status: [[name, task], ...]`。这三者**互斥不混用**。
|
||||
- **后端 picks clamp 2–6,前端用户可手动加到 8**。
|
||||
- **不写死任何具体模型名**:`intent / recommend / multi_agent` 三个 router 的 `model_name = str(payload.get("model") or "")`,空串会被下游 `lead_agent._resolve_model_name()` 自动回退到 `config.yaml` 的 `models[0]`(与 `/api/ai-writing` 行为一致)。内网部署只需配 `config.yaml`,前后端均无需改硬编码。
|
||||
- **草稿/推荐历史持久化(2026-06)**:圆桌页的「历史草稿」从浏览器 `localStorage` 迁到**后端 MySQL**(`/api/roundtable-drafts`,按登录用户隔离);新增**会话级推荐历史**让推荐弹窗回显上次结果。两张表 `roundtable_drafts` / `roundtable_recommend_history`,启动 `create_all` 自动建表,详见 §7A。
|
||||
|
||||
---
|
||||
|
||||
@@ -73,7 +74,12 @@ offline-backend-20260512/backend/
|
||||
│ ├── multi_agent.py # Step 2:init(SSE) + run/stream + 共享的 loopback 工具
|
||||
│ ├── intent.py # Step 1:init + stream(import multi_agent 工具)
|
||||
│ ├── recommend.py # Step 1→2:推荐 stream(import multi_agent 工具)
|
||||
│ └── artifacts.py # Step 3:列出/下载/编辑 thread 产出(通用,非圆桌专用)
|
||||
│ ├── artifacts.py # Step 3:列出/下载/编辑 thread 产出(通用,非圆桌专用)
|
||||
│ └── roundtable_drafts.py # 持久化:草稿 CRUD + 推荐历史(§7A,2026-06 新增)
|
||||
├── packages/harness/deerflow/persistence/roundtable_drafts/
|
||||
│ ├── model.py # ORM:RoundtableDraftRow + RoundtableRecommendHistoryRow
|
||||
│ ├── sql.py # RoundtableDraftRepository(CRUD + 历史)
|
||||
│ └── __init__.py # make_roundtable_draft_store(sf)
|
||||
├── packages/harness/deerflow/tools/builtins/
|
||||
│ └── clarification_utils.py # resolve_allow_multiple + coerce_bool(Step1/Step2 共享)
|
||||
└── .deer-flow/agents/
|
||||
@@ -110,8 +116,15 @@ offline-backend-20260512/backend/
|
||||
| GET | `/api/threads/{thread_id}/artifacts` | 3 | 列出该 thread 的 outputs 文件 |
|
||||
| GET | `/api/threads/{thread_id}/artifacts/{path}` | 3 | 预览/下载单个产出(含 `.skill/` 内文件提取) |
|
||||
| PATCH | `/api/threads/{thread_id}/artifacts/{path}` | 3 | 编辑文本类产物(白名单后缀) |
|
||||
| GET | `/api/roundtable-drafts` | 持久化 | 列出当前用户草稿(轻量元数据) |
|
||||
| POST | `/api/roundtable-drafts` | 持久化 | 新建草稿 |
|
||||
| GET | `/api/roundtable-drafts/{id}` | 持久化 | 取草稿全量(含 step1/step2 快照) |
|
||||
| PUT | `/api/roundtable-drafts/{id}` | 持久化 | 局部更新(title / furthest_step / step1 / step2) |
|
||||
| DELETE | `/api/roundtable-drafts/{id}` | 持久化 | 删除草稿 |
|
||||
| GET | `/api/roundtable-drafts/{id}/recommendations` | 持久化 | 列出该草稿的推荐历史(倒序) |
|
||||
| POST | `/api/roundtable-drafts/{id}/recommendations` | 持久化 | 追加一次推荐记录 |
|
||||
|
||||
字段级请求/响应见各 step 的 API 文档;下文只写**后端实现语义**。
|
||||
字段级请求/响应见各 step 的 API 文档;下文只写**后端实现语义**。圆桌草稿/推荐历史持久化见 §7A。
|
||||
|
||||
---
|
||||
|
||||
@@ -282,33 +295,50 @@ offline-backend-20260512/backend/
|
||||
请求体:
|
||||
{
|
||||
"agent_names": ["roundtable-intelligence", ...], // 用户选的席位 id
|
||||
"main_agent_name": "roundtable-coordinator-xxx", // 当次总控 id,前端生成
|
||||
"model": "deepseek-chat" // 可选,写入 coordinator agent
|
||||
"main_agent_name": "<可选,已废弃>", // 历史字段;2026-05 改造后后端忽略,统一用 COORDINATOR_AGENT_ID
|
||||
"model": "deepseek-chat" // 可选;不传由 lead_agent 回退到 config.yaml models[0]
|
||||
}
|
||||
```
|
||||
|
||||
**协调智能体改造说明(2026-05)**:以前 `main_agent_name` 由前端用时间戳生成
|
||||
(`roundtable-coordinator-${Date.now().toString(36)}`),后端 `_create_coordinator_direct`
|
||||
把动态拼接的席位列表 SOUL 写盘并入 DB,导致 `.deer-flow/agents/` 越用越多。改造后:
|
||||
|
||||
- **id 固定**:`COORDINATOR_AGENT_ID = "roundtable-coordinator"`(前后端常量必须保持一致);
|
||||
- **缺失自动落地**:路由入口调 `ensure_roundtable_functional_agents()`,与 intent/recommender 共用同一套 seeder;
|
||||
- **席位列表运行时注入**:init 创建好 coordinator thread 之后,立刻通过 `_append_thread_message` 把「【圆桌系统初始化】本次可调度席位:…」作为 human 消息追加到 thread 历史最前面,leader run 每轮都能看到;
|
||||
- **`main_agent_name` 入参保留为向后兼容**:旧 client 仍可传,后端只是日志里看到不会用它创建新 agent。
|
||||
|
||||
**早期校验**(同步抛 HTTP 4xx,**不**进 SSE):
|
||||
|
||||
- `agent_names` 必须非空
|
||||
- 每个 `agent_names` 元素 + `main_agent_name` 都需通过 `_AGENT_ID_PATTERN = ^[A-Za-z0-9_-]+$`(用 `_validate_agent_id` 提前 400;上游若收到不合规 id 会抛 422,提前拦更友好)
|
||||
- 每个 `agent_names` 元素需通过 `_AGENT_ID_PATTERN = ^[A-Za-z0-9_-]+$`(用 `_validate_agent_id` 提前 400;上游若收到不合规 id 会抛 422,提前拦更友好)
|
||||
- 所有 id 都 `.lower()` 后比较 / 存储
|
||||
- `main_agent_name` 入参不再做校验(被忽略,统一用 `COORDINATOR_AGENT_ID` 常量)
|
||||
|
||||
**SSE 内部流程**:
|
||||
**SSE 内部流程**(2026-05 单例改造后):
|
||||
|
||||
```
|
||||
ensure_roundtable_functional_agents()
|
||||
// 路由入口:保证 .deer-flow/agents/roundtable-coordinator/ 存在
|
||||
// 缺失时由 _roundtable_seed.COORDINATOR_AGENT_SOUL 落地静态 SOUL
|
||||
|
||||
asyncio.as_completed(各席位 _prepare_sub_agent)
|
||||
每完成一个 → data: {"event":"seat_ready","agent_name","thread_id","display_name","description"}
|
||||
(按真实完成顺序,先完成先发,前端因此能逐个点亮)
|
||||
|
||||
异常时:取消所有未完成的 task,避免泄露到 AsyncClient close 之后
|
||||
|
||||
协调智能体:
|
||||
POST /api/threads → coord_thread
|
||||
POST /api/agents
|
||||
skills=["agent_orchestration"]
|
||||
soul=动态拼接(本次 init 的席位列表 + 派活规则)
|
||||
id=main_agent_name(前端生成的 roundtable-coordinator-<ts36>)
|
||||
协调智能体(单例):
|
||||
main_agent_name = COORDINATOR_AGENT_ID # 固定常量,不再每次新建 agent
|
||||
coord_thread = _create_thread_direct(...) # 仍然每次新 thread,会话独立
|
||||
agent_threads[main_agent_name] = coord_thread // ⚠️ thread_ids 含 coordinator 自身
|
||||
|
||||
# 通过 HTTP loopback append 一条 human 消息,把本次席位清单写入对话历史:
|
||||
# "【圆桌系统初始化】本次研讨可调度的席位清单如下..."
|
||||
# leader run 每轮都能从对话历史里读到,等效于旧版动态 SOUL 的作用。
|
||||
_append_thread_message(seed_client, ..., coord_thread, seat_introduction)
|
||||
|
||||
→ data: {"event":"coordinator_ready","main_agent_name","thread_id"}
|
||||
|
||||
→ data: {"event":"init_done","main_agent_name","thread_ids":{...}}
|
||||
@@ -316,28 +346,26 @@ asyncio.as_completed(各席位 _prepare_sub_agent)
|
||||
失败 → data: {"event":"error","detail":"..."}
|
||||
```
|
||||
|
||||
**协调智能体创建幂等**:若 `_create_agent` 返回 (False, "exists ...")(同名 agent 已存在)则继续往下走,不报错。注意这里的「已存在」会复用历史 agent 的 SOUL(与本次动态拼接的不同),通常只在前端用同一个时间戳跑过两遍时触发。
|
||||
**协调智能体单例 SOUL**(磁盘上唯一一份,见 `_roundtable_seed.COORDINATOR_AGENT_SOUL`):
|
||||
|
||||
**协调智能体 SOUL**(动态拼接,与席位列表一起写入):
|
||||
通用协调规则,**不含**席位列表。模型派活时从对话历史最前面的「【圆桌系统初始化】…」消息读取本次可用 agent_name。仍然强调英文 id(避免把中文显示名拼进 `agent_name`),靠后端 `_strip_display_suffix` 兜底(详见 §6.4)。
|
||||
|
||||
**席位清单注入消息形状**(init 阶段写入 coordinator thread):
|
||||
|
||||
```
|
||||
#核心定位:
|
||||
用途:根据用户的任务目标,调用其他智能体干活,只负责协调汇总,
|
||||
当你觉得已有信息支持回答用户问题时候,停止调度,并输出最后的结果
|
||||
|
||||
#调度方法:
|
||||
通过使用 agent_orchestration 技能调用其他智能体干活,使用技能时传入
|
||||
agent_name 和需要做的活。
|
||||
⚠️ agent_name 必须严格使用下方列出的英文 id(例如 roundtable-intelligence),
|
||||
不要把括号里的中文显示名拼进 agent_name 里。
|
||||
|
||||
#可调度智能体:
|
||||
- agent_name: roundtable-intelligence(情报收集):<description>
|
||||
- agent_name: roundtable-environment(环境评估):<description>
|
||||
【圆桌系统初始化】本次研讨可调度的席位清单如下,请严格按 agent_name 通过 agent_orchestration 技能派活,不要派给不在清单内的 agent:
|
||||
- agent_name: roundtable-intelligence(情报收集):<description>
|
||||
- agent_name: roundtable-environment(环境评估):<description>
|
||||
...
|
||||
```
|
||||
|
||||
中文显示名通过 `GET /api/agents/{id}` 取 `name`、描述取 `description`。**强调英文 id** 是因为部分模型会把整段 `roundtable-x(中文)` 当 `agent_name` 塞回来,靠后端 `_strip_display_suffix` 兜底(详见 §6.4)。
|
||||
中文显示名通过 `_get_agents_batch_direct` 一次 DB 查询取 `name`、描述取 `description`。
|
||||
|
||||
**单例 agent 的几个语义保障**:
|
||||
|
||||
1. **agent 落地幂等**:`_ensure_one` 检查目录是否存在,存在就 no-op,不覆盖运维手改的 SOUL;
|
||||
2. **席位列表 append 失败不阻断**:`_append_thread_message` 包在 try/except 里,失败只记 warning,leader run 仍能跑(只是看不到席位清单,可能派活到错的 id,由 `_validate_agent_id` 在 run/stream 里报错);
|
||||
3. **`_create_coordinator_direct` 已删除**:旧函数已移除(2026-05 改造),避免后续维护者误调;如果你正在 review 旧 PR 看到这个函数,那是 pre-rebase 版本。
|
||||
|
||||
### 6.2 `/run/stream` — `agent_type = "leader"`(`_leader_run`)
|
||||
|
||||
@@ -574,6 +602,53 @@ Step 3 **没有** 单独的 `multi_agent` 路由;使用既有 artifacts 能力
|
||||
|
||||
---
|
||||
|
||||
## 7A. 圆桌草稿与推荐历史持久化(`roundtable_drafts.py`,2026-06)
|
||||
|
||||
圆桌规划页的「历史记录」此前只存浏览器 `localStorage`(前端 `utils/drafts.ts`),换设备/清缓存即丢、大对话还会撞 5MB 配额。2026-06 迁到**后端 MySQL**,按登录用户隔离、跨设备保留;并新增**会话级推荐历史**,让推荐弹窗能回显上次推荐结果。
|
||||
|
||||
### 7A.1 数据模型(`deerflow.persistence.roundtable_drafts`)
|
||||
|
||||
仿 `user_prompts`(最简 CRUD)+ `ai_writing_sessions`(大 JSON 用 `PortableLongText` 存)两个现有模式。两张表:
|
||||
|
||||
- **`roundtable_drafts`**(会话主表,一条 = 一次完整圆桌会话)
|
||||
- `id`(PK, str64) / `user_id`(idx) / `title`(512) / `furthest_step`(int, 1|2|3)
|
||||
- `step1` / `step2`:前端 `DraftStep{1,2}Snapshot` 的 JSON,列类型 **`PortableLongText`**(MySQL `LONGTEXT`),避免 Step 2 长对话 + `seatStubMessages` 撞 `TEXT` 64KB 上限
|
||||
- `created_at` / `updated_at`:**`BeijingDateTime`**(项目规范,存北京时间且 tz-aware)
|
||||
- **`roundtable_recommend_history`**(推荐历史,按 `draft_id` 归属)
|
||||
- `id`(PK) / `user_id`(idx) / `draft_id`(idx) / `objective`(512) / `status`(32: done|fallback|asking|error) / `model`(128)
|
||||
- `rationale` / `picks`(JSON) / `candidates`(JSON 候选池快照):均 `PortableLongText`
|
||||
- `created_at`:`BeijingDateTime`
|
||||
|
||||
JSON 列在 repo(`sql.py`)里用 `json.dumps/loads` 手动序列化(与 `ai_writing_sessions.transcript` 同法)。两个 Row 已登记进 `persistence/models/__init__.py`,**启动时 `Base.metadata.create_all` 自动建表**——新部署无需手动建表(需 mysql 账号有建库/表权限)。
|
||||
|
||||
### 7A.2 路由(`app/gateway/routers/roundtable_drafts.py`,前缀 `/api/roundtable-drafts`)
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
|------|------|------|
|
||||
| GET | `` | `list_drafts` → 轻量元数据列表(不含 step 大 blob),按 `updated_at` 倒序 |
|
||||
| POST | `` | `create_draft`,可带客户端 `id`(稳定 id 跨 create+update) |
|
||||
| GET | `/{id}` | `get_draft` 全量;非属主 → 404 |
|
||||
| PUT | `/{id}` | `update_draft`,`model_dump(exclude_unset=True)` → 只更新客户端实际发的字段 |
|
||||
| DELETE | `/{id}` | 204;非属主 → 404 |
|
||||
| GET | `/{id}/recommendations` | 推荐历史倒序 |
|
||||
| POST | `/{id}/recommendations` | 追加一次推荐(先校验草稿属主,404 拦截越权) |
|
||||
|
||||
鉴权/属主:用 `_current_user_id(request)`(登录态取 `request.state.user.id`,无登录回退 `get_effective_user_id()` 的 `"default"`),与 `user_prompts` 一致;所有 repo 读写按 `user_id` 过滤,跨用户访问一律 404。store 在 `deps.py` 接为 `app.state.roundtable_draft_store`(`make_roundtable_draft_store(sf)`),`app.py` `include_router`。
|
||||
|
||||
### 7A.3 与前端的契约要点
|
||||
|
||||
- **PUT 不带 `title` 时不改标题**:前端自动保存只发 `furthest_step`/`step1`/`step2`,不发 `title`,因此**不会覆盖用户手动重命名**;标题只在 create(派生)与显式重命名(只发 title)时改。
|
||||
- **推荐时机**:前端在打开推荐弹窗前先 `ensureDraft` 落地草稿拿到 `draft_id`,推荐完成后 POST 一条历史;重开弹窗 GET 历史回显最近一次,可「重新分析」再 POST。
|
||||
- **字段命名**:后端 snake_case(`furthest_step`/`created_at`),前端 `api/drafts.ts` 在边界映射成 camelCase。
|
||||
|
||||
### 7A.4 设计取舍
|
||||
|
||||
- **整存 JSON 而非拆表**:step1/step2 形状宽且常变(前端 hook 里是 loose 类型),整存 JSON 避免每次改前端快照都要迁库;代价是后端不校验嵌套字段(与 `ai_writing_sessions.transcript` 同取舍)。
|
||||
- **推荐历史绑定草稿而非全局**:语义是「这个会话上次推荐了什么」,故按 `draft_id` 归属;这也要求推荐前必有 `draft_id`(前端 `ensureDraft` 保证)。
|
||||
- **本地 dev 走 sqlite**:`config.yaml` `database.backend` 本地默认 sqlite,走同一套 SQLAlchemy 代码,`PortableLongText/JSON` 各自降级;生产切 mysql 用同一份代码。
|
||||
|
||||
---
|
||||
|
||||
## 8. 内置席位 SOUL 设计要点
|
||||
|
||||
每个 `roundtable-*`(除 intent / recommender)遵循统一结构:角色定位、核心职责、输出风格(emoji + 简短结论)、边界(只产出本席位、等总控派活)。
|
||||
@@ -609,13 +684,20 @@ httpx.AsyncClient(
|
||||
|
||||
**已废止的 `trust_env=False` workaround**:旧版本走 `127.0.0.1:<port>` 真实 HTTP,需要 `trust_env=False` 阻止 httpx 读 `HTTP_PROXY` 把回环也走代理(症状日志 `headers_in=42.160s`)。改 ASGITransport 后这个问题在物理上已不存在——根本没走网络栈。
|
||||
|
||||
### 9.2 协调智能体每次新建
|
||||
### 9.2 协调智能体单例(2026-05 改造)
|
||||
|
||||
`main_agent_name` 形如 `roundtable-coordinator-{timestamp36}`,会话隔离;长期会累积 agent 目录(实际仓库已有数十个 `roundtable-coordinator-mp*`),需后续 GC 策略:
|
||||
历史实现 `main_agent_name = roundtable-coordinator-{timestamp36}`,会话隔离,但长期会累积 agent 目录(仓库里曾积累几十个 `roundtable-coordinator-mp*` 壳目录)。2026-05 改造选用上方决策 §9.2 选项 C 的本质:**把 coordinator 实例化为「内置 + 静态 SOUL + 运行时注入席位列表」**,固定 id `roundtable-coordinator`,与 `roundtable-intent` / `roundtable-recommender` 同样走 `ensure_roundtable_functional_agents()` 缺失自动落地。
|
||||
|
||||
- 选项 A:定时任务清理 N 天前无活跃 thread 的 coordinator agent
|
||||
- 选项 B:每次创建前 LRU 清理(注意:跨服务实例难协调)
|
||||
- 选项 C:把 coordinator 实例化为「内置 + 动态 SOUL」复用同一个 id
|
||||
实现要点:
|
||||
|
||||
- **磁盘 SOUL 是通用版本**:不含本次席位列表,只规定协调规则、工具用法、终止条件;
|
||||
- **席位列表运行时注入**:init 创建 coordinator thread 后立刻 `_append_thread_message` 写入一条 human 消息("【圆桌系统初始化】…"),位置在对话历史最前面,leader run 每轮自然读到;
|
||||
- **`_create_coordinator_direct` 已删除**:不再有"每次创建"路径。
|
||||
|
||||
**遗留 `roundtable-coordinator-*` 目录的处理**:仓库可能仍有几十个历史时间戳壳目录。改造后**不会**再生成新的,但旧目录目前不自动清理(避免破坏可能仍存在的旧草稿引用)。运维可通过:
|
||||
|
||||
- 在 admin agents 管理页逐个 DELETE;
|
||||
- 或写一次性脚本扫描 `.deer-flow/agents/roundtable-coordinator-*` 并删除目录 + DB 记录(注意不要删除 `roundtable-coordinator` 本体)。
|
||||
|
||||
### 9.3 澄清协议统一
|
||||
|
||||
@@ -705,15 +787,22 @@ offline-backend-20260512/backend/.deer-flow/*
|
||||
|
||||
| Agent | 角色 | 是否必须打包发布 |
|
||||
|-------|------|------------------|
|
||||
| `roundtable-intent` | **功能型**:Step 1 任务理解,所有部署都用它 | ✅ **必须**(任何环境) |
|
||||
| `roundtable-recommender` | **功能型**:Step 1→2 之间从候选池里挑推荐,所有部署都用它 | ✅ **必须**(任何环境) |
|
||||
| `roundtable-intent` | **功能型**:Step 1 任务理解,所有部署都用它 | ✅ seeder 自动落地(无需手工打包) |
|
||||
| `roundtable-recommender` | **功能型**:Step 1→2 之间从候选池里挑推荐,所有部署都用它 | ✅ seeder 自动落地(无需手工打包) |
|
||||
| `roundtable-coordinator` | **功能型单例**:Step 2 总控协调,2026-05 起为单例(id 固定) | ✅ seeder 自动落地(无需手工打包) |
|
||||
| `roundtable-intelligence` | 示例研讨席位(情报收集) | ⚠️ **互联网 demo 用**,内网不需要 |
|
||||
| `roundtable-environment` | 示例研讨席位(环境评估) | ⚠️ 同上 |
|
||||
| `roundtable-solution-design` | 示例研讨席位(方案设计) | ⚠️ 同上 |
|
||||
| `roundtable-risk-review` | 示例研讨席位(风险审查) | ⚠️ 同上 |
|
||||
| `roundtable-execution-plan` | 示例研讨席位(执行规划) | ⚠️ 同上 |
|
||||
| `roundtable-summary` | 示例研讨席位(总结陈述) | ⚠️ 同上 |
|
||||
| `roundtable-coordinator-*` | 协调智能体壳,每次会话动态新建 | ❌ **不打包**(运行时生成) |
|
||||
| `roundtable-coordinator-*`(带后缀) | 2026-05 之前每次会话动态新建的临时壳 | ❌ **遗留**(仓库可能仍有几十个旧目录,新版本不再生成;运维按需清理) |
|
||||
|
||||
**关键变化(2026-05)**:三个功能型 agent(intent / recommender / coordinator)现在都由
|
||||
``_roundtable_seed.ensure_roundtable_functional_agents()`` **自动落地**——任何 intent /
|
||||
recommend / multi-agent 路由的入口都会触发,首次请求时缺什么补什么。所以**新部署的
|
||||
机器 `git clone` 后既不需要手工拷目录、也不需要走下文的 `.gitignore` 白名单方案**,
|
||||
SOUL 改动跟着 Python 代码走 git review 即可。
|
||||
|
||||
**关键区分**:
|
||||
- `roundtable-intent` / `roundtable-recommender` 是**圆桌功能本身的一部分**——没有它们,整个 Step 1 + 推荐流程跑不起来,跟客户业务无关
|
||||
@@ -1166,6 +1255,9 @@ client = httpx.AsyncClient(transport=transport, base_url=...)
|
||||
| 推荐路由 | `offline-backend-20260512/backend/app/gateway/routers/recommend.py` |
|
||||
| Step 2 路由 | `offline-backend-20260512/backend/app/gateway/routers/multi_agent.py` |
|
||||
| Step 3 列出/下载/编辑 | `offline-backend-20260512/backend/app/gateway/routers/artifacts.py` |
|
||||
| 草稿/推荐历史路由(§7A) | `offline-backend-20260512/backend/app/gateway/routers/roundtable_drafts.py` |
|
||||
| 草稿/推荐历史持久化 | `offline-backend-20260512/backend/packages/harness/deerflow/persistence/roundtable_drafts/` |
|
||||
| store 接线 | `offline-backend-20260512/backend/app/gateway/deps.py`(`app.state.roundtable_draft_store`) |
|
||||
| 路由注册 | `offline-backend-20260512/backend/app/gateway/app.py` |
|
||||
| 澄清单选/多选 | `offline-backend-20260512/backend/packages/harness/deerflow/tools/builtins/clarification_utils.py` |
|
||||
| 任务理解 Agent | `offline-backend-20260512/backend/.deer-flow/agents/roundtable-intent/` |
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
- **步骤折叠卡与主聊天对齐**:思考过程 / 工具调用展示走 `MessageStepsCard`,**always-show-last-tool + 折叠 "查看其他 N 个步骤"** 的视觉与主聊天 `chats/new` 的 `MessageGroup` 一致。工具图标 / 文案映射在 `lib/step-display.tsx`,新增工具时与 `src/core/i18n/locales/zh-CN.ts` 的 `toolCalls` 字段对齐。
|
||||
- **`<think>` 标签自动提取为「思考过程」**:`lib/reasoning.ts::splitInlineReasoning(text)` 把 `<think>...</think>`(含未闭合的流式中段)抽离成 `reasoning`,正文走 markdown;由 `MessageBubble.tsx::ReasoningBlock` 渲染一个折叠卡。Step 1 / Step 2 气泡和推荐弹窗的 rationale 都走这一套,与主聊天 `Reasoning` 元素的视觉对齐。
|
||||
- **不使用 LangGraph SDK**:所有 API 都是自研的 `apiFetch` + `ReadableStream` SSE 解析(见 `api/intent.ts`、`api/recommend.ts`、`api/multi-agent.ts`)。
|
||||
- **草稿/历史持久化在后端(2026-06)**:草稿不再存浏览器 `localStorage`,改走后端 MySQL(`/api/roundtable-drafts`,按登录用户隔离、跨设备保留)。`api/drafts.ts` 封装 CRUD,`useDraftPersistence` 异步对接、对外接口不变。**推荐弹窗带「会话级推荐历史」**:每个草稿一串历史,重开弹窗先显示上次推荐结果,可「重新分析」重跑(详见 §5.7 / §6.2)。后端实现见 backend doc 的「圆桌草稿持久化」一节。
|
||||
- **不写死模型名**:与 `/page/canvas/ai-writing` 同样的策略 —— 全局选中模型由 `selectedModel` state 维护,首次 `useModels()` 完成后初始化为 `availableModels[0].name`,顶栏「模型」下拉可切换。所有 API 调用统一传 `model: selectedModel || undefined`;后端缺省由 `lead_agent._resolve_model_name()` 回退到 `config.yaml` 的 `models[0]`。**内网部署只需在 `config.yaml` 配自家模型即可,前后端均无需改动**。
|
||||
- **席位区间硬约束**:推荐弹窗要求 **2 ≤ 选中数 ≤ 8**(`MIN_SELECTED` / `MAX_SELECTED`)。
|
||||
- **协调智能体单例(2026-05)**:`COORDINATOR_AGENT_ID = "roundtable-coordinator"` 是固定常量,不再每会话生成新 id。后端 seeder 自动落地,「本次席位列表」改由后端通过 thread 历史 human 消息注入,前端无感。`newCoordinatorName()` 仅作为兼容性壳保留。
|
||||
- **总控编排循环上限**:`MAX_CYCLES = 8`,超出后强制停止并 toast。
|
||||
- **席位派活策略**:**顺序**(不是并行)。旧实现并行触发多路 SSE 会让浏览器卡顿,现已改为顺序。
|
||||
- **调试开关**:`window.__MULTI_AGENT_INIT_TIMING__` 与 `window.__MULTI_AGENT_DEBUG__`(**不是** `__MULTI_AGENT_STREAM_DEBUG__`,文档历史版本有误)。
|
||||
@@ -53,7 +55,8 @@ frontend-web/src/roundtable-planning/
|
||||
│ └── RoundtablePlanningPage.tsx # 主页面:组合 hook + 顶栏/侧栏 + 三步路由(≈1 150 行)
|
||||
├── api/
|
||||
│ ├── intent.ts # Step 1:initIntent、streamIntent
|
||||
│ ├── recommend.ts # 推荐:streamRecommend、filterRecommendCandidates、parseRecommendStreamContent
|
||||
│ ├── recommend.ts # 推荐:streamRecommend、filterRecommendCandidates、parseRecommendStreamContent;**+ 推荐历史 listRecommendHistory / saveRecommendHistory**
|
||||
│ ├── drafts.ts # **草稿后端 CRUD**:listDrafts / getDraft / createDraft / updateDraft / deleteDraft / deriveDraftName(替代旧 localStorage utils/drafts.ts)
|
||||
│ └── multi-agent.ts # Step 2/3:initMultiAgent、streamMultiAgent、listSessionArtifacts、buildArtifactDownloadUrl
|
||||
├── components/
|
||||
│ ├── Avatars.tsx # 所有 SVG 头像 + getAvatar 选择器
|
||||
@@ -72,14 +75,13 @@ frontend-web/src/roundtable-planning/
|
||||
│ ├── useAutoScroll.ts # 滚动跟随 + 用户上滑暂停跟随
|
||||
│ ├── useStep1Intent.ts # Step 1 状态机:init、send、stream、abort、INTENT_READY 同步
|
||||
│ ├── useStep2Orchestration.ts # Step 2 状态机:initMultiAgent + 编排循环 + 对话流管理 + Persona
|
||||
│ └── useDraftPersistence.ts # 草稿:自动保存(前进切换)/手动保存/加载/重命名/删除
|
||||
│ └── useDraftPersistence.ts # 草稿(后端版):异步走 api/drafts;自动保存(前进切换)/手动保存/加载/重命名/删除/ensureDraft
|
||||
├── lib/
|
||||
│ ├── clarification.ts # resolveAllowMultiple(单选/多选解析),与主聊天 ClarificationCard 对齐
|
||||
│ ├── reasoning.ts # splitInlineReasoning:从模型流式文本里提取 `<think>...</think>` 思考过程
|
||||
│ ├── roundtable-constants.ts # 类型(RoleEntry / SelectedAgent) + 常量 + 纯工具函数(buildRoleTemplates / splitIntentReadyBlock 等)
|
||||
│ └── step-display.tsx # Step 2 ChainOfThought 折叠卡图标 + 文案 + 子节点渲染
|
||||
├── utils/
|
||||
│ └── drafts.ts # localStorage 草稿存档(list / upsert / get / delete / rename / deriveName)
|
||||
├── utils/ # (旧 drafts.ts 已删除 —— 草稿改走后端 api/drafts.ts)
|
||||
└── styles/
|
||||
└── roundtable-planning.css # 页面主题变量(浅红品牌色 + 深色覆盖)
|
||||
```
|
||||
@@ -182,6 +184,7 @@ hooks/useDraftPersistence → utils/drafts + step1/step2 的 Snapshot 类型
|
||||
- `signal`:必填(页面通过 `intentAborterRef` 控制暂停 / 切步取消)
|
||||
- `onTextDelta(text, messageId)`:每个 AI 文本增量
|
||||
- `onPhaseChange(phase, toolName?)`:`connecting → connected → streaming|tool_calling`
|
||||
- **`onClarification(clarification, index)`(2026-06)**:每解析到一条 `ask_clarification` 工具结果帧就回调一次,让前端**实时**逐个渲染澄清卡。任务理解智能体**一轮可能问多个问题**,这是「实时接收显示协助过程」的关键入口。
|
||||
|
||||
**`StreamIntentResult`**:
|
||||
|
||||
@@ -190,14 +193,16 @@ hooks/useDraftPersistence → utils/drafts + step1/step2 的 Snapshot 类型
|
||||
| `status` | `"asking" \| "clarification" \| "done" \| "error"` | 终态分支 |
|
||||
| `content` | `string` | 完整 AI 文本(含 `[INTENT_READY]` 块) |
|
||||
| `summary` | `IntentSummary \| null` | 仅 `done` 有;前端 fallback 也会从 `content` 里用 `splitIntentReadyBlock` 解 |
|
||||
| `clarification` | `ClarificationPayload \| null` | 仅 `clarification` 有 |
|
||||
| `clarification` | `ClarificationPayload \| null` | **第一个**澄清(向后兼容字段) |
|
||||
| `clarifications` | `ClarificationPayload[]` | **本轮全部澄清问题**(2026-06)。来源是流式 `type:"tool"` 帧而非终态帧——**终态帧只带第 1 个**,多问题必须靠它。每条带 `id`(= `tool_call_id`)供前端按题维护选择。 |
|
||||
|
||||
**SSE 解析要点**:
|
||||
|
||||
- `event: metadata` → phase `connected`
|
||||
- `event: messages` + `extractAiTextDelta` → `onTextDelta`
|
||||
- `event: messages` + `type:"tool"` 且 `name==="ask_clarification"` → `extractClarificationToolMessage` 解出完整澄清(options 已是 `{id,label}`),按 `tool_call_id` 去重后 `onClarification` 实时回调并收进 `result.clarifications`
|
||||
- tool call 帧(`tool_calls` / `tool_call_chunks` 非空)→ phase `tool_calling`(含 `ask_clarification` 工具名)
|
||||
- 终态帧识别:`isFinalIntentFrame`(必须有 `status` + `content`)
|
||||
- 终态帧识别:`isFinalIntentFrame`(必须有 `status` + `content`);`status==="clarification"` 且**未**收到任何流式 tool 澄清帧时,才用终态帧字段兜底合成单条澄清
|
||||
|
||||
**Abort 行为**:
|
||||
|
||||
@@ -341,7 +346,12 @@ React 18 StrictMode 开发环境下,effect 会 mount → cleanup → mount 两
|
||||
| `agentConfigs` | `Map<seatId, {model, weight, prompt, temp}>` Persona 覆盖;下一轮该席位的派活会用此 model |
|
||||
| `isUpperPanelCollapsed` | 是否折叠圆桌可视化 + 调控台,给对话区让出垂直空间 |
|
||||
|
||||
**协调智能体命名**:`roundtable-coordinator-${Date.now().toString(36)}`,每次 Step 2 会话新建。后端把这类壳 agent 留在 DB 中,因此 `filterRecommendCandidates` 默认过滤掉。
|
||||
**协调智能体命名(2026-05 改造)**:现在是**固定单例 id** `roundtable-coordinator`(见 `lib/roundtable-constants.ts::COORDINATOR_AGENT_ID`)。`newCoordinatorName()` 函数为兼容性保留,内部直接返回这个常量字符串。后端 `ensure_roundtable_functional_agents()` 缺失自动落地,不再每次新建。`filterRecommendCandidates` 在 `EXCLUDED_AGENT_IDS` 集合里同时排除:
|
||||
|
||||
- `roundtable-coordinator`(新版单例 id,永远过滤);
|
||||
- `roundtable-coordinator-*` 前缀(历史残留,管理员清理之前先在 UI 隐藏)。
|
||||
|
||||
> 历史草稿兼容性:用户加载 2026-05 前保存的草稿时,存储的 `coordinatorName` 仍是 `roundtable-coordinator-<ts36>` 形式。只要那个旧 agent 目录还在磁盘上(即运维没手动删过),加载后继续在 Step 2 干活就能正常工作;如果旧 agent 被清理掉了,需要让用户「重新起草」从头跑一遍 Step 1 → Step 2。
|
||||
|
||||
### 5.4 编排循环 `runOrchestration(seedMessage, ids, coord)`
|
||||
|
||||
@@ -424,19 +434,29 @@ isOrchestrating = false
|
||||
- **禁用态**:`availableModels.length === 0` 或 `modelsLoading` → `disabled`,placeholder 显示「加载中…」或「未配置模型」
|
||||
- **可改换为 Radix Select**:当前用原生 `<select>` 与 Persona 抽屉保持一致;如需统一样式可改为 `@/components/ui/select`,行为不变
|
||||
|
||||
### 5.7 草稿持久化(`utils/drafts.ts`)
|
||||
### 5.7 草稿持久化(`api/drafts.ts` + 后端 MySQL,2026-06 改造)
|
||||
|
||||
- Key:`roundtable-planning:drafts:v1`(`localStorage`)
|
||||
- 草稿快照含:`step1.{intentThreadId, intentReady, interactiveMessages, timelineEntries}`、`step2.{threadIds, coordinatorName, step2RoundtableDialogues, lastLeaderContent, hasConsensus, consensusPercentage, budgetLimit}`、`furthestStep`
|
||||
- `deriveDraftName({intentReady, interactiveMessages})`:优先用 `intentReady.objective`,否则取第一个 user 消息,否则用 `未命名草稿 <时间>`,统一截断到 40 字
|
||||
- **自动保存策略**:仅在「前进」步骤切换时保存(1→2、2→3),后退不触发,避免覆盖 `furthestStep`
|
||||
- **手动保存**:顶栏 + Step 1 底部「保存草稿」按钮均调用 `handleManualSave`
|
||||
- **加载草稿**:`handleLoadDraft`
|
||||
- 中断所有 in-flight(`abortAllInFlight + stopIntentStream`)
|
||||
- **先**置 `loadedFromDraftRef.current = true`,再 `setCurrentStep(draft.furthestStep)`,避免 step1/step2 init effect 重新调用 init 把恢复的状态打掉
|
||||
- `step1InitGenRef` 自增,淘汰可能晚归的旧 init
|
||||
- `step2InitRef.current = draft.furthestStep >= 2`:曾经走到 Step 2 才标记已 init
|
||||
- 角色面板基线状态:被恢复时全部置「在线」,否则 init 流程逐个置「在线」
|
||||
> **重大变更**:草稿从浏览器 `localStorage` 迁到**后端 MySQL**,按登录用户隔离、跨设备/会话保留。旧 `utils/drafts.ts` 已删除;`useDraftPersistence` 仍保持对外接口不变(列表项含 `name`,由后端 `title` 映射而来),主页面无需改动。后端表/路由见 backend doc「圆桌草稿持久化」。
|
||||
|
||||
- **API 客户端 `api/drafts.ts`**:`listDrafts()`(轻量元数据)/ `getDraft(id)`(全量 step1+step2)/ `createDraft` / `updateDraft`(partial)/ `deleteDraft` / `deriveDraftName`。snake_case↔camelCase 映射在这一层收口(后端 `furthest_step/created_at/updated_at` ↔ 前端 `furthestStep/...`)。
|
||||
- **快照形状**:`DraftStep1Snapshot.{intentThreadId, intentReady, interactiveMessages, timelineEntries}`、`DraftStep2Snapshot.{selectedAgents, threadIds, coordinatorName, step2RoundtableDialogues, lastLeaderContent, hasConsensus, consensusPercentage, budgetLimit, seatStubMessages}`;以 JSON 整存进后端 `step1`/`step2`(`PortableLongText`/LONGTEXT,避免大对话超 64KB)。
|
||||
- **`selectedAgents`(2026-06 修复)**:本次研讨实际选中的席位。**不存的话加载草稿后 Step 2/3 左侧「参与角色」会回退到 `DEFAULT_SELECTED_AGENTS`(默认 6 个)而非当时真正选的那几个** —— `roleTemplates`/`agentNameToRole` 都由 `selectedAgents` 派生。`useStep2Orchestration.hydrateFromDraft` 在该字段非空时 `setSelectedAgents`,老草稿(无此字段)保持当前值不强行覆盖。
|
||||
- `deriveDraftName({intentReady, interactiveMessages})`:优先 `intentReady.objective`,否则第一个 user 消息,否则 `未命名草稿 <时间>`,截断 40 字。**仅在 create 时写一次**(见下方 bug 修复)。
|
||||
- **列表加载**:挂载时 `useEffect` 调 `listDrafts()`;增删改后 `refreshList()` 重拉。
|
||||
- **自动保存策略**:仅在「前进」步骤切换时保存(1→2、2→3),后退不触发。
|
||||
- **手动保存 / `ensureDraft`**:`handleManualSave` 走同一条保存队列;`ensureDraft(furthestStep?)` 幂等保证后端有一条对应草稿并返回 id(**推荐弹窗打开前调用**,让推荐历史有 `draft_id` 归属)。
|
||||
- **加载草稿 `handleLoadDraft`**:
|
||||
- 走 `getDraft(id)` **实时拉服务端最新全量**(不再读内存里可能过期的列表快照);404 → toast「草稿已不存在」并刷新列表。
|
||||
- **先**置 `loadedFromDraftRef.current = true`,再 `setCurrentStep(draft.furthestStep)`(顺序不能反)。
|
||||
- `setStep2InitGate(draft.furthestStep >= 2)`:曾走到 Step 2 才跳过自动 init。
|
||||
- 角色面板基线:被恢复时全部「在线」,否则 init 流程逐个「在线」。
|
||||
|
||||
**本次随手修复的 4 个旧 localStorage 版 bug**(对接后端时一并解决):
|
||||
|
||||
1. **自动保存覆盖手动重命名** —— 现在所有 `updateDraft` 一律**不带 title**;标题只由 create(派生)与显式「重命名」改写。
|
||||
2. **快速连续前进(1→2→3)产生重复草稿** —— 所有保存经一条**串行队列**(`saveQueueRef`)+ 同步镜像 `currentDraftIdRef`,create 完成即写 id,后续保存读到 id 走 update 而非再 create。
|
||||
3. **加载读到内存旧列表快照** —— 改为 `getDraft(id)` 实时拉。
|
||||
4. **localStorage 配额静默写失败 / 数据丢失** —— 迁后端后不复存在。
|
||||
|
||||
---
|
||||
|
||||
@@ -444,25 +464,39 @@ isOrchestrating = false
|
||||
|
||||
### 6.1 `IntentClarificationCard`
|
||||
|
||||
- Props:`payload`(`ClarificationPayload`)、`selection`、`onSubmit(overrideSelection?)`、`disabled`、`submitting`、`fallbackContent`
|
||||
- Props:`payload`(`ClarificationPayload`)、`selection`、`onSubmit(overrideSelection?)`、`disabled`、`submitting`、`fallbackContent`、**`deferSubmit?`(2026-06)**
|
||||
- **单选**(默认 `allowMultiple === false`):`resolveAllowMultiple` 返回 false → 点击选项即 `onSubmit({selectedIds:[id], custom: ""})`,UI 不显示「发送回答」按钮(除非 `allowCustom`)
|
||||
- **多选**:勾选多个 + 输入补充,再点「发送回答」;答案格式见 `formatIntentClarificationAnswer`:
|
||||
- 仅选项 → `我选择:A、B`
|
||||
- 仅自定义 → 直接发自定义文本
|
||||
- 同时存在 → `我选择:A、B;补充:…`
|
||||
- 展示条件:`isPendingClarification && !intentReady && !parts.summary && pendingIntentClarificationMsgId === msg.id`(已出现 `[INTENT_READY]` 则隐藏可操作卡片)
|
||||
- **单问题 vs 多问题的判断(2026-06)**:`Step1Message` 按 `clarifications.length` 分流,**默认单选**(后端 `allow_multiple` 缺省 false,`resolveAllowMultiple` 兜底):
|
||||
- **单问题(最常见)**:`deferSubmit={false}`,沿用原交互 —— 单选**点击选项即发送**;多选 / 允许自定义则走卡片自带的「发送回答」按钮。**不**显示合并按钮。
|
||||
- **多问题**:`deferSubmit={true}` —— 连单选点击也只**记录**选择(不立即发送),卡片自身隐藏按钮;父组件在卡片下方渲染**一个**「发送全部回答」按钮,统一提交。
|
||||
- 该判断纯在前端(不动工具/后端):依据 `clarifications.length` + `allow_multiple`,后端 `ask_clarification` 本就默认单选。
|
||||
- **合并提交逻辑**:`submitIntentClarifications(msgId, clarifications, overrideByKey?)` 逐题取选择、格式化、拼成一条消息(多题带 `1. <问题>\n答:<答案>` 编号;单题直接发答案;至少答一题才发)。`overrideByKey` 供「单题单选点击即发送」用——此时选择还没写进 state map(setState 异步),把即时选择按 `clarificationKey` 传进去直接用。
|
||||
- **逐题选择隔离**:选择 Map 改为 `Map<string, IntentClarificationSelection>`,key 由 `clarificationKey(msgId, clar.id, index)` 生成(`clar.id` = `tool_call_id`,缺省退化为 `idx-N`)。
|
||||
- 展示条件:`isAgent && clarifications.length>0 && !intentReady && !parts.summary`;**流式期也展示**(卡片 `disabled`,只读,体现「协助过程」实时出现),仅当终态且 `pendingIntentClarificationMsgId === msg.id && !streaming` 时才可交互。出现 `[INTENT_READY]` / summary 后隐藏。
|
||||
- **步骤链强化**:`onClarification` 同时往 `msg.steps` 追加一条 `追问 N:<问题>`,让 `MessageStepsCard` 把每个 `ask_clarification` 调用显示成独立步骤。
|
||||
|
||||
### 6.2 `RecommendAgentsDialog`
|
||||
|
||||
- 打开时管线:`listAgents() → filterRecommendCandidates() → streamRecommend()`
|
||||
- **新增 `draftId` prop(2026-06)**:本次推荐归属的草稿/会话 id。由主页面在打开弹窗前 `await drafts.ensureDraft(1)` 拿到并传入(见 §6.6)。`null` 时退化为「直接推荐、不存历史」的旧行为。
|
||||
- 打开时管线(`start(forceFresh=false)`):`listAgents() → filterRecommendCandidates()` → **若 `draftId` 有历史 → `listRecommendHistory()` 取最近一次直接展示(不重跑模型)**;否则 `streamRecommend()` 跑新推荐。
|
||||
- 阶段 UI(`InternalState.phase`):
|
||||
- `idle` → `loading_agents` → `recommending`(顶部「模型生成内容」区流式;下方推荐卡 streaming=true)→ `ready` / `fallback` / `error`
|
||||
- `idle` → `loading_agents` → **`loading_history`** → **`history`**(展示上次推荐,可直接进入研讨或「重新分析」)
|
||||
- 或 `loading_agents` → `recommending`(顶部「模型生成内容」流式;推荐卡 streaming=true)→ `ready` / `fallback` / `error`
|
||||
- **推荐历史(会话级)**:
|
||||
- 打开时若该 `draftId` 有历史,进入 `history` 态:蓝色提示条标注上次推荐时间,picks 默认勾选、rationale 回显,**不**自动重跑模型。
|
||||
- 「**重新分析**」按钮(`history` 态显示该文案,其它态为「重新推荐」)→ `start(true)` 强制跑新推荐,跳过历史。
|
||||
- 每次**新推荐**完成(`ready`/`fallback`)后 `saveRecommendHistory(draftId, {objective,status,model,rationale,picks,candidates})` best-effort 追加一条(失败仅告警不阻断)。
|
||||
- `history`/`fallback`/`ready` 三态都允许 `onConfirm`(用户可直接采纳历史 picks)。
|
||||
- **布局分两段**:
|
||||
- **顶部「模型生成内容」**:`RecommenderOutput` —— 状态行(`spinner + 调度推荐 / 已连接 / 正在生成`)+ `MessageStepsCard` 步骤卡 + `ReasoningBlock`(从 `<think>` 拆出来)+ markdown rationale + 末尾 `StreamingCursor`。视觉与 Step 1/Step 2 气泡的内容区一致,参考主聊天 `chats/new`。
|
||||
- **底部「推荐参会智能体」**:候选卡片(`AgentCard`),分「推荐参会 / 其他候选」两组。
|
||||
- 选择约束:`2 ≤ selected ≤ 8`;底部实时显示「至少再选 N 个」「已选 X / 8」
|
||||
- 失败兜底:候选为空 → error;status==="asking" 或 picks 不足 2 → `fallback`,自动用 `FALLBACK_AGENT_IDS` 与候选池交集勾选
|
||||
- 反竞态:内部 `generationRef`,每次 `runRecommendation` 自增,所有 setState 都校验 `myGen === generationRef.current`,避免「重新推荐」时旧 stream 写脏 state
|
||||
- 反竞态:内部 `generationRef`,每次 `start()` 自增,所有 setState(含历史读取/流式回调)都校验 `myGen === generationRef.current`,避免「重新分析」时旧 stream / 旧历史写脏 state
|
||||
- `onConfirm(agentIds)` → 父组件 `handleConfirmAgents`:复位 `step2InitRef` 并 `setCurrentStep(2)`,触发 Step 2 init
|
||||
|
||||
### 6.3 `HighFidelityReport`(Step 3)
|
||||
@@ -479,6 +513,7 @@ isOrchestrating = false
|
||||
- 各席位最终交付(中段折叠区)数据源:父组件传入的 `seatDeliveries`,按发送者去重(后到的覆盖前者)
|
||||
- 「重新起草」→ 父组件 `handleStartNewTask`(清空并 `runStep1Init`)
|
||||
- 「打印 / 另存 PDF」→ `window.print()`,浏览器原生流程
|
||||
- **Step 3 不显示左侧栏(2026-06)**:`LeftSidebar` 在 `currentStep === 3` 时 `return null`(原「参与与结论贡献」列已移除),右侧栏在 Step !== 1 时本就 `return null`,因此中间 `middle-viewport`(`flex-1`)会自适应撑满整行,报告区获得最大宽度。
|
||||
|
||||
### 6.4 `ArtifactPreviewModal`
|
||||
|
||||
@@ -607,7 +642,7 @@ interface StreamMultiAgentResult {
|
||||
| `FALLBACK_AGENT_IDS` | 6 内置 roundtable-* | RecommendAgentsDialog |
|
||||
| `BUILTIN_AGENT_META` | 6 内置头像/中文名 | RoundtablePlanningPage |
|
||||
| `FALLBACK_AVATAR_TYPES` | `[blue, purple, emerald, amber, pink]` | RoundtablePlanningPage |
|
||||
| `STORAGE_KEY` | `"roundtable-planning:drafts:v1"` | drafts.ts |
|
||||
| ~~`STORAGE_KEY`~~ | 已废弃 —— 草稿改存后端 `/api/roundtable-drafts`,不再用 localStorage | (旧 utils/drafts.ts,已删除) |
|
||||
| `INTENT_READY_RE` | `/\[INTENT_READY\]\s*```json\s*(\{[\s\S]*?\})\s*```/` | RoundtablePlanningPage |
|
||||
| `RECOMMEND_READY_MARKER` | `"[RECOMMEND_READY]"` | recommend.ts |
|
||||
| `EXCLUDED_AGENT_IDS` / 前缀 | `roundtable-intent`、`roundtable-recommender`、`roundtable-coordinator-*` | recommend.ts |
|
||||
@@ -693,8 +728,8 @@ window.__MULTI_AGENT_DEBUG__ = true; // stream 帧计数(默认开)
|
||||
|
||||
1. **不要在 Panel 组件里写 fetch / setState 业务流程** —— Panel 只渲染,事件透传到 hook。
|
||||
2. **hook 之间不要互相 import** —— 跨 hook 的数据通过主页面的 ref / callback 桥接(参考 `buildInitialIntent` 与 `loadedFromDraftRef` 的实现)。
|
||||
3. **草稿 snapshot 形状**(Step 1 的 `Step1Snapshot` / Step 2 的 `Step2Snapshot`)与 `utils/drafts.ts` 的 `DraftStep{1,2}Snapshot` 是同一份语义,改字段时两边都要改。
|
||||
4. **lint/typecheck**:重构后 `pnpm typecheck` 与 `pnpm build` 必须保持与重构前同样的 0 个新增错误(预存量 50 个 pre-existing 错误来自其它模块如 `next/link` shim,与本特性无关)。
|
||||
3. **草稿 snapshot 形状**(Step 1 的 `Step1Snapshot` / Step 2 的 `Step2Snapshot`)与 `api/drafts.ts` 的 `DraftStep{1,2}Snapshot` 是同一份语义,改字段时两边都要改;后端以 JSON 整存,不强约束嵌套字段。
|
||||
4. **lint/typecheck**:重构后 `pnpm typecheck` 与 `pnpm build` 必须保持 0 个新增错误(预存量错误来自其它无关模块如 `strategy-components` / `next/link` shim,与本特性无关)。
|
||||
|
||||
### 12.7 文档协同
|
||||
|
||||
@@ -725,7 +760,8 @@ window.__MULTI_AGENT_DEBUG__ = true; // stream 帧计数(默认开)
|
||||
| 常量/工具函数 | `frontend-web/src/roundtable-planning/lib/roundtable-constants.ts` |
|
||||
| ChainOfThought 渲染 | `frontend-web/src/roundtable-planning/lib/step-display.tsx` |
|
||||
| Step 1 API | `frontend-web/src/roundtable-planning/api/intent.ts` |
|
||||
| 推荐 API | `frontend-web/src/roundtable-planning/api/recommend.ts` |
|
||||
| 推荐 API(含推荐历史) | `frontend-web/src/roundtable-planning/api/recommend.ts` |
|
||||
| 草稿 API(后端 CRUD) | `frontend-web/src/roundtable-planning/api/drafts.ts` |
|
||||
| Step 2/3 API | `frontend-web/src/roundtable-planning/api/multi-agent.ts` |
|
||||
| 澄清卡片 | `frontend-web/src/roundtable-planning/components/IntentClarificationCard.tsx` |
|
||||
| 推荐弹窗 | `frontend-web/src/roundtable-planning/components/RecommendAgentsDialog.tsx` |
|
||||
@@ -734,7 +770,7 @@ window.__MULTI_AGENT_DEBUG__ = true; // stream 帧计数(默认开)
|
||||
| 回底按钮 | `frontend-web/src/roundtable-planning/components/ScrollToBottomButton.tsx` |
|
||||
| 滚动跟随 | `frontend-web/src/roundtable-planning/hooks/useAutoScroll.ts` |
|
||||
| 澄清单选逻辑 | `frontend-web/src/roundtable-planning/lib/clarification.ts` |
|
||||
| 草稿存档 | `frontend-web/src/roundtable-planning/utils/drafts.ts` |
|
||||
| 后端草稿/历史路由 | `offline-backend-20260512/backend/app/gateway/routers/roundtable_drafts.py` |
|
||||
| 路由 | `frontend-web/src/pages/WorkspaceRoutes.tsx` |
|
||||
| 样式 | `frontend-web/src/roundtable-planning/styles/roundtable-planning.css` |
|
||||
| 主聊天澄清参考 | `frontend-web/src/components/workspace/messages/message-list.tsx` |
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,580 @@
|
||||
# 深蓝色 UI 规范 · 00 基础(色彩 / 字体 / 阴影 / 圆角 / 间距 / 分割线)
|
||||
|
||||
> 本文件是《深蓝色 UI 规范》拆分后的**基础篇(§1–§7)**,是全站设计令牌的唯一来源。
|
||||
> 其余分册见同目录 `README.md`;可直接 import 的变量见 `tokens.css`。
|
||||
> 跨章节 `§N` 编号全局唯一,所属文件见 README 的「§ 索引」。
|
||||
|
||||
**本篇目录(§1–§7)**:`1` 色彩 · `2` 字体 · `3` 阴影 · `4` 圆角 · `5` 按钮 · `6` 分割线 · `7` 间距
|
||||
|
||||
---
|
||||
|
||||
## 1. 色彩
|
||||
|
||||
### 1.1 标准色
|
||||
|
||||
色彩体系由四个色系构成,每个色系分主色与辅色两组,每组按明度从浅到深编号(01 最浅,数字越大越深)。
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.1 色系总览
|
||||
|
||||
| 色系 | 用途定位 | 代码前缀 |
|
||||
|------|----------|----------|
|
||||
| 渐红系 | 警示、错误、强调操作 | ZS-001 |
|
||||
| 渐蓝系 | 信息、链接、次级操作 | ZS-002 |
|
||||
| 渐青系 | 成功、在线状态、数据高亮 | ZS-003 |
|
||||
| 深蓝系 | 页面背景、容器、导航底色 | ZS-004 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.2 渐红系(ZS-001)
|
||||
|
||||
用于错误提示、危险操作、重要告警。
|
||||
|
||||
| 编号 | 色值 | 说明 |
|
||||
|------|------|------|
|
||||
| ZS-001-01 | `#FFF1F0` | 极浅红,错误背景底色 |
|
||||
| ZS-001-02 | `#FFCCC7` | 浅红,输入框错误边框 |
|
||||
| ZS-001-03 | `#FFA39E` | — |
|
||||
| ZS-001-04 | `#FF7875` | — |
|
||||
| ZS-001-05 | `#FF4D4F` | 标准红,Tag / Badge |
|
||||
| ZS-001-06 | `#F5222D` | 主色红,按钮 / 图标 |
|
||||
| ZS-001-07 | `#CF1322` | 深红,Hover 状态 |
|
||||
| ZS-001-08 | `#A8071A` | 深红,Active / Press |
|
||||
| ZS-001-09 | `#820014` | 极深红 |
|
||||
| ZS-001-10 | `#5C0011` | 最深红 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.3 渐蓝系(ZS-002)
|
||||
|
||||
用于信息提示、链接、次级按钮。
|
||||
|
||||
| 编号 | 色值 | 说明 |
|
||||
|------|------|------|
|
||||
| ZS-002-01 | `#E6F4FF` | 极浅蓝,信息背景底色 |
|
||||
| ZS-002-02 | `#BAE0FF` | 浅蓝 |
|
||||
| ZS-002-03 | `#91CAFF` | — |
|
||||
| ZS-002-04 | `#69B1FF` | — |
|
||||
| ZS-002-05 | `#4096FF` | 标准蓝,链接 / 信息 Tag |
|
||||
| ZS-002-06 | `#1677FF` | 主色蓝,主操作按钮 |
|
||||
| ZS-002-07 | `#0958D9` | 深蓝,Hover |
|
||||
| ZS-002-08 | `#003EB3` | 深蓝,Active |
|
||||
| ZS-002-09 | `#002C8C` | 极深蓝 |
|
||||
| ZS-002-10 | `#001D6C` | 最深蓝 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.4 渐青系(ZS-003)
|
||||
|
||||
用于成功状态、在线标识、数据图表高亮。
|
||||
|
||||
| 编号 | 色值 | 说明 |
|
||||
|------|------|------|
|
||||
| ZS-003-01 | `#E6FFFB` | 极浅青,成功背景 |
|
||||
| ZS-003-02 | `#B5F5EC` | 浅青 |
|
||||
| ZS-003-03 | `#87E8DE` | — |
|
||||
| ZS-003-04 | `#5CDBD3` | — |
|
||||
| ZS-003-05 | `#36CFC9` | 标准青,成功 Tag |
|
||||
| ZS-003-06 | `#13C2C2` | 主色青,在线点 / 图标 |
|
||||
| ZS-003-07 | `#08979C` | 深青,Hover |
|
||||
| ZS-003-08 | `#006D75` | 深青,Active |
|
||||
| ZS-003-09 | `#00474F` | 极深青 |
|
||||
| ZS-003-10 | `#002329` | 最深青 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.5 深蓝系(ZS-004)
|
||||
|
||||
用于页面背景、导航栏、侧边栏、卡片容器。这是深蓝主题的核心色系。
|
||||
|
||||
| 编号 | 色值 | 说明 |
|
||||
|------|------|------|
|
||||
| ZS-004-01 | `#E8EDF5` | 极浅,分割线 / 禁用底色 |
|
||||
| ZS-004-02 | `#C5CFE0` | 浅,边框 |
|
||||
| ZS-004-03 | `#9BADC8` | — |
|
||||
| ZS-004-04 | `#6E88B0` | — |
|
||||
| ZS-004-05 | `#4A6491` | 中深蓝,次级文字 |
|
||||
| ZS-004-06 | `#2D4473` | 深蓝,卡片容器背景 |
|
||||
| ZS-004-07 | `#1A2F5A` | 深蓝,侧边栏背景 |
|
||||
| ZS-004-08 | `#122347` | 深蓝,导航栏背景 |
|
||||
| ZS-004-09 | `#0C1836` | 极深蓝,页面背景 |
|
||||
| ZS-004-10 | `#060E24` | 最深,全局底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.6 功能色(主色 / 字体色 / 辅色 / 背景色)
|
||||
|
||||
从标准色系中提取,用于具体 UI 角色指定。
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 主色(Primary) | `#1677FF` | ZS-002-06 |
|
||||
| 主色 Hover | `#0958D9` | ZS-002-07 |
|
||||
| 主色 Active | `#003EB3` | ZS-002-08 |
|
||||
| 正常字体色 | `#C5CFE0` | ZS-004-02 |
|
||||
| 次级字体色 | `#6E88B0` | ZS-004-04 |
|
||||
| 禁用字体色 | `#4A6491` | ZS-004-05 |
|
||||
| 辅色(Accent) | `#13C2C2` | ZS-003-06 |
|
||||
| 页面背景色 | `#0C1836` | ZS-004-09 |
|
||||
| 容器背景色 | `#1A2F5A` | ZS-004-07 |
|
||||
| 白色 | `#FFFFFF` | — |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.7 小面积装饰色
|
||||
|
||||
用于图标点缀、徽标、少量强调,不用于大面积背景。
|
||||
|
||||
| 色值 | 说明 |
|
||||
|------|------|
|
||||
| `#6388FF` | 紫蓝,图标装饰 |
|
||||
| `#F5222D` | 红色,危险徽标 |
|
||||
| `#12306C` | 深蓝,品牌点缀 |
|
||||
| `#478880` | 青绿,辅助点缀 |
|
||||
| `#950404` | 深红,重要告警点 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.8 图表配色
|
||||
|
||||
**通用图表色序**(面积较大,如柱状图、折线图、饼图):
|
||||
|
||||
| 序号 | 色值 |
|
||||
|------|------|
|
||||
| 1 | `#1677FF` |
|
||||
| 2 | `#13C2C2` |
|
||||
| 3 | `#4096FF` |
|
||||
| 4 | `#36CFC9` |
|
||||
| 5 | `#69B1FF` |
|
||||
| 6 | `#5CDBD3` |
|
||||
| 7 | `#91CAFF` |
|
||||
| 8 | `#87E8DE` |
|
||||
|
||||
**小面积图表色序**(面积较小,如散点、小徽章、迷你图):
|
||||
|
||||
| 序号 | 色值 |
|
||||
|------|------|
|
||||
| 1 | `#4096FF` |
|
||||
| 2 | `#36CFC9` |
|
||||
| 3 | `#FF4D4F` |
|
||||
| 4 | `#FFA39E` |
|
||||
| 5 | `#6388FF` |
|
||||
| 6 | `#478880` |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.9 功能语义色(Functional / Status)
|
||||
|
||||
承载「成功 / 警告 / 错误 / 信息 / 处理中」语义。其中**错误红、信息蓝、处理中青**直接复用标准色;**成功绿、警告橙**为标准色系之外的补充色(深色背景下 ZS-003 青偏冷、且无现成橙),在此正式收录。全站语义场景一律引用本表,不再各处自定义。
|
||||
|
||||
| 语义 | 色值 | 来源 | 典型用途 |
|
||||
|------|------|------|----------|
|
||||
| 成功 / 已完成 | `#52C41A` | 补充色(绿) | 成功提示、完成状态、通过校验 |
|
||||
| 警告 / 进行中 | `#FAAD14` | 补充色(橙) | 警告提示、进行中、需注意 |
|
||||
| 错误 / 失败 | `#F5222D` | ZS-001-06 | 错误提示、删除、失败状态 |
|
||||
| 信息 / 默认 | `#1677FF` | ZS-002-06 | 信息提示、主操作、链接 |
|
||||
| 处理中 / 等待 | `#13C2C2` | ZS-003-06 | 处理中、排队、等待反馈 |
|
||||
|
||||
> 浅底变体(Message / Alert / Tag 底色):前景色取 16% 透明度,如成功底 `rgba(82,196,26,0.16)`、警告底 `rgba(250,173,20,0.16)`。
|
||||
> CSS Token 见 `tokens.css` 的 `--func-success / --func-warning / --func-error / --func-info / --func-processing`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 字体
|
||||
|
||||
### 2.1 全局样式 - 字体
|
||||
|
||||
---
|
||||
|
||||
#### 2.1.1 大屏页面字体规范
|
||||
|
||||
##### 中文字体:Noto Sans S Chinese
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 24px Bold | 一级标题 |
|
||||
| 24px Medium | 次要一级标题 |
|
||||
| 22px Medium | 二级标题 |
|
||||
| 22px Regular | 正文 |
|
||||
| 20px Regular | 排版空间有限的正文 |
|
||||
|
||||
##### 数字字体:D-DIN
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 32px Bold | 重要数据展示 |
|
||||
| 32px Regular | 普通数据展示 |
|
||||
| 26px Bold | 常规数据展示 |
|
||||
| 26px Regular | 常规数据展示 |
|
||||
|
||||
##### 特殊数字:DS-Digital
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 50px Bold | 大屏主数据展示 |
|
||||
|
||||
##### 表格字体:Arial
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 20px Regular | 表格横纵轴数字 |
|
||||
|
||||
---
|
||||
|
||||
#### 2.1.2 后台系统字体规范
|
||||
|
||||
##### 中文字体:Noto Sans S Chinese
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 18px Bold | 导航、一级标题 |
|
||||
| 18px Medium | 次要一级标题 |
|
||||
| 16px Bold | 二级标题 |
|
||||
| 16px Medium | 次要二级标题 |
|
||||
| 16px Regular | 正文、按钮内部文字等 |
|
||||
| 16px Light | 次要正文 |
|
||||
|
||||
##### 数字字体:D-DIN
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 26px Bold | 重要数据展示 |
|
||||
| 26px Regular | 普通数据展示 |
|
||||
| 24px Bold | 常规数据展示(小) |
|
||||
| 24px Regular | 常规数据展示(小) |
|
||||
|
||||
##### LOGO 字体:DOUYUFont
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 20px 文字样式 | 页面顶部系统名称 |
|
||||
|
||||
##### 表格数字:Arial
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 16px Regular | 表格横纵轴数字 |
|
||||
| 14px Regular | 表格横轴数字(空间有限) |
|
||||
|
||||
---
|
||||
|
||||
## 3. 阴影
|
||||
|
||||
### 3.1 容器与卡片配色
|
||||
|
||||
阴影组通过深浅层级叠加形成空间感:外层容器最深,内层卡片次之,边框与高亮文字使用主色或字体色。
|
||||
|
||||
#### 3.1.1 外层容器
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 页面 / 最外层背景 | `#060E24` | ZS-004-10 |
|
||||
| 分栏容器背景 | `#0C1836` | ZS-004-09 |
|
||||
|
||||
#### 3.1.2 卡片(标题 + 操作)
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 卡片背景 | `#122347` | ZS-004-08 |
|
||||
| 卡片边框 | `#1A2F5A` | ZS-004-07 |
|
||||
| 卡片阴影(外发光) | `rgba(22, 119, 255, 0.12)` | 基于 ZS-002-06 主色蓝 12% 透明度 |
|
||||
| 标题文字(16px Bold) | `#C5CFE0` | ZS-004-02(正常字体色) |
|
||||
| 操作按钮文字 | `#4096FF` | ZS-002-05(标准蓝,链接) |
|
||||
| 次级操作图标(✏️ / ⋯) | `#6E88B0` | ZS-004-04(次级字体色) |
|
||||
|
||||
#### 3.1.3 卡片新增(占位卡片)
|
||||
|
||||
虚线描边的"新增入口"卡片,用于引导用户添加内容。
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 卡片背景 | `#0C1836` | ZS-004-09(与外层同色,营造凹陷感) |
|
||||
| 虚线边框 | `#4096FF` | ZS-002-05 |
|
||||
| 加号图标 | `#4096FF` | ZS-002-05 |
|
||||
|
||||
#### 3.1.4 阴影投影规则
|
||||
|
||||
| 层级 | 阴影值 | 使用场景 |
|
||||
|------|--------|----------|
|
||||
| 一级阴影(卡片悬浮) | `0 2px 8px rgba(22, 119, 255, 0.12)` | 普通卡片 |
|
||||
| 二级阴影(hover / 强调) | `0 4px 16px rgba(22, 119, 255, 0.24)` | 卡片 hover、弹出层 |
|
||||
| 三级阴影(弹窗 / Modal) | `0 8px 32px rgba(6, 14, 36, 0.6)` | Dialog、Drawer |
|
||||
|
||||
---
|
||||
|
||||
## 4. 圆角
|
||||
|
||||
### 4.1 圆角统一规范
|
||||
|
||||
| 元素 | 圆角值 | 说明 |
|
||||
|------|--------|------|
|
||||
| 按钮 | `2px` | 所有按钮(主按钮 / 次按钮 / 文本按钮)统一使用 |
|
||||
| 卡片 | `4px` | 内容卡片、标题+操作卡片、卡片新增占位 |
|
||||
| 页面分栏框 | `4px` | 外层容器、分栏区域 |
|
||||
| 输入框 / 选择器 | `2px` | 与按钮一致,保持表单内对齐 |
|
||||
| Tag / Badge | `2px` | 与按钮一致 |
|
||||
| Modal / Drawer | `4px` | 与卡片一致 |
|
||||
|
||||
### 4.2 按钮配色(圆角 2px)
|
||||
|
||||
#### 4.2.1 主按钮(Primary)
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 背景 | `#1677FF` | ZS-002-06 |
|
||||
| 文字 | `#FFFFFF` | — |
|
||||
| Hover 背景 | `#0958D9` | ZS-002-07 |
|
||||
| Active 背景 | `#003EB3` | ZS-002-08 |
|
||||
| 禁用背景 | `#4A6491` | ZS-004-05 |
|
||||
| 禁用文字 | `#6E88B0` | ZS-004-04 |
|
||||
|
||||
#### 4.2.2 次按钮(Outline / Default)
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 背景 | `transparent` | — |
|
||||
| 边框 | `#6E88B0` | ZS-004-04 |
|
||||
| 文字 | `#C5CFE0` | ZS-004-02 |
|
||||
| Hover 边框 | `#4096FF` | ZS-002-05 |
|
||||
| Hover 文字 | `#4096FF` | ZS-002-05 |
|
||||
| Active 边框 | `#1677FF` | ZS-002-06 |
|
||||
|
||||
### 4.3 卡片与分栏(圆角 4px)
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 卡片背景 | `#122347` | ZS-004-08 |
|
||||
| 卡片边框 | `#1A2F5A` | ZS-004-07 |
|
||||
| 分栏框背景 | `#0C1836` | ZS-004-09 |
|
||||
| 分栏框边框 | `#1A2F5A` | ZS-004-07 |
|
||||
|
||||
---
|
||||
|
||||
## 5. 按钮
|
||||
|
||||
> 全部圆角 `2px`,文字字号 14px(小尺寸)/ 14px(正常尺寸),字体 Noto Sans S Chinese Regular。
|
||||
|
||||
### 5.1 按钮尺寸
|
||||
|
||||
| 规格 | 高度 | 内边距 | 使用场景 |
|
||||
|------|------|--------|----------|
|
||||
| 小 | `28px` | `0 10px` | 空间小的板块内部,如表格中、卡片标题等 |
|
||||
| 正常 | `32px` | `0 14px` | 默认尺寸,所有常用按钮 |
|
||||
|
||||
### 5.2 按钮类型与配色
|
||||
|
||||
#### 5.2.1 主按钮(Primary)
|
||||
|
||||
> 一个操作区域只能有一个主按钮。
|
||||
|
||||
| 状态 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `#1677FF` (ZS-002-06) | — | `#FFFFFF` |
|
||||
| Hover | `#0958D9` (ZS-002-07) | — | `#FFFFFF` |
|
||||
| Active | `#003EB3` (ZS-002-08) | — | `#FFFFFF` |
|
||||
| 失效 | `rgba(22, 119, 255, 0.35)` | — | `#6E88B0` (ZS-004-04) |
|
||||
|
||||
#### 5.2.2 默认按钮(Default / Outline)
|
||||
|
||||
用于"取消 / 返回"等次要操作,与主按钮成对出现时主按钮在右。
|
||||
|
||||
| 状态 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `transparent` | `#6E88B0` (ZS-004-04) | `#C5CFE0` (ZS-004-02) |
|
||||
| Hover | `rgba(22, 119, 255, 0.08)` | `#4096FF` (ZS-002-05) | `#4096FF` (ZS-002-05) |
|
||||
| Active | `rgba(22, 119, 255, 0.16)` | `#1677FF` (ZS-002-06) | `#1677FF` (ZS-002-06) |
|
||||
| 失效 | `transparent` | `#4A6491` (ZS-004-05) | `#4A6491` (ZS-004-05) |
|
||||
|
||||
#### 5.2.3 文本按钮(Text)
|
||||
|
||||
用于表格操作、文件下载等。无背景与边框,靠文字色识别。
|
||||
|
||||
| 状态 | 文字 | 装饰 |
|
||||
|------|------|------|
|
||||
| 默认 | `#4096FF` (ZS-002-05) | 无下划线 |
|
||||
| Hover | `#1677FF` (ZS-002-06) | 显示下划线(与文字同色) |
|
||||
| Active | `#0958D9` (ZS-002-07) | 下划线 |
|
||||
| 失效 | `#4A6491` (ZS-004-05) | 无装饰 |
|
||||
|
||||
#### 5.2.4 图标按钮(Icon-only)
|
||||
|
||||
用于增强辨识度或节省空间。仅图标,无文字。
|
||||
|
||||
| 变体 | 背景 | 图标颜色 |
|
||||
|------|------|----------|
|
||||
| 主色(常用) | `#1677FF` (ZS-002-06) | `#FFFFFF` |
|
||||
| 主色 Hover | `#0958D9` (ZS-002-07) | `#FFFFFF` |
|
||||
| 危险(删除等) | `#F5222D` (ZS-001-06) | `#FFFFFF` |
|
||||
| 危险 Hover | `#CF1322` (ZS-001-07) | `#FFFFFF` |
|
||||
| 透明(仅图标) | `transparent` | `#6E88B0` (ZS-004-04) → hover `#4096FF` (ZS-002-05) |
|
||||
|
||||
### 5.3 按钮组合
|
||||
|
||||
#### 5.3.1 文字 + 下拉按钮(含 ▾)
|
||||
|
||||
两种填充:
|
||||
|
||||
| 形态 | 配色规则 |
|
||||
|------|----------|
|
||||
| 默认(Outline) | 沿用 §5.2.2 默认按钮,箭头 ▾ 与文字同色 `#C5CFE0` |
|
||||
| 主色(Filled) | 沿用 §5.2.1 主按钮,箭头 ▾ 同步白色 `#FFFFFF` |
|
||||
|
||||
#### 5.3.2 图标 + 文字按钮(如 `+ 正常`)
|
||||
|
||||
| 形态 | 配色规则 |
|
||||
|------|----------|
|
||||
| 默认(Outline) | 沿用 §5.2.2,左侧图标颜色与文字一致 `#C5CFE0` |
|
||||
| 主色(Filled) | 沿用 §5.2.1,左侧图标与文字一致 `#FFFFFF` |
|
||||
|
||||
#### 5.3.3 文本按钮 + 图标("更多 »"、"展开 ⌄"、"下一页 »"、"« 上一页")
|
||||
|
||||
| 角色 | 色值 |
|
||||
|------|------|
|
||||
| 文字 + 图标(默认) | `#4096FF` (ZS-002-05) |
|
||||
| 文字 + 图标(Hover) | `#1677FF` (ZS-002-06) |
|
||||
| 失效 | `#4A6491` (ZS-004-05) |
|
||||
|
||||
> 图标可在文字前或后;多个文本按钮排成一行时,间距 `16px`,无分隔符。
|
||||
|
||||
#### 5.3.4 主按钮 + 默认按钮组合(如"确定 / 取消 / 返回")
|
||||
|
||||
- **排列顺序**:默认按钮在左,主按钮在右(最右侧为主操作)
|
||||
- **按钮间距**:`8px`
|
||||
- **示例**:`[ 返回 ] [ 取消 ] [ 确定 ]`
|
||||
- **配色**:主按钮沿用 §5.2.1,其余沿用 §5.2.2
|
||||
|
||||
### 5.4 其他按钮
|
||||
|
||||
#### 5.4.1 悬浮状态(Floating)
|
||||
|
||||
用于 Banner / 登录 / 视觉冲击强等展示场景。配色与主按钮一致,叠加阴影抬升。
|
||||
|
||||
| 状态 | 阴影 |
|
||||
|------|------|
|
||||
| 默认 | `0 2px 8px rgba(22, 119, 255, 0.12)`(§3.1.4 一级阴影) |
|
||||
| Hover | `0 4px 16px rgba(22, 119, 255, 0.24)`(§3.1.4 二级阴影) |
|
||||
| Active | 阴影消失,按下感 |
|
||||
|
||||
#### 5.4.2 加载中(Loading)
|
||||
|
||||
用于异步操作等待反馈。点击瞬间将按钮锁定,文字前显示旋转图标。
|
||||
|
||||
| 角色 | 色值 |
|
||||
|------|------|
|
||||
| 背景 | `#1677FF` (ZS-002-06) |
|
||||
| 文字 | `#FFFFFF` |
|
||||
| 加载图标 | `#FFFFFF`,旋转动画 `1.2s linear infinite` |
|
||||
| 不可点击 | 鼠标 `cursor: not-allowed` |
|
||||
|
||||
> 与失效态的区别:失效是"不可操作",加载是"操作进行中"——保留品牌主色,只是不可再次触发。
|
||||
|
||||
---
|
||||
|
||||
## 6. 分割线
|
||||
|
||||
> 统一线宽 `1px`,颜色全部从 ZS-004 深蓝系取色,与深色背景保持低对比度但仍可识别。
|
||||
|
||||
### 6.1 水平分割线
|
||||
|
||||
水平分割线常用来对不同元素内容进行分割。
|
||||
|
||||
| 类型 | 色值 | 来源 | 样式 | 使用场景 |
|
||||
|------|------|------|------|----------|
|
||||
| 实线(默认) | `#4A6491` | ZS-004-05 | `border-top: 1px solid` | 模块间、列表项间分割 |
|
||||
| 实线(强调) | `#6E88B0` | ZS-004-04 | `border-top: 1px solid` | 主区块标题下方、卡片头部分割 |
|
||||
| 实线(弱化) | `#2D4473` | ZS-004-06 | `border-top: 1px solid` | 卡片内部、密集列表分隔 |
|
||||
| 虚线 | `#4A6491` | ZS-004-05 | `border-top: 1px dashed` | 次级 / 层级内分割,提示"非主结构" |
|
||||
| 主色实线(高亮) | `#1677FF` | ZS-002-06 | `border-top: 1px solid` | 强调分隔,少量使用(如当前激活区块底边) |
|
||||
|
||||
### 6.2 垂直分割线
|
||||
|
||||
垂直分割线常用来做行内分割(如导航项之间、状态指示之间、表格列头之间)。
|
||||
|
||||
| 类型 | 色值 | 来源 | 样式 | 使用场景 |
|
||||
|------|------|------|------|----------|
|
||||
| 实线(默认) | `#4A6491` | ZS-004-05 | `border-left: 1px solid` | 行内 inline 元素分割(面包屑、操作按钮组) |
|
||||
| 实线(弱化) | `#2D4473` | ZS-004-06 | `border-left: 1px solid` | 表格列分割、紧凑布局 |
|
||||
| 虚线 | `#4A6491` | ZS-004-05 | `border-left: 1px dashed` | 多列对齐辅助、辅助参考线 |
|
||||
|
||||
### 6.3 规格与间距
|
||||
|
||||
| 规则 | 取值 |
|
||||
|------|------|
|
||||
| 线宽 | `1px` |
|
||||
| 水平分割线与上下元素间距 | `≥ 8px`(紧凑布局可用 `4px`) |
|
||||
| 垂直分割线与左右元素间距 | `≥ 8px`(行内紧凑 `4px`) |
|
||||
| 垂直分割线高度 | 与文字行高一致,约 `12–14px`(也可全高跟随容器) |
|
||||
| 透明度 | 必要时叠 `opacity: 0.6` 实现"更弱"层级 |
|
||||
|
||||
### 6.4 CSS 参考
|
||||
|
||||
```css
|
||||
/* 默认水平分割线 */
|
||||
.divider-h { border-top: 1px solid #4A6491; }
|
||||
.divider-h-strong { border-top: 1px solid #6E88B0; }
|
||||
.divider-h-weak { border-top: 1px solid #2D4473; }
|
||||
.divider-h-dashed { border-top: 1px dashed #4A6491; }
|
||||
.divider-h-accent { border-top: 1px solid #1677FF; }
|
||||
|
||||
/* 垂直分割线 */
|
||||
.divider-v { border-left: 1px solid #4A6491; height: 14px; display: inline-block; vertical-align: middle; }
|
||||
.divider-v-weak { border-left: 1px solid #2D4473; height: 14px; display: inline-block; vertical-align: middle; }
|
||||
.divider-v-dashed { border-left: 1px dashed #4A6491; height: 14px; display: inline-block; vertical-align: middle; }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. 间距
|
||||
|
||||
> 全站以 `8px (0.5rem)` 为对照基准单位,划分"密 / 疏"两个层次。所有间距取值均来自下列阶梯,禁止使用非阶梯值(如 5px、13px)。
|
||||
|
||||
### 7.1 间距阶梯
|
||||
|
||||
| 阶 | px | rem | 分组 | 典型场景 |
|
||||
|----|------|--------|------|----------|
|
||||
| 1 | `4px` | `0.25rem` | 密 | 图标与文字间距、Tag 内边距、紧凑徽标 |
|
||||
| 2 | `8px` | `0.5rem` | 密 | 行内元素相邻、按钮组间距、表单 label 与控件 |
|
||||
| 3 | `12px` | `0.75rem` | 密 | 表单项垂直间距、列表项内边距 |
|
||||
| 4 | `16px` | `1rem` | 密 | 卡片内容内边距、模块内分隔 |
|
||||
| 5 | `24px` | `1.5rem` | 疏 | 模块之间、Section 内边距 |
|
||||
| 6 | `32px` | `2rem` | 疏 | 卡片之间、表单组之间 |
|
||||
| 7 | `40px` | `2.5rem` | 疏 | 主区块之间、页面 Header / Footer 内边距 |
|
||||
| 8 | `56px` | `3.5rem` | 疏 | 页面段落级隔断、Banner 区域 |
|
||||
|
||||
> "密"对应紧凑信息密度(表格、表单、卡片内部);"疏"对应视觉呼吸(模块之间、页面整体留白)。**16px 是"密"的上限,24px 是"疏"的下限**,两者之间不应再插入自定义值。
|
||||
|
||||
### 7.2 使用原则
|
||||
|
||||
- **同层级一致**:同一布局层级内的间距必须使用同一阶值;多种取值会破坏节奏。
|
||||
- **就近取阶**:相邻区块的间距尽量从相邻阶梯取值(如 `16px → 24px`),跨越过多阶(如 `8px → 56px`)会让视觉断裂。
|
||||
- **密疏不混用**:一个组件内部全部用"密",外部用"疏",避免内/外间距颠倒。
|
||||
- **优先 8 的倍数**:除最小阶 `4px` 外,所有阶皆为 8 的倍数,方便 4/8 网格对齐。
|
||||
- **响应式按比例衰减**:移动端可整体降一阶(如 `24px → 16px`),但仍在阶梯内。
|
||||
|
||||
### 7.3 CSS Token 建议
|
||||
|
||||
```css
|
||||
:root {
|
||||
--spacing-1: 4px; /* 0.25rem */
|
||||
--spacing-2: 8px; /* 0.5rem */
|
||||
--spacing-3: 12px; /* 0.75rem */
|
||||
--spacing-4: 16px; /* 1rem */
|
||||
--spacing-5: 24px; /* 1.5rem */
|
||||
--spacing-6: 32px; /* 2rem */
|
||||
--spacing-7: 40px; /* 2.5rem */
|
||||
--spacing-8: 56px; /* 3.5rem */
|
||||
}
|
||||
```
|
||||
|
||||
### 7.4 与已有规范的对齐
|
||||
|
||||
| 已有规则 | 对应阶 |
|
||||
|----------|--------|
|
||||
| §4.x 卡片圆角内边距 | `--spacing-4` (16px) |
|
||||
| §5.3.4 主+默认按钮组合间距 `8px` | `--spacing-2` |
|
||||
| §5.3.3 文本按钮间距 `16px` | `--spacing-4` |
|
||||
| §6.3 分割线与上下元素间距 `≥ 8px` | `--spacing-2` 起 |
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,780 @@
|
||||
# 深蓝色 UI 规范 · 01 导航(§8–§13)
|
||||
|
||||
> 《深蓝色 UI 规范》分册之一。基础令牌见 `00-基础-色彩字体间距.md`,可 import 的变量见 `tokens.css`,总目录与 §索引见 `README.md`。`§N` 编号全局唯一。
|
||||
|
||||
**本篇目录**:`8` 导航组件 · `9` 锚点与页签 · `10` 步骤条 · `11` 面包屑 · `12` 页头 · `13` 分页
|
||||
|
||||
---
|
||||
|
||||
## 8. 导航组件
|
||||
|
||||
> 适用于"大屏后台 / 控制台"类深蓝主题界面。整体结构 = 顶部导航 + 左侧分级菜单 + 多级下拉。所有颜色取自 ZS-002 / ZS-004 两个色系。
|
||||
|
||||
### 8.1 整体结构
|
||||
|
||||
```
|
||||
┌─ 顶部导航(Header)─ 高 56px ──────────────────────────────────────────────┐
|
||||
│ ≡ 二级菜单 二级菜单 二级菜单 〈一级菜单〉〈一级菜单〉 ⟪ XXXX系统 ⟫ 〈一级菜单〉 ⟳ 时间 ⌂ 返回首页 │
|
||||
├──┬──────────────────────────────────────────────────────────────────────────┤
|
||||
│ 三│ ┌─ 四级菜单(下拉面板)──┐ │
|
||||
│ 级│ │ ▾ 四级菜单 │ │
|
||||
│ 菜│ │ ▾ 五级菜单 │ │
|
||||
│ 单│ │ - 六级菜单 (active)│ │
|
||||
│ 三│ │ - 六级菜单 │ │
|
||||
│ 级│ │ ▸ 五级菜单 │ │
|
||||
│ 菜│ │ ▸ 四级菜单 │ │
|
||||
│ 单│ └────────────────────────┘ │
|
||||
│ …│ │
|
||||
└──┴──────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 8.2 顶部导航(Header)
|
||||
|
||||
#### 8.2.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 高度 | `56px` |
|
||||
| 左右 padding | `--spacing-4` (16px) |
|
||||
| 背景 | 渐变 `linear-gradient(180deg, #122347 0%, #0C1836 100%)`(ZS-004-08 → ZS-004-09) |
|
||||
| 底边 | `border-bottom: 1px solid #1A2F5A` (ZS-004-07) |
|
||||
| 阴影 | `0 2px 8px rgba(6, 14, 36, 0.6)`(§3.1.4 一级阴影变体) |
|
||||
| 文字基线 | `Noto Sans S Chinese`,垂直居中 |
|
||||
|
||||
#### 8.2.2 二级菜单(左侧 Tabs,小号 14px)
|
||||
|
||||
| 状态 | 文字 | 背景 | 装饰 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `#6E88B0` (ZS-004-04) | `transparent` | — |
|
||||
| Hover | `#C5CFE0` (ZS-004-02) | `rgba(22,119,255,0.08)` | — |
|
||||
| 激活 | `#4096FF` (ZS-002-05) | `transparent` | 底部 `2px solid #4096FF` 高亮线 |
|
||||
|
||||
- 字号 `14px Regular`,间距 `--spacing-3` (12px)
|
||||
- 与最左侧的"折叠菜单 ≡"图标间距 `--spacing-4` (16px)
|
||||
|
||||
#### 8.2.3 一级菜单(中部主导航,16px 带切角装饰)
|
||||
|
||||
| 状态 | 文字 | 装饰 |
|
||||
|------|------|------|
|
||||
| 默认 | `#C5CFE0` (ZS-004-02) | 两端切角斜边,`border: 1px solid #1A2F5A` |
|
||||
| Hover | `#4096FF` (ZS-002-05) | 切角线变 `#4096FF` |
|
||||
| 激活 | `#FFFFFF` | 切角线 `#1677FF` (ZS-002-06),背景 `rgba(22,119,255,0.16)` |
|
||||
|
||||
- 字号 `16px Medium`
|
||||
- 切角推荐 `clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 100%, 0 100%)`
|
||||
- 项间距 `--spacing-2` (8px)
|
||||
|
||||
#### 8.2.4 系统标题(XXXX系统)
|
||||
|
||||
- 字号 `20px Bold`,颜色 `#FFFFFF`
|
||||
- 字体 `DOUYUFont` 或 Noto Sans Medium
|
||||
- 左右装饰用主色蓝渐变线条:`linear-gradient(90deg, transparent 0%, #1677FF 50%, transparent 100%)`,线宽 `1px`
|
||||
- 居中相对 Header 几何中心,左右最少留 `--spacing-6` (32px) 间距给一级菜单
|
||||
|
||||
#### 8.2.5 右侧工具区(时间 / 图标 / 返回首页)
|
||||
|
||||
| 元素 | 字号/尺寸 | 颜色 |
|
||||
|------|----------|------|
|
||||
| 更新时间文字 | `12px Regular` | `#6E88B0` (ZS-004-04) |
|
||||
| 时间数值(数字) | `12px D-DIN Regular` | `#C5CFE0` (ZS-004-02) |
|
||||
| 工具图标(刷新/上/家) | `16px` | `#6E88B0`,hover → `#4096FF` |
|
||||
| 返回首页文字 | `14px Regular` | `#C5CFE0`,hover → `#4096FF` |
|
||||
|
||||
- 元素间距 `--spacing-3` (12px)
|
||||
- 整体右 padding `--spacing-4` (16px)
|
||||
|
||||
### 8.3 侧边栏(三级菜单)
|
||||
|
||||
#### 8.3.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 宽度 | `64px`(仅图标 / 竖排文字) |
|
||||
| 背景 | `#0C1836` (ZS-004-09) |
|
||||
| 右边界 | `border-right: 1px solid #1A2F5A` (ZS-004-07) |
|
||||
| 项高度 | `64px`(与宽度一致,呈正方形) |
|
||||
| 项内间距 | 上下 `--spacing-3` (12px) |
|
||||
| 字号 | `14px Medium`,竖排(`writing-mode: vertical-rl`)或正常排两行 |
|
||||
|
||||
#### 8.3.2 状态配色
|
||||
|
||||
| 状态 | 背景 | 文字 | 左侧指示条 |
|
||||
|------|------|------|-----------|
|
||||
| 默认 | `transparent` | `#6E88B0` (ZS-004-04) | 无 |
|
||||
| Hover | `rgba(22,119,255,0.08)` | `#C5CFE0` (ZS-004-02) | 无 |
|
||||
| 激活 | `#1A2F5A` (ZS-004-07) | `#FFFFFF` | 左侧 `2px solid #1677FF` (ZS-002-06) |
|
||||
|
||||
### 8.4 下拉菜单面板(四级 / 五级 / 六级)
|
||||
|
||||
#### 8.4.1 面板规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 背景 | `#122347` (ZS-004-08) |
|
||||
| 边框 | `1px solid #1A2F5A` (ZS-004-07) |
|
||||
| 阴影 | `0 4px 16px rgba(6, 14, 36, 0.6)`(§3.1.4 三级阴影变体) |
|
||||
| 圆角 | `4px` |
|
||||
| 内边距 | 上下 `--spacing-2` (8px) |
|
||||
| 最小宽度 | `150px` |
|
||||
|
||||
#### 8.4.2 菜单项规格
|
||||
|
||||
| 层级 | 缩进(padding-left) | 字号 | 展开图标 | 前缀 |
|
||||
|------|---------------------|------|----------|------|
|
||||
| 四级菜单 | `--spacing-3` (12px) | `14px Medium` | `▾ / ▸` | — |
|
||||
| 五级菜单 | `--spacing-5` (24px) | `14px Regular` | `▾ / ▸` | — |
|
||||
| 六级菜单 | `--spacing-6` (32px) | `14px Regular` | — | `-` 短横线 |
|
||||
|
||||
- 行高 `32px`
|
||||
- 项之间无分割线(靠缩进与图标区分层级)
|
||||
|
||||
#### 8.4.3 菜单项配色
|
||||
|
||||
| 状态 | 背景 | 文字 | 展开图标 |
|
||||
|------|------|------|----------|
|
||||
| 默认 | `transparent` | `#C5CFE0` (ZS-004-02) | `#6E88B0` (ZS-004-04) |
|
||||
| Hover | `rgba(22,119,255,0.08)` | `#4096FF` (ZS-002-05) | `#4096FF` |
|
||||
| 激活(当前选中) | `rgba(22,119,255,0.16)` | `#4096FF` (ZS-002-05) | `#1677FF` (ZS-002-06) |
|
||||
| 父级(含激活子项) | `transparent` | `#FFFFFF` | `#1677FF` |
|
||||
| 失效 | `transparent` | `#4A6491` (ZS-004-05) | `#4A6491` |
|
||||
|
||||
### 8.5 交互与动画
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 下拉面板展开 | `transform-origin: top; transform: scaleY(0.95) → scaleY(1); opacity 0 → 1`,`200ms ease-out` |
|
||||
| 展开图标旋转 | `transform: rotate(0 → 90deg)`,`200ms ease-out` |
|
||||
| Hover 背景过渡 | `background-color 120ms ease-out` |
|
||||
| 激活底部高亮线(二级菜单) | `width 0% → 100%`,`240ms ease-out` |
|
||||
|
||||
### 8.6 间距引用
|
||||
|
||||
| 位置 | 取值 |
|
||||
|------|------|
|
||||
| Header 内部元素间距 | `--spacing-2 / --spacing-3` |
|
||||
| Header 与下方内容间距 | `0`(贴合,靠底边线与阴影区分) |
|
||||
| 侧边栏与下拉面板间距 | `--spacing-1` (4px) |
|
||||
| 下拉面板与触发元素间距 | `--spacing-1` (4px) |
|
||||
| 同级菜单项之间 | `0`(紧贴排列,靠 hover/active 背景区分) |
|
||||
|
||||
---
|
||||
|
||||
## 9. 锚点与页签
|
||||
|
||||
> 对应"4.2 导航组件-锚点"。三类组件共用主色蓝指示当前位置:**页签 / 锚点 / 回到顶部**。
|
||||
>
|
||||
> 视觉参考:标签横向 / 标签纵向 / 锚点的三联图见设计稿「选项卡.png」——三种形态在本节均已规范化(§9.1 = 标签横纵向、§9.2 = 锚点)。
|
||||
|
||||
### 9.1 页签(Tabs)
|
||||
|
||||
#### 9.1.1 横向页签(下划线-横向)
|
||||
|
||||
| 状态 | 文字 | 下划线 |
|
||||
|------|------|--------|
|
||||
| 默认 | `#C5CFE0` (ZS-004-02) | 无 |
|
||||
| Hover | `#4096FF` (ZS-002-05) | 无 |
|
||||
| 激活 | `#4096FF` (ZS-002-05) | `2px solid #4096FF`,宽度与文字齐 |
|
||||
| 失效 | `#4A6491` (ZS-004-05) | 无 |
|
||||
|
||||
- 字号 `14px Medium`
|
||||
- 项间距 `--spacing-5` (24px)
|
||||
- 下划线与文字底部间距 `--spacing-2` (8px)
|
||||
- 容器底边可叠一条 `1px solid #1A2F5A` (ZS-004-07) 作为基线,激活态的高亮线压在上面
|
||||
|
||||
#### 9.1.2 纵向页签(下划线-纵向)
|
||||
|
||||
| 状态 | 文字 | 右侧指示线 |
|
||||
|------|------|-----------|
|
||||
| 默认 | `#C5CFE0` (ZS-004-02) | 无 |
|
||||
| Hover | `#4096FF` (ZS-002-05) | 无 |
|
||||
| 激活 | `#4096FF` (ZS-002-05) | 右侧 `2px solid #4096FF`,高度与文字齐 |
|
||||
| 失效 | `#4A6491` (ZS-004-05) | 无 |
|
||||
|
||||
- 字号 `14px Medium`,项高度 `32px`
|
||||
- 项间距 `--spacing-2` (8px)
|
||||
- 容器右边可叠一条 `1px solid #1A2F5A` 基线,激活指示线压在上面
|
||||
|
||||
### 9.2 锚点(Anchor)
|
||||
|
||||
用于长内容页(如详情页、文档页)的章节快速跳转。
|
||||
|
||||
#### 9.2.1 结构
|
||||
|
||||
```
|
||||
│ 一级
|
||||
│ 一级 (active)
|
||||
│ 二级
|
||||
│ 二级
|
||||
│ 一级
|
||||
│ 一级
|
||||
```
|
||||
|
||||
#### 9.2.2 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器背景 | `#122347` (ZS-004-08) 或 `transparent`(嵌入页面侧栏时) |
|
||||
| 左侧基线 | `1px solid #1A2F5A` (ZS-004-07) 通栏 |
|
||||
| 项高度 | `32px` |
|
||||
| 一级项左 padding | `--spacing-3` (12px) |
|
||||
| 二级项左 padding | `--spacing-5` (24px) |
|
||||
| 项间距 | `0`(贴合排列) |
|
||||
| 字号 | `14px Regular` |
|
||||
|
||||
#### 9.2.3 状态配色
|
||||
|
||||
| 状态 | 一级文字 | 二级文字 | 左侧指示条 |
|
||||
|------|----------|----------|-----------|
|
||||
| 默认 | `#C5CFE0` (ZS-004-02) | `#6E88B0` (ZS-004-04) | 无 |
|
||||
| Hover | `#4096FF` (ZS-002-05) | `#4096FF` (ZS-002-05) | 无 |
|
||||
| 激活 | `#4096FF` (ZS-002-05) | — | 左侧 `2px solid #4096FF`,覆盖容器基线 |
|
||||
| 父级(含激活子项) | `#FFFFFF` | — | — |
|
||||
|
||||
- 激活态指示条与基线重合,宽 `2px`,色压主色蓝 `#4096FF`
|
||||
- 二级项**不单独支持激活态**:当二级被点中时,其父级一级显示激活态,左侧指示条按父级位置渲染
|
||||
|
||||
#### 9.2.4 滚动同步
|
||||
|
||||
| 行为 | 规则 |
|
||||
|------|------|
|
||||
| 页面滚动 | 监听锚点对应区块进入视口的相对位置,自动切换激活态 |
|
||||
| 点击锚点 | `behavior: smooth` 滚动到目标,激活指示条 `top` 过渡 `200ms ease-out` |
|
||||
| 边界处理 | 滚动到页面顶部 → 第一个锚点激活;到页尾 → 最后一个锚点激活 |
|
||||
|
||||
### 9.3 回到顶部(BackToTop)
|
||||
|
||||
固定在视口右下角的悬浮按钮,向上滚动到页面顶部。
|
||||
|
||||
#### 9.3.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 形状 | 圆形 `40px × 40px`(`border-radius: 50%`) |
|
||||
| 图标 | `↑` 上箭头,`16px`,`#FFFFFF` |
|
||||
| 距视口右边 | `--spacing-5` (24px) |
|
||||
| 距视口下边 | `--spacing-6` (32px) |
|
||||
| 出现时机 | 页面 `scrollTop > 200px` 时淡入;回到顶部后淡出 |
|
||||
| 淡入/淡出 | `opacity 0 → 1` / `1 → 0`,`200ms ease-out` |
|
||||
|
||||
#### 9.3.2 状态配色
|
||||
|
||||
| 状态 | 背景 | 阴影 | 图标 |
|
||||
|------|------|------|------|
|
||||
| 正常(默认) | `#1677FF` (ZS-002-06) | `0 2px 8px rgba(22,119,255,0.12)` (§3.1.4 一级阴影) | `#FFFFFF` |
|
||||
| 悬停(Hover) | `#0958D9` (ZS-002-07) | `0 4px 16px rgba(22,119,255,0.24)` (§3.1.4 二级阴影) | `#FFFFFF` |
|
||||
| 点按(Active) | `#003EB3` (ZS-002-08) | 阴影消失,按下感 | `#FFFFFF` |
|
||||
| 失效 / 不显示 | — | — | 整体 `opacity: 0`,`pointer-events: none` |
|
||||
|
||||
#### 9.3.3 悬停 Tooltip
|
||||
|
||||
Hover 状态下方显示 `回到顶部` 提示气泡:
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 文字 | `回到顶部`,`12px Regular` |
|
||||
| 文字颜色 | `#C5CFE0` (ZS-004-02) |
|
||||
| 背景 | `#1677FF` (ZS-002-06) |
|
||||
| 圆角 | `2px` |
|
||||
| 内边距 | 上下 `4px`,左右 `--spacing-2` (8px) |
|
||||
| 与按钮间距 | `--spacing-2` (8px) |
|
||||
| 出现时机 | Hover 进入 `300ms` 后显示,离开立即消失 |
|
||||
|
||||
### 9.4 三者的差异与选用
|
||||
|
||||
| 组件 | 主要用途 | 视觉特征 |
|
||||
|------|----------|---------|
|
||||
| 页签 | 同层级内容切换(多 Tab 互斥) | 文字 + 下划线(横/纵) |
|
||||
| 锚点 | 长页面内章节跳转 | 文字 + 左侧指示条 + 层级缩进 |
|
||||
| 回到顶部 | 长页面快速返回起点 | 圆形悬浮按钮 + 上箭头 |
|
||||
|
||||
---
|
||||
|
||||
## 10. 步骤条
|
||||
|
||||
> 对应「4.7 导航组件-步骤条」。用于多步流程的进度指引,按布局方向分**横向**与**纵向**两类,按使用场景分**弹窗步骤条**、**页面步骤条**、**纵向步骤条**三种。所有颜色取自 ZS-002 主色蓝与 ZS-004 深蓝系。
|
||||
|
||||
### 10.1 步骤节点(公共)
|
||||
|
||||
每个步骤由「指示圆 + 标题(可选描述)」组成。指示圆按状态切换三种形态:
|
||||
|
||||
| 状态 | 圆形外观 | 圆内符号 | 来源 |
|
||||
|------|----------|----------|------|
|
||||
| 已完成(Completed) | 描边圆,`2px solid #1677FF`,背景 `transparent` | `✓`(对勾,`#1677FF`) | ZS-002-06 |
|
||||
| 当前(Current / Active) | 实心圆,背景 `#1677FF` | 步骤数字,`#FFFFFF` | ZS-002-06 / 白 |
|
||||
| 未开始(Upcoming) | 描边圆,`1px solid #4A6491`,背景 `transparent` | 步骤数字,`#6E88B0` | ZS-004-05 / ZS-004-04 |
|
||||
| 失效(Disabled) | 描边圆,`1px solid #2D4473`,背景 `transparent` | 步骤数字,`#4A6491` | ZS-004-06 / ZS-004-05 |
|
||||
|
||||
**指示圆规格**:
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 直径 | `24px` |
|
||||
| 圆内字号 | `12px Bold`(D-DIN 或 Noto Sans Bold) |
|
||||
| 对勾图标 | `12px`,居中 |
|
||||
| 字体水平居中 | 数字 / 对勾 在圆几何中心 |
|
||||
|
||||
**标题与描述文字**:
|
||||
|
||||
| 元素 | 状态 | 字号 / 颜色 | 来源 |
|
||||
|------|------|-------------|------|
|
||||
| 标题 | 已完成 / 当前 | `14px Medium`,`#FFFFFF` | — |
|
||||
| 标题 | 未开始 | `14px Medium`,`#6E88B0` | ZS-004-04 |
|
||||
| 标题 | 失效 | `14px Medium`,`#4A6491` | ZS-004-05 |
|
||||
| 描述 | 已完成 / 当前 | `12px Regular`,`#C5CFE0` | ZS-004-02 |
|
||||
| 描述 | 未开始 / 失效 | `12px Regular`,`#6E88B0` → `#4A6491` | ZS-004-04 → ZS-004-05 |
|
||||
|
||||
**连接线(步骤之间)**:
|
||||
|
||||
| 类型 | 色值 | 来源 | 样式 |
|
||||
|------|------|------|------|
|
||||
| 已完成段(前一节点已完成) | `#1677FF` | ZS-002-06 | `1px dashed`(弹窗)/ `1px solid`(页面) |
|
||||
| 未完成段 | `#4A6491` | ZS-004-05 | `1px dashed` |
|
||||
|
||||
> 连接线在指示圆**两侧水平居中**(横向)或**正下方垂直**(纵向);线两端与圆外缘留 `--spacing-1` (4px) 间隙,避免线穿圆。
|
||||
|
||||
### 10.2 弹窗步骤条(横向 · 描边圆为主)
|
||||
|
||||
用于 Modal / Drawer 内引导多步操作的紧凑步骤条。指示圆**完成态用描边 + 对勾**而非实心,避免在弹窗背景上过于抢眼。
|
||||
|
||||
#### 10.2.1 布局
|
||||
|
||||
```
|
||||
( ✓ ) ┄┄┄┄┄ (●2) ┄┄┄┄┄ ( 3 ) ┄┄┄┄┄ ( 4 ) ┄┄┄┄┄ ( 5 )
|
||||
标题 标题 标题 标题 标题
|
||||
(描述) (描述) (描述) (描述) (描述)
|
||||
```
|
||||
|
||||
#### 10.2.2 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器水平 padding | `--spacing-5` (24px) |
|
||||
| 指示圆 → 标题间距 | `--spacing-2` (8px) |
|
||||
| 标题 → 描述间距 | `--spacing-1` (4px) |
|
||||
| 节点之间水平间距 | 节点间距自适应等分;连接线占用中间空间 |
|
||||
| 连接线 | `1px dashed`,已完成段 `#1677FF`,未完成段 `#4A6491` |
|
||||
| 文字对齐 | 标题、描述居中对齐于指示圆下方 |
|
||||
|
||||
#### 10.2.3 两种变体
|
||||
|
||||
| 变体 | 适用 |
|
||||
|------|------|
|
||||
| **仅标题** | 步骤含义已经清晰(如「填写信息 / 确认 / 完成」),节省垂直空间 |
|
||||
| **标题 + 描述** | 步骤名抽象需要一行小字补充时使用 |
|
||||
|
||||
### 10.3 页面步骤条(横向 · 实心圆 + 自定义首项标题)
|
||||
|
||||
用于页面级流程(如「新建集群」类向导)。和弹窗步骤条相比,**已完成态指示圆改为实心填充 + 白色对勾**,视觉权重更高;首步标题可显示具体名称(如「新建集群」)而非「标题」占位。
|
||||
|
||||
#### 10.3.1 布局
|
||||
|
||||
```
|
||||
(✓) ────── (●2) ┄┄┄┄┄ ( 3 ) ┄┄┄┄┄ ( 4 ) ┄┄┄┄┄ ( 5 )
|
||||
新建集群 标题 标题 标题 标题
|
||||
(描述文本) (描述文本) (描述文本) (描述文本) (描述文本)
|
||||
```
|
||||
|
||||
#### 10.3.2 与 §10.2 弹窗步骤条的差异
|
||||
|
||||
| 维度 | 弹窗步骤条 | 页面步骤条 |
|
||||
|------|-----------|-----------|
|
||||
| 完成态圆形 | 描边圆 + 蓝色对勾 | 实心蓝圆 + 白色对勾 |
|
||||
| 完成段连接线样式 | `1px dashed #1677FF` | `1px solid #1677FF` |
|
||||
| 标题文字号 | `14px Medium` | `14px Medium`(同) |
|
||||
| 第一项 | 通用「标题」占位 | 可显示具体名称(自定义文案) |
|
||||
|
||||
#### 10.3.3 完成态指示圆补充
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 已完成圆背景 | `#1677FF` | ZS-002-06 |
|
||||
| 已完成圆内对勾 | `#FFFFFF` | — |
|
||||
| 已完成圆边框 | 无(实心) | — |
|
||||
|
||||
### 10.4 纵向步骤条
|
||||
|
||||
用于侧栏 / 详情页内的纵向流程指引。两种变体——「仅标题」与「标题 + 描述」。
|
||||
|
||||
#### 10.4.1 布局
|
||||
|
||||
```
|
||||
仅标题: 标题 + 描述:
|
||||
|
||||
(✓) 新建集群 (✓) 新建集群
|
||||
┊ 描述文本描述
|
||||
(●2) 标题 ┊
|
||||
┊ (●2) 标题
|
||||
( 3 ) 标题 描述文本描述
|
||||
┊ ┊
|
||||
( 4 ) 标题 ( 3 ) 标题
|
||||
描述文本描述
|
||||
┊
|
||||
( 4 ) 标题
|
||||
描述文本描述
|
||||
```
|
||||
|
||||
#### 10.4.2 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 指示圆 → 标题水平间距 | `--spacing-2` (8px) |
|
||||
| 节点垂直间距(仅标题) | `--spacing-5` (24px),圆心到圆心 |
|
||||
| 节点垂直间距(标题 + 描述) | `--spacing-6` (32px),圆心到圆心 |
|
||||
| 标题 → 描述间距 | `--spacing-1` (4px) |
|
||||
| 连接线位置 | 上下两个指示圆**正下方垂直**,居中于圆心 |
|
||||
| 连接线样式 | `1px dashed`,已完成段 `#1677FF`,未完成段 `#4A6491` |
|
||||
| 文字左对齐 | 标题与描述左对齐,与指示圆右侧对齐基线 |
|
||||
|
||||
#### 10.4.3 与横向步骤条共用规则
|
||||
|
||||
- 指示圆三态规格沿用 §10.1
|
||||
- 已完成态默认用**描边 + 对勾**(与 §10.2 弹窗一致);若纵向步骤条用于页面级主流程,可切换为 §10.3 的实心圆变体
|
||||
|
||||
### 10.5 交互与动画
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 步骤切换(next) | 当前圆 `background: transparent → #1677FF`,`200ms ease-out`;同时上一步圆 `border-color: #4A6491 → #1677FF`,再用 `200ms` 切换为对勾图标淡入 |
|
||||
| 步骤切换(prev / 回退) | 反向,未完成态恢复 `#4A6491` 边框,圆内数字淡入 |
|
||||
| 连接线高亮 | 完成段 `border-color: #4A6491 → #1677FF`,`240ms ease-out` |
|
||||
| Hover 节点(可点击) | 圆边框色暂时变 `#4096FF` (ZS-002-05),标题文字 `#4096FF`,`120ms ease-out`;不可点击节点(未来步骤)无 hover |
|
||||
| 点击节点 | 节点必须**已完成**才能点(回看),否则视为禁用;点击合法节点触发 `step:change` 事件 |
|
||||
|
||||
### 10.6 状态机与可达性
|
||||
|
||||
| 当前步 = N | 节点 i 的状态 |
|
||||
|-----------|----------------|
|
||||
| `i < N` | Completed(已完成,可点回看) |
|
||||
| `i === N` | Current(当前,不可点) |
|
||||
| `i > N` | Upcoming(未开始,不可点) |
|
||||
| `i.disabled` | Disabled(被显式禁用,例如条件未满足) |
|
||||
|
||||
**键盘导航**:
|
||||
- `Tab` 顺序在「已完成」节点之间流转,跳过 `Current / Upcoming / Disabled`
|
||||
- 焦点节点圆外加 `2px solid #4096FF` 焦点环(`outline`,`offset 2px`)
|
||||
|
||||
**屏幕阅读器**:
|
||||
- 指示圆 `role="img"`,`aria-label="已完成第 N 步"` / `"当前第 N 步"` / `"未开始第 N 步"`
|
||||
- 容器 `role="list"`,节点 `role="listitem"`
|
||||
- 当前节点额外 `aria-current="step"`
|
||||
|
||||
### 10.7 CSS Token 参考
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* 步骤条节点 */
|
||||
--step-circle-size: 24px;
|
||||
--step-circle-current-bg: #1677FF; /* ZS-002-06 */
|
||||
--step-circle-current-text: #FFFFFF;
|
||||
--step-circle-done-border: #1677FF; /* ZS-002-06 */
|
||||
--step-circle-done-icon: #1677FF; /* 弹窗变体 */
|
||||
--step-circle-done-bg-page: #1677FF; /* 页面变体:实心 */
|
||||
--step-circle-done-icon-page: #FFFFFF;
|
||||
--step-circle-upcoming-border: #4A6491; /* ZS-004-05 */
|
||||
--step-circle-upcoming-text: #6E88B0; /* ZS-004-04 */
|
||||
--step-circle-disabled-border: #2D4473; /* ZS-004-06 */
|
||||
--step-circle-disabled-text: #4A6491; /* ZS-004-05 */
|
||||
|
||||
/* 连接线 */
|
||||
--step-line-done: #1677FF; /* 已完成段 */
|
||||
--step-line-upcoming: #4A6491; /* 未完成段:ZS-004-05 */
|
||||
|
||||
/* 文字 */
|
||||
--step-title-active: #FFFFFF;
|
||||
--step-title-inactive: #6E88B0; /* ZS-004-04 */
|
||||
--step-desc-active: #C5CFE0; /* ZS-004-02 */
|
||||
--step-desc-inactive: #6E88B0; /* ZS-004-04 */
|
||||
}
|
||||
```
|
||||
|
||||
### 10.8 三种步骤条的选用决策
|
||||
|
||||
| 场景 | 选择 |
|
||||
|------|------|
|
||||
| Modal / Drawer 内多步表单 | §10.2 弹窗步骤条(描边圆,紧凑) |
|
||||
| 页面级向导(独占大区域) | §10.3 页面步骤条(实心圆,视觉重) |
|
||||
| 侧栏 / 详情页纵向流程 | §10.4 纵向步骤条 |
|
||||
| 步骤数 ≤ 3 且无描述 | 优先「仅标题」变体 |
|
||||
| 步骤名抽象需补充说明 | 用「标题 + 描述」变体 |
|
||||
| 步骤数 > 7 | 不推荐用步骤条,改用「锚点」(§9.2)或分页 |
|
||||
|
||||
---
|
||||
|
||||
## 11. 面包屑
|
||||
|
||||
> 对应「4.3 导航组件-面包屑」。用于显示当前位置在整个站点层级中的路径,配合「← 返回」按钮支持逐级回溯。颜色取自 ZS-002 主色蓝与 ZS-004 深蓝系。
|
||||
|
||||
### 11.1 标准形态
|
||||
|
||||
容器顶部带一个独立的容器 / 边框包裹:
|
||||
|
||||
```
|
||||
🏠 | 概况 / 总概况
|
||||
```
|
||||
|
||||
带「返回」按钮的层级形态(一级到四级):
|
||||
|
||||
```
|
||||
一级: ← 返回 │ 现在位置
|
||||
二级: ← 返回 │ 上一级位置 / 现在位置
|
||||
三级: ← 返回 │ 上二级位置 / 上一级位置 / 现在位置
|
||||
四级: ← 返回 │ 上三级位置 / 上二级位置 / 上一级位置 / 现在位置
|
||||
```
|
||||
|
||||
### 11.2 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器高度 | `40px` |
|
||||
| 容器背景 | `#0C1836` (ZS-004-09) |
|
||||
| 容器底边 | `1px solid #1A2F5A` (ZS-004-07) |
|
||||
| 容器水平 padding | `--spacing-4` (16px) |
|
||||
| 字号 | `14px Regular` |
|
||||
| 元素间距(图标 / 文字 / 分隔符之间) | `--spacing-2` (8px) |
|
||||
| 「返回」与首段路径之间分隔符 `│` | `1px solid #4A6491`,高度 `14px` |
|
||||
|
||||
### 11.3 配色
|
||||
|
||||
| 角色 | 色值 | 来源 | 备注 |
|
||||
|------|------|------|------|
|
||||
| Home 图标 🏠 | `#4096FF` | ZS-002-05 | 默认主色,hover → `#1677FF` (ZS-002-06) |
|
||||
| 「← 返回」图标 + 文字 | `#4096FF` | ZS-002-05 | 链接样式,hover 显示下划线 |
|
||||
| 历史路径文字(可点击) | `#4096FF` | ZS-002-05 | 同链接配色 |
|
||||
| 当前位置文字(最后一段) | `#FFFFFF` | — | 加粗 `14px Medium`,不可点击 |
|
||||
| 分隔符 `/` | `#4A6491` | ZS-004-05 | 静态、不可点 |
|
||||
| 分隔符 `│`(返回按钮与路径之间) | `#4A6491` | ZS-004-05 | 同上 |
|
||||
| Hover 路径项 | `#1677FF` | ZS-002-06 | 文字色 + 下划线 |
|
||||
| 失效路径项(无对应页) | `#4A6491` | ZS-004-05 | `cursor: not-allowed` |
|
||||
|
||||
### 11.4 交互规则
|
||||
|
||||
- **点击「← 返回」**:逐步向上返回一级(等同浏览器 back)
|
||||
- **点击文字路径**:快速跳回到对应任意上级页面
|
||||
- **当前位置**(最后一段):不响应点击,仅作展示
|
||||
- **层级建议**:尽可能不超过 **4 级**;超过 4 级会让面包屑过长,应改用侧栏 / 锚点辅助
|
||||
|
||||
### 11.5 与导航的关系
|
||||
|
||||
面包屑**不替代**主导航(§8):
|
||||
|
||||
- 主导航 = 「我能去哪些地方」(站点结构)
|
||||
- 面包屑 = 「我当前在哪里」(路径回溯)
|
||||
|
||||
两者并存时,面包屑紧贴页面主内容区顶部,位于主导航下方、页头(§12)上方。
|
||||
|
||||
### 11.6 CSS 参考
|
||||
|
||||
```css
|
||||
.breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 40px;
|
||||
padding: 0 var(--spacing-4);
|
||||
background: #0C1836;
|
||||
border-bottom: 1px solid #1A2F5A;
|
||||
font-size: 14px;
|
||||
gap: var(--spacing-2);
|
||||
}
|
||||
.breadcrumb-back { color: #4096FF; cursor: pointer; }
|
||||
.breadcrumb-back:hover { color: #1677FF; text-decoration: underline; }
|
||||
.breadcrumb-sep-bar { width: 1px; height: 14px; background: #4A6491; }
|
||||
.breadcrumb-sep { color: #4A6491; }
|
||||
.breadcrumb-link { color: #4096FF; cursor: pointer; }
|
||||
.breadcrumb-link:hover { color: #1677FF; text-decoration: underline; }
|
||||
.breadcrumb-current { color: #FFFFFF; font-weight: 500; }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 12. 页头
|
||||
|
||||
> 对应「4.6 导航组件-分页」上半段示意。用于页面主内容区顶部、面包屑下方,承载页面标题与可选的说明 / Tabs。共有 4 种变体。
|
||||
|
||||
### 12.1 通用规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器高度 | `56px`(仅标题)/ `64px`(含 Tabs) |
|
||||
| 背景 | `#0C1836` (ZS-004-09) |
|
||||
| 底边 | `1px solid #1A2F5A` (ZS-004-07) |
|
||||
| 水平 padding | `--spacing-5` (24px) |
|
||||
| 文字基线 | 垂直居中 |
|
||||
|
||||
### 12.2 四种变体
|
||||
|
||||
#### 12.2.1 基础页头
|
||||
|
||||
只有标题:
|
||||
|
||||
```
|
||||
页头标题
|
||||
```
|
||||
|
||||
| 角色 | 色值 / 字号 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 标题 | `18px Bold`,`#FFFFFF` | — |
|
||||
|
||||
#### 12.2.2 页头 + 说明
|
||||
|
||||
标题后跟一段灰色说明文字:
|
||||
|
||||
```
|
||||
页头标题 (这是一句简要说明)
|
||||
```
|
||||
|
||||
| 角色 | 色值 / 字号 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 标题 | `18px Bold`,`#FFFFFF` | — |
|
||||
| 说明文字 | `14px Regular`,`#6E88B0` | ZS-004-04 |
|
||||
| 标题 → 说明间距 | `--spacing-3` (12px) | — |
|
||||
|
||||
说明用半角圆括号包裹,颜色与括号一致(不要让括号比文字更醒目)。
|
||||
|
||||
#### 12.2.3 页头 + 说明 icon
|
||||
|
||||
标题后跟一个可悬停查看说明的图标:
|
||||
|
||||
```
|
||||
页头标题 ⓘ
|
||||
```
|
||||
|
||||
| 角色 | 色值 / 字号 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 标题 | `18px Bold`,`#FFFFFF` | — |
|
||||
| 说明 icon `ⓘ` 或 `?` | `16px`,`#6E88B0` | ZS-004-04 |
|
||||
| Icon hover | `#4096FF` | ZS-002-05 |
|
||||
| 标题 → 图标间距 | `--spacing-2` (8px) | — |
|
||||
|
||||
Hover 弹出 Tooltip(沿用 §9.3.3 Tooltip 配色),承载完整说明文字。
|
||||
|
||||
#### 12.2.4 分 Tabs 页头
|
||||
|
||||
标题位置直接放横向页签(沿用 §9.1.1 横向页签配色),点击切换右侧主内容区:
|
||||
|
||||
```
|
||||
标题 标题 标题
|
||||
─────
|
||||
```
|
||||
|
||||
| 复用规则 | 说明 |
|
||||
|----------|------|
|
||||
| Tab 配色 | 完全沿用 §9.1.1 横向页签 |
|
||||
| Tab 字号 | `16px Medium`(页头位置比一般 tab 略大) |
|
||||
| Tab 间距 | `--spacing-5` (24px) |
|
||||
| 激活态下划线 | `2px solid #4096FF`,宽与文字齐 |
|
||||
|
||||
### 12.3 与右侧操作区的组合
|
||||
|
||||
页头右侧常承载主操作按钮(「+ 新建」、「导出」等)。规则:
|
||||
|
||||
- 按钮组靠右对齐,右 padding 与左 padding 一致 (`--spacing-5`)
|
||||
- 多按钮排列顺序参照 §5.3.4(默认按钮在左、主按钮在右),按钮间距 `--spacing-2`
|
||||
- Tabs 页头中右侧操作区与 Tabs 同高居中
|
||||
|
||||
---
|
||||
|
||||
## 13. 分页
|
||||
|
||||
> 对应「4.6 导航组件-分页」下半段。三种形态——**正常分页 / 精简分页 / 导航式分页**——按页面信息量与可用空间选用。
|
||||
|
||||
### 13.1 正常分页
|
||||
|
||||
承载大列表,提供页码、跳转、每页条数选择:
|
||||
|
||||
```
|
||||
共 240 项 < ① 2 3 4 5 … 24 > 每页 [10▾] 条 前往 [ ] 页
|
||||
```
|
||||
|
||||
#### 13.1.1 元素配色与规格
|
||||
|
||||
| 元素 | 字号 / 色值 | 来源 / 说明 |
|
||||
|------|-------------|-------------|
|
||||
| 「共 N 项」总数文字 | `14px Regular`,`#6E88B0` | ZS-004-04 |
|
||||
| 页码按钮(默认) | `14px Regular`,`#C5CFE0`,背景 `transparent` | ZS-004-02 |
|
||||
| 页码按钮(hover) | `#4096FF`,背景 `rgba(22,119,255,0.08)` | ZS-002-05 |
|
||||
| 页码按钮(激活/当前页) | `#FFFFFF`,背景 `#1677FF`(实心圆) | ZS-002-06 |
|
||||
| 页码按钮(失效) | `#4A6491`,背景 `transparent` | ZS-004-05 |
|
||||
| 左右翻页箭头 `<` `>` | `14px`,`#6E88B0`,hover → `#4096FF` | ZS-004-04 → ZS-002-05 |
|
||||
| 翻页箭头失效(首/末页) | `#4A6491` | ZS-004-05 |
|
||||
| 省略号 `…` | `#6E88B0` | ZS-004-04,静态展示,不可点 |
|
||||
| 每页条数下拉 `[10▾]` | 沿用 §14.1 输入框规格 | 高度 `28px`,宽 `60px` |
|
||||
| 「前往 N 页」输入框 | 沿用 §14.1 输入框规格 | 高度 `28px`,宽 `48px` |
|
||||
|
||||
#### 13.1.2 页码按钮规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 形状 | 圆形 `28px × 28px`(`border-radius: 50%`) |
|
||||
| 默认背景 | `transparent` |
|
||||
| 当前页背景 | `#1677FF` (ZS-002-06),实心圆,白色数字 |
|
||||
| 字号 | `14px Regular`(数字 D-DIN 或 Noto Sans) |
|
||||
| 项间距 | `--spacing-1` (4px) |
|
||||
|
||||
#### 13.1.3 元素间距
|
||||
|
||||
| 区段 | 间距 |
|
||||
|------|------|
|
||||
| 「共 N 项」→ 翻页区 | `--spacing-4` (16px) |
|
||||
| 翻页区内(箭头 / 页码) | `--spacing-1` (4px) |
|
||||
| 翻页区 → 每页下拉 | `--spacing-5` (24px) |
|
||||
| 每页下拉 → 前往输入 | `--spacing-4` (16px) |
|
||||
|
||||
### 13.2 精简分页
|
||||
|
||||
承载弹窗 / 表格紧凑场景,只暴露「当前页 / 总页数」与左右翻页:
|
||||
|
||||
```
|
||||
共 1 项 < [ 1 ] / 10 >
|
||||
```
|
||||
|
||||
#### 13.2.1 规格
|
||||
|
||||
| 元素 | 配色 / 备注 |
|
||||
|------|------------|
|
||||
| 「共 N 项」 | 同 §13.1.1 |
|
||||
| `<` `>` 翻页箭头 | 同 §13.1.1 |
|
||||
| `[ 1 ]` 当前页输入框 | 沿用 §14.1 输入框规格,高 `28px`,宽 `40px`,居中文字 |
|
||||
| `/ N` 总页数 | `14px Regular`,`#6E88B0` (ZS-004-04) |
|
||||
| 元素间距 | `--spacing-2` (8px) |
|
||||
|
||||
#### 13.2.2 与正常分页的差异
|
||||
|
||||
| 维度 | 正常分页 | 精简分页 |
|
||||
|------|----------|----------|
|
||||
| 页码 | 点击式数字列表 | 输入框 + 总页数文字 |
|
||||
| 跳转方式 | 点击数字 / 前往输入 | 直接修改输入框 |
|
||||
| 每页条数 | 暴露下拉 | 不暴露(默认值由调用方决定) |
|
||||
| 适用 | 列表 / 表格主内容区 | 弹窗、抽屉、卡片内嵌列表 |
|
||||
|
||||
### 13.3 导航式分页
|
||||
|
||||
承载长文 / 详情页的「上一篇 / 下一篇」式翻页,只有方向,不暴露页码:
|
||||
|
||||
```
|
||||
下一页 »
|
||||
« 上一页
|
||||
```
|
||||
|
||||
#### 13.3.1 规格
|
||||
|
||||
| 元素 | 配色 / 备注 |
|
||||
|------|------------|
|
||||
| 「下一页」/「上一页」文字 + 箭头 | `14px Regular`,`#4096FF` (ZS-002-05) |
|
||||
| Hover | `#1677FF` (ZS-002-06) + 下划线 |
|
||||
| 失效(首/末篇) | `#4A6491` (ZS-004-05),`cursor: not-allowed` |
|
||||
| 箭头位置 | `下一页 »`(箭头在后)/ `« 上一页`(箭头在前) |
|
||||
| 文字 → 箭头间距 | `--spacing-2` (8px) |
|
||||
| 两个按钮纵向排列时项间距 | `--spacing-3` (12px) |
|
||||
|
||||
### 13.4 三种分页的选用决策
|
||||
|
||||
| 场景 | 选择 |
|
||||
|------|------|
|
||||
| 后台列表 / 表格 | §13.1 正常分页 |
|
||||
| Modal / Drawer 内嵌列表 | §13.2 精简分页 |
|
||||
| 详情页前后翻 | §13.3 导航式分页 |
|
||||
| 列表少于 1 页(项数 ≤ pageSize) | **不显示**分页 |
|
||||
| 项数明确但页码可能很多(>50 页) | 用正常分页 + 隐藏中间页码(`...` 省略) |
|
||||
|
||||
---
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,573 @@
|
||||
# 深蓝色 UI 规范 · 04 图表(§35–§41)
|
||||
|
||||
> 《深蓝色 UI 规范》分册之一。基础令牌见 `00-基础-色彩字体间距.md`,可 import 的变量见 `tokens.css`,总目录与 §索引见 `README.md`。`§N` 编号全局唯一。
|
||||
|
||||
**本篇目录**:`35` 图表通用规范 · `36` 柱状图 · `37` 折线图 · `38` 甘特图 · `39` 环形图 · `40` 关系图/散点图 · `41` 图表色值
|
||||
|
||||
---
|
||||
|
||||
## 35. 图表通用规范(Chart 基础)
|
||||
|
||||
> 对应设计稿「8. 图表」系列(柱状图 / 折线图 / 甘特图)。本节先约定**所有图表共用**的容器、标题、坐标轴、网格、图例、Tooltip、配色与空状态;§36 起按图表类型补充各自细则。配色一律取自 §1.1.8 图表配色与 §1.1.5 深蓝系,不另造色。
|
||||
|
||||
### 35.1 图表容器
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 背景 | `#0C1836` (ZS-004-09),嵌入卡片时随 §22 卡片 `#122347` | §3.1 |
|
||||
| 圆角 | `4px` | §4.1 |
|
||||
| 内边距 | `--spacing-5` (24px) | §7.1 |
|
||||
| 多图并排间距 | `--spacing-6` (32px) | §7.1 |
|
||||
| 边框(可选) | `1px solid #1A2F5A` (ZS-004-07) | — |
|
||||
|
||||
### 35.2 图表标题
|
||||
|
||||
设计稿中标题统一为「**主色蓝竖条 ▌ + 文字**」的小标题样式。
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 左侧竖条 | `3px × 14px`,`#1677FF` (ZS-002-06),圆角 `1px` | §1.1.6 |
|
||||
| 竖条 → 文字间距 | `--spacing-2` (8px) | §7.1 |
|
||||
| 标题文字 | `16px Bold`,`#FFFFFF`(或 `#C5CFE0`) | §2.1.2 |
|
||||
| 标题 → 图表区间距 | `--spacing-4` (16px) | §7.1 |
|
||||
| 副标题 / 单位 | `12px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
|
||||
> 部分卡片标题不带竖条(如「标题(BW)」「数据采集XXX」),此时直接用 `16px Bold #C5CFE0`,与 §22 卡片标题一致。
|
||||
|
||||
### 35.3 坐标轴
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 轴线(X / Y 基线) | `1px solid #2D4473` (ZS-004-06) | §6.1 |
|
||||
| 刻度文字(轴标签) | `12px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 轴标题 / 类目名(如「类型」「2012」) | `12px Regular`,`#4096FF` (ZS-002-05) 或 `#6E88B0` | — |
|
||||
| 刻度线(tick) | 通常隐藏,仅留网格线 | — |
|
||||
| 轴名称单位 | `12px`,`#6E88B0`,置于轴末端 | — |
|
||||
|
||||
### 35.4 网格线(splitLine)
|
||||
|
||||
| 类型 | 色值 | 样式 | 使用场景 |
|
||||
|------|------|------|----------|
|
||||
| 主网格(默认) | `#2D4473` (ZS-004-06) | `1px dashed` | 柱状 / 折线的 Y 向参考线 |
|
||||
| 弱化网格 | `#1A2F5A` (ZS-004-07) | `1px dashed` | 密集图表、次要参考 |
|
||||
|
||||
> 深色背景下网格一律用**虚线**且低对比,避免抢戏;纵向类目方向通常不画网格。
|
||||
|
||||
### 35.5 图例(Legend)
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 位置 | 右上角(多数)或顶部居中 | — |
|
||||
| 色块(marker) | `10px` 方块 / 圆点,取系列色 | §1.1.8 |
|
||||
| 色块 → 文字间距 | `--spacing-1` (4px) | §7.1 |
|
||||
| 图例文字 | `12px Regular`,`#C5CFE0` (ZS-004-02) | — |
|
||||
| 项间距 | `--spacing-3` (12px) | §7.1 |
|
||||
| 未选中态(点击隐藏系列) | 色块 + 文字置灰 `#4A6491` (ZS-004-05) | §1.1.5 |
|
||||
|
||||
### 35.6 Tooltip(悬浮提示)
|
||||
|
||||
鼠标悬停时跟随的浮层(如折线图「1月10日 异常率12.9%」、「5.32」)。
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 背景 | `rgba(12,24,54,0.92)`(ZS-004-09 92%) | §3.1 |
|
||||
| 边框 | `1px solid #1A2F5A` (ZS-004-07) | — |
|
||||
| 圆角 | `4px` | §4.1 |
|
||||
| 阴影 | `0 4px 16px rgba(6,14,36,0.6)` | §3.1.4 |
|
||||
| 内边距 | 上下 `--spacing-2`,左右 `--spacing-3` | §7.1 |
|
||||
| 标题行(日期 / 类目) | `12px Medium`,`#FFFFFF` | — |
|
||||
| 数值行 | `12px Regular`,色块(系列色)+ 名称 `#6E88B0` + 数值 `#C5CFE0` | — |
|
||||
| 指示线(axisPointer) | `1px dashed #4096FF` (ZS-002-05),或半透明竖向高亮带 `rgba(22,119,255,0.12)` | §6.1 |
|
||||
|
||||
> 设计稿中数据点 hover 常显示一个**实心小标签**(如圆点 + 数值 `5.32`):标签背景 `#122347`,文字 `#FFFFFF`,圆点取系列色,圆角 `2px`。
|
||||
|
||||
### 35.7 数据点与标记
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 折线拐点(默认) | 不显示或 `2px` 实心点 | — |
|
||||
| 折线拐点(hover / 强调) | `空心圆`,描边 `2px` 系列色,填充 `#0C1836`,直径 `6px` | — |
|
||||
| 高亮竖带(选中区间) | `rgba(22,119,255,0.12)` 矩形,无边框 | §3.1 |
|
||||
|
||||
### 35.8 图表配色引用
|
||||
|
||||
| 用途 | 色序 | 来源 |
|
||||
|------|------|------|
|
||||
| 多系列(面积大:柱 / 折线 / 饼) | `#1677FF → #13C2C2 → #4096FF → #36CFC9 → #69B1FF → #5CDBD3 → #91CAFF → #87E8DE` | §1.1.8 通用图表色序 |
|
||||
| 小面积(散点 / 迷你图 / 徽标) | `#4096FF → #36CFC9 → #FF4D4F → #FFA39E → #6388FF → #478880` | §1.1.8 小面积色序 |
|
||||
| 语义系列(成功 / 警告 / 错误) | 绿 `--func-success` / 橙 `--func-warning` / 红 `#F5222D` | §27.4 / §1.1.2 |
|
||||
|
||||
> 设计稿柱状图出现的「绿(Paper) / 橙(Project) / 蓝(Book)」三系列,对应**语义化分类**:绿取 §27.4 成功绿、橙取 §27.4 警告橙、蓝取主色 `#1677FF`;若为无语义的并列分类,应改用通用图表色序避免误读。
|
||||
|
||||
### 35.9 空状态 / 加载
|
||||
|
||||
| 状态 | 表现 |
|
||||
|------|------|
|
||||
| 加载中 | 图表区居中显示旋转图标 `#4096FF` + 文字「加载中…」`12px #6E88B0`(沿用 §5.4.2) |
|
||||
| 无数据 | 居中占位插画 / 文字「暂无数据」`14px #6E88B0` |
|
||||
|
||||
---
|
||||
|
||||
## 36. 柱状图(Column / Bar)
|
||||
|
||||
> 对应设计稿「8.1 图表-柱状图」。涵盖**堆叠柱 / 分组柱 / 条形图(横向)/ 排行进度条**四种形态。容器、坐标轴、网格、图例、Tooltip 全部沿用 §35。
|
||||
|
||||
### 36.1 通用规格
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 柱体圆角 | 顶部 `2px`(堆叠柱仅最顶段圆角) | §4.1 |
|
||||
| 柱宽 | 类目宽度的 `40%~60%` | — |
|
||||
| 同组柱间距 | `--spacing-1` (4px) | §7.1 |
|
||||
| 类目(组)间距 | 自适应等分 | — |
|
||||
| 数值标签(可选) | `12px Regular`,`#C5CFE0`,置柱顶上方 `--spacing-1` | — |
|
||||
|
||||
### 36.2 堆叠柱状图(如「标题」Paper/Project/Book)
|
||||
|
||||
| 元素 | 配色 | 来源 |
|
||||
|------|------|------|
|
||||
| 系列 1(Book / 底段) | `#69B1FF` (ZS-002-04) 或主色 `#1677FF` | §1.1.3 |
|
||||
| 系列 2(Project / 中段) | `--func-warning`(橙) | §27.4 |
|
||||
| 系列 3(Paper / 顶段) | `--func-success`(绿) | §27.4 |
|
||||
| 段间分隔 | `1px` 容器底色 `#0C1836` 描边,制造堆叠缝隙 | — |
|
||||
| Y 轴类目标签「类型」 | `12px`,`#4096FF` (ZS-002-05) | §35.3 |
|
||||
|
||||
### 36.3 分组柱状图(如「标题(BW)」「标题」双系列)
|
||||
|
||||
| 元素 | 配色 | 来源 |
|
||||
|------|------|------|
|
||||
| 系列依次取色 | 通用图表色序 `#1677FF / #13C2C2 / #4096FF …` | §1.1.8 |
|
||||
| 设计稿 BW 三色变体 | 蓝 `#69B1FF` / 绿 `--func-success` / 橙 `--func-warning` | §35.8 |
|
||||
| 双系列变体 | 蓝 `#69B1FF`(ZS-002-04) + 橙 `--func-warning` | — |
|
||||
|
||||
### 36.4 条形图(横向,如「标题」x 轴 0–400)
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 方向 | 水平,类目在 Y 轴、数值在 X 轴 | — |
|
||||
| 条体颜色 | `#69B1FF` (ZS-002-04)(单系列)或图表色序 | §1.1.3 |
|
||||
| 条体圆角 | 右端 `2px` | §4.1 |
|
||||
| 类目标签「类型」 | 左对齐,`12px #6E88B0` | §35.3 |
|
||||
| X 轴刻度 | `0 / 100 / 200 / 300 / 400`,`12px #6E88B0` | §35.3 |
|
||||
|
||||
### 36.5 排行进度条(如「数据采集XXX」TOP1–5)
|
||||
|
||||
横向「标签 + 渐变进度条 + 数值」的榜单形态。
|
||||
|
||||
```
|
||||
TOP1 项目任务名称一 15,465
|
||||
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■▓▓▓▓▓▓▓▓
|
||||
TOP2 项目任务名称二 15,234
|
||||
■■■■■■■■■■■■■■■■■■■■■■■■■▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
|
||||
```
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 排名 + 名称(TOPn 项目任务名称) | `14px Regular`,`#C5CFE0` (ZS-004-02) | — |
|
||||
| 数值(右对齐) | `16px D-DIN Regular`,`#FFFFFF` | §2.1.2 |
|
||||
| 进度条高度 | `8px`,圆角 `4px` | §4.1 |
|
||||
| 进度填充 | 渐变 `linear-gradient(90deg, #1677FF 0%, #13C2C2 100%)`(主色蓝→主色青) | §1.1.8 |
|
||||
| 进度轨道(底槽) | `#1A2F5A` (ZS-004-07) | §1.1.5 |
|
||||
| 行间距 | `--spacing-4` (16px) | §7.1 |
|
||||
| 名称行 → 进度条间距 | `--spacing-2` (8px) | §7.1 |
|
||||
|
||||
### 36.6 交互
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 入场 | 柱体由 `0` 向目标高度 / 长度增长,`scaleY/scaleX 0→1`,`400ms ease-out`,按系列依次 `60ms` 错峰 |
|
||||
| Hover 柱 | 该柱亮度 `+8%`,弹出 §35.6 Tooltip,axisPointer 高亮该类目竖带 |
|
||||
| Hover 进度条 | 数值放大或显示绝对值 Tooltip |
|
||||
|
||||
---
|
||||
|
||||
## 37. 折线图(Line / Area)
|
||||
|
||||
> 对应设计稿「8.2 图表-折线图」与「8.3 多系列折线」。涵盖**迷你面积图 / 单线(含异常点 Tooltip)/ 长时序面积图(带缩略轴)/ 多系列折线**。容器、轴、网格、图例、Tooltip 沿用 §35。
|
||||
|
||||
### 37.1 线条与面积
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 线宽 | `2px` | — |
|
||||
| 线条颜色 | 取图表色序,单线默认 `#1677FF` (ZS-002-06) | §1.1.8 |
|
||||
| 平滑 | `smooth`(曲线)或折线,按数据性质选用 | — |
|
||||
| 面积填充(单线) | 自顶向下渐变 `rgba(22,119,255,0.32) → rgba(22,119,255,0)` | §3.1 |
|
||||
| 拐点 | 默认隐藏,hover 显示空心圆(§35.7) | — |
|
||||
|
||||
### 37.2 迷你面积图(如左上「图表标题」+ 已选/未选 标签)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 顶部切换标签(已选 / 未选) | §29 标签:选中 `#1677FF` 实心白字 / 未选 `transparent` + `1px #6E88B0` 边、`#6E88B0` 字 | §29 |
|
||||
| 线条 | `2px #4096FF` (ZS-002-05) | — |
|
||||
| 面积渐变 | `rgba(64,150,255,0.32) → 0` | — |
|
||||
| 当前值标签(如 `59.32`) | 实心小牌 `#122347` 背景 / `#FFFFFF` 文字,圆角 `2px`,定位于末端点 | §35.6 |
|
||||
| 轴标签(日期) | `12px #6E88B0` | §35.3 |
|
||||
|
||||
### 37.3 单线异常点图(如中部「5-1…5-12」+「1月10日 异常率12.9%」)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 主线 | `2px #1677FF` | — |
|
||||
| 面积渐变 | `rgba(22,119,255,0.32) → 0` | — |
|
||||
| 选中竖带 | `rgba(22,119,255,0.12)` 矩形高亮当前 X 区间 | §35.7 |
|
||||
| 异常点标记 | 空心圆 `6px`,描边 `#FAAD14`(警告橙),填充 `#0C1836` | §27.4 |
|
||||
| Tooltip(日期 + 指标) | §35.6;指标行如「异常率 12.9%」用 `--func-warning` 橙强调 | §35.6 |
|
||||
| Y 轴(0–2500) | `12px #6E88B0`,虚线网格 `#2D4473` | §35.3 / §35.4 |
|
||||
|
||||
### 37.4 长时序面积图 + 缩略轴(如底部「图表标题」1986–2024)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 主线 | `2px #36CFC9`(标准青)或 `#4096FF` | §1.1.4 |
|
||||
| 面积渐变 | `rgba(54,207,201,0.24) → 0` | — |
|
||||
| 数据点标签(如 `2.43`) | 实心小牌(§35.6),定位于选中点上方 | — |
|
||||
| 缩略轴(dataZoom,右下迷你图) | 缩略折线 `#4A6491`;滑窗手柄 `#1677FF`,选中区 `rgba(22,119,255,0.16)` | §1.1.5 / §1.1.6 |
|
||||
| X 轴年份 | `12px #6E88B0`,密集时隔项显示 | §35.3 |
|
||||
|
||||
### 37.5 多系列折线图(如「图表标题」XXX/XXX/都是/无反应)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 图例(顶部居中) | 方块 marker + 文字,项间距 `--spacing-3` | §35.5 |
|
||||
| 系列 1(XXX) | 红 `#FF4D4F` (ZS-001-05) | §1.1.2 |
|
||||
| 系列 2(XXX) | 蓝 `#1677FF` (ZS-002-06) | §1.1.3 |
|
||||
| 系列 3(都是) | 橙 `--func-warning` | §27.4 |
|
||||
| 系列 4(无反应) | 绿 `--func-success` 或青 `#36CFC9` | §27.4 / §1.1.4 |
|
||||
| 线宽 | `2px`,多系列**不填充面积**(避免互相遮挡) | — |
|
||||
| 拐点 | 全程显示 `4px` 空心圆(描边系列色,填充 `#0C1836`) | §35.7 |
|
||||
| 选中竖带 + Tooltip | hover 竖带 `rgba(22,119,255,0.12)`,Tooltip 列出各系列值(如 `5.32`) | §35.6 |
|
||||
| Y 轴(0–10) / X 轴(年份) | `12px #6E88B0`,横向虚线网格 `#2D4473` | §35.3 / §35.4 |
|
||||
|
||||
### 37.6 交互
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 入场 | 线条沿路径绘制 `stroke-dashoffset` 动画,`600ms ease-out`;面积同步淡入 |
|
||||
| Hover | 显示 §35.6 Tooltip + 竖向 axisPointer 高亮带;对应拐点放大为空心圆 |
|
||||
| 图例点击 | 切换系列显隐,隐藏态图例置灰 `#4A6491`(§35.5) |
|
||||
| 缩略轴拖拽 | 主图 X 轴范围实时联动,`100ms` 节流 |
|
||||
|
||||
---
|
||||
|
||||
## 38. 甘特图(Gantt)
|
||||
|
||||
> 对应设计稿「甘特图」。以时间为横轴、任务行为纵轴的进度条排期图。深蓝背景上以**交替行底纹 + 渐变任务条 + 箭头收尾**呈现,配色取 §1.1.8 图表色序与语义色。
|
||||
|
||||
### 38.1 结构
|
||||
|
||||
```
|
||||
1 2 3 … 15 16 17 … 31 ← 时间刻度表头
|
||||
Jan ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▶ ← 任务条(带箭头收尾)
|
||||
Feb ▐▓▓▓▓▓▓▓▓▓▶
|
||||
Mar ▐▓▓▓▓▓▓▓▶
|
||||
…
|
||||
Dec ▐▓▓▓▓▓▓▓▓▓▓▓▶
|
||||
● Lorem ipsum 1 ● Lorem ipsum 2 … ← 底部图例
|
||||
```
|
||||
|
||||
### 38.2 表格框架
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 容器背景 | `#0C1836` (ZS-004-09) | §35.1 |
|
||||
| 时间刻度表头(1–31 / 月) | `12px Regular`,`#C5CFE0` (ZS-004-02) | §35.3 |
|
||||
| 行标签(Jan…Dec) | `14px Regular`,`#C5CFE0` | — |
|
||||
| 行高 | `28px`,行间距 `--spacing-1` (4px) | §7.1 |
|
||||
| 行底纹(轨道) | `#122347` (ZS-004-08),整行通栏,圆角 `2px` | §1.1.5 |
|
||||
| 行底纹(隔行可选) | 奇偶交替 `#122347` / `#0F1C3D` | — |
|
||||
| 列分隔(可选) | `1px dashed #1A2F5A` (ZS-004-07) | §6.2 |
|
||||
|
||||
### 38.3 任务条
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 条高 | `16px`,垂直居中于行内 | — |
|
||||
| 圆角 | `2px`(左端);右端收**箭头**三角表示方向 | §4.1 |
|
||||
| 填充 | 沿条向右渐变(系列色 `0%` → 同色 70% 透明 `100%`),叠加斜纹/点纹理增强层次 | §1.1.8 |
|
||||
| 纹理 | `repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 4px, transparent 4px 8px)` | — |
|
||||
| 箭头收尾 | 与条同色实心三角,`6px`,指向时间推进方向 | — |
|
||||
| 进度(可选) | 条内再叠一段高饱和系列色表示完成比例 | — |
|
||||
|
||||
### 38.4 任务分类配色(对应底部图例 Lorem ipsum 1–5)
|
||||
|
||||
| 图例 | 圆点 / 任务条主色 | 来源 |
|
||||
|------|------------------|------|
|
||||
| Lorem ipsum 1 | 橙 `--func-warning` | §27.4 |
|
||||
| Lorem ipsum 2 | 红 `#FF4D4F` (ZS-001-05) | §1.1.2 |
|
||||
| Lorem ipsum 3 | 青绿 `#36CFC9` (ZS-003-05) | §1.1.4 |
|
||||
| Lorem ipsum 4 | 浅蓝 `#91CAFF` (ZS-002-03) | §1.1.3 |
|
||||
| Lorem ipsum 5 | 主色蓝 `#1677FF` (ZS-002-06) | §1.1.3 |
|
||||
|
||||
### 38.5 图例与表头
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 底部图例圆点 | `10px` 圆形,取 §38.4 分类色 | §35.5 |
|
||||
| 图例文字 | `14px Regular`,`#C5CFE0` | — |
|
||||
| 图例项间距 | `--spacing-5` (24px) | §7.1 |
|
||||
| 表头 → 首行间距 | `--spacing-3` (12px) | §7.1 |
|
||||
|
||||
### 38.6 交互
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 入场 | 任务条由左端起点向右展开 `scaleX 0→1`(`transform-origin:left`),`400ms ease-out`,按行错峰 `60ms` |
|
||||
| Hover 任务条 | 整条亮度 `+8%`,弹出 §35.6 Tooltip(任务名 / 起止日期 / 进度) |
|
||||
| Hover 行 | 行底纹由 `#122347` → `#1A2F5A` (ZS-004-07) |
|
||||
| 今日线(可选) | 一条 `1px dashed #4096FF` (ZS-002-05) 竖线标注当前日期 | §6.2 |
|
||||
|
||||
### 38.7 CSS Token 参考(§35–§38 共用)
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* 图表容器与标题 */
|
||||
--chart-bg: #0C1836; /* ZS-004-09 */
|
||||
--chart-title-bar: #1677FF; /* ZS-002-06 标题竖条 */
|
||||
--chart-title-text: #FFFFFF;
|
||||
--chart-subtitle: #6E88B0; /* ZS-004-04 */
|
||||
|
||||
/* 坐标轴与网格 */
|
||||
--chart-axis-line: #2D4473; /* ZS-004-06 */
|
||||
--chart-axis-label: #6E88B0; /* ZS-004-04 */
|
||||
--chart-axis-cat: #4096FF; /* ZS-002-05 类目名 */
|
||||
--chart-grid: #2D4473; /* ZS-004-06 虚线网格 */
|
||||
--chart-grid-weak: #1A2F5A; /* ZS-004-07 */
|
||||
|
||||
/* 图例 / Tooltip */
|
||||
--chart-legend-text: #C5CFE0; /* ZS-004-02 */
|
||||
--chart-legend-off: #4A6491; /* ZS-004-05 未选中 */
|
||||
--chart-tooltip-bg: rgba(12,24,54,0.92);
|
||||
--chart-tooltip-border:#1A2F5A; /* ZS-004-07 */
|
||||
--chart-tooltip-title: #FFFFFF;
|
||||
--chart-tooltip-value: #C5CFE0;
|
||||
--chart-axispointer: #4096FF; /* ZS-002-05 */
|
||||
--chart-highlight-band:rgba(22,119,255,0.12);
|
||||
|
||||
/* 通用图表色序(面积大) */
|
||||
--chart-c1: #1677FF; --chart-c2: #13C2C2; --chart-c3: #4096FF; --chart-c4: #36CFC9;
|
||||
--chart-c5: #69B1FF; --chart-c6: #5CDBD3; --chart-c7: #91CAFF; --chart-c8: #87E8DE;
|
||||
|
||||
/* 小面积图表色序 */
|
||||
--chart-s1: #4096FF; --chart-s2: #36CFC9; --chart-s3: #FF4D4F;
|
||||
--chart-s4: #FFA39E; --chart-s5: #6388FF; --chart-s6: #478880;
|
||||
|
||||
/* 排行进度条(§36.5) */
|
||||
--rank-bar-fill: linear-gradient(90deg, #1677FF 0%, #13C2C2 100%);
|
||||
--rank-bar-track: #1A2F5A; /* ZS-004-07 */
|
||||
--rank-value: #FFFFFF;
|
||||
|
||||
/* 甘特图(§38) */
|
||||
--gantt-track: #122347; /* ZS-004-08 行底纹 */
|
||||
--gantt-row-hover: #1A2F5A; /* ZS-004-07 */
|
||||
--gantt-c1: #FAAD14; /* 警告橙 */
|
||||
--gantt-c2: #FF4D4F; /* ZS-001-05 */
|
||||
--gantt-c3: #36CFC9; /* ZS-003-05 */
|
||||
--gantt-c4: #91CAFF; /* ZS-002-03 */
|
||||
--gantt-c5: #1677FF; /* ZS-002-06 */
|
||||
--gantt-today: #4096FF; /* ZS-002-05 今日线 */
|
||||
}
|
||||
```
|
||||
|
||||
> 项目当前未引入图表库;若后续接入 ECharts,可将以上 token 注入主题(`backgroundColor` / `axisLine.lineStyle.color` / `splitLine.lineStyle` / `color[]` 色序 / `tooltip.backgroundColor` 等),保持与本规范一致。
|
||||
>
|
||||
> **关于多系列填充色**:§36–§38 表格中标注的系列色用于说明语义映射;**实际多系列图表的系列填充色一律以 §41 图表色值(设计稿 8.7)为准**——即淡色系 `#FA9196 / #FFCC80 / #97EBCD / #A2E1F9 / #80BCFF …`,按系列数量取对应色序。§1.1.8 的高彩度色序仅用于需要强对比的强调场景(如单色进度条渐变、KPI 高亮)。
|
||||
|
||||
---
|
||||
|
||||
## 39. 环形图(Donut / Ring)
|
||||
|
||||
> 对应设计稿「8.3 图表-环形图」。中心带总量数字的占比环图,按分类数量分**三环 / 四环 / 五环 / 六环 / 七环 / 八环**等变体。环段配色取 §41 图表色值(淡色系列),中心总量与引导标签取深蓝系字体色。
|
||||
|
||||
### 39.1 结构
|
||||
|
||||
```
|
||||
三环 / 四环 …(标题)
|
||||
╭──────────╮
|
||||
Media│ │Social
|
||||
28% │ 34801 │ 36%
|
||||
│ XXX总量 │
|
||||
╰──────────╯
|
||||
News 28%
|
||||
```
|
||||
|
||||
### 39.2 环体规格
|
||||
|
||||
| 属性 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 外径 | 容器短边的 `60%~70%` | — |
|
||||
| 内径(中空比) | 外径的 `62%`(环宽约 `38%`) | — |
|
||||
| 环段间隙 | `2px`(用容器底色 `#0C1836` 描边分隔) | §35.1 |
|
||||
| 环段圆角 | `2px`(段端微圆角,可选) | §4.1 |
|
||||
| 环段配色 | 按分类数取 §41 对应「N 色」色序 | §41 |
|
||||
| 起始角 / 方向 | 顶部 `90°` 起,顺时针 | — |
|
||||
|
||||
### 39.3 中心与标签
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 中心主数值(如 `34801`) | `26px Bold D-DIN`,`#FFFFFF` | §2.1.2 |
|
||||
| 中心说明(如 `XXX总量`) | `12px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 引导标签名(如 `Social`) | `12px Regular`,`#C5CFE0` (ZS-004-02) | — |
|
||||
| 引导标签占比(如 `36%`) | `12px Regular`,`#FFFFFF` 或对应环段色 | — |
|
||||
| 引导线 | `1px solid #4A6491` (ZS-004-05) 折线,从环段引至外侧标签 | §6.1 |
|
||||
| 变体标题(三环 / 四环…) | `14px Medium`,`#C5CFE0`,居中于图上方 | §35.2 |
|
||||
|
||||
### 39.4 交互
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 入场 | 环段沿顺时针扫出 `0°→终值`,`600ms ease-out`,按段错峰 `60ms` |
|
||||
| Hover 环段 | 该段沿半径外扩 `4px`(`offset`),中心数值切换为该段值 + 占比,弹出 §35.6 Tooltip |
|
||||
| 图例点击 | 切换分类显隐,其余环段占比按比例重算 |
|
||||
|
||||
---
|
||||
|
||||
## 40. 关系图 / 散点图(Network / Scatter)
|
||||
|
||||
> 对应设计稿「8.6 图表-散点图」「关系图」。用于展示账号、节点间关系的力导向网络图与散点分布。深蓝背景上以**发光节点 + 渐隐连线 + 平台聚类**呈现,节点配色取主色蓝 / 警告橙 / 危险红做分类,节点尺寸映射权重。
|
||||
|
||||
### 40.1 节点(Node)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 形状 | 圆形(普通节点)/ 头像圆(账号节点,`2px` 描边)/ 六边形(聚合节点) | — |
|
||||
| 直径 | `8px ~ 40px`,按权重(连接数 / 数值)线性映射 | — |
|
||||
| 分类色 A(本方 / 主) | `#1677FF` (ZS-002-06) | §1.1.3 |
|
||||
| 分类色 B(异常 / 外部) | `--func-warning`(橙) | §27.4 |
|
||||
| 分类色 C(高危 / 标红) | `#FF4D4F` (ZS-001-05) | §1.1.2 |
|
||||
| 节点发光(重点节点) | `0 0 12px` 同色 40% 透明外发光 | §3.1 |
|
||||
| 节点文字(数值 / 名称) | `12px Regular`,`#FFFFFF`(节点内)/ `#C5CFE0`(节点外) | — |
|
||||
| 中心 / 焦点节点 | 加大直径 + 强发光,橙色 `--func-warning` 高亮 | — |
|
||||
|
||||
### 40.2 连线(Edge)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 线宽 | `1px`(普通)/ `2px`(强关系) | — |
|
||||
| 颜色 | `#4A6491` (ZS-004-05) 半透明,或取**起点节点分类色** 40% 透明 | §1.1.5 |
|
||||
| 渐隐 | 由中心向外渐隐(`opacity 0.6 → 0.15`),弱化边缘视觉噪声 | — |
|
||||
| 方向(有向) | 末端箭头 `4px`,同线色 | — |
|
||||
| 高亮态(hover 节点时) | 关联边升为节点分类色满饱和、`2px`,无关边降至 `opacity 0.08` | — |
|
||||
|
||||
### 40.3 散点图(Scatter,纯坐标分布)
|
||||
|
||||
| 元素 | 规格 / 配色 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 散点 | 实心圆 `6px ~ 16px`(尺寸可映射第三维) | — |
|
||||
| 配色 | 小面积色序(§41 或 §1.1.8 小面积),分类着色 | §41 |
|
||||
| 坐标轴 / 网格 | 沿用 §35.3 / §35.4 | §35 |
|
||||
| 气泡变体 | 半透明填充 `35%` + `1px` 同色描边,避免重叠遮挡 | — |
|
||||
|
||||
### 40.4 平台聚类与图例(如 Facebook / Twitter / 微博 / TikTok)
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 聚类标签 | 平台名 `14px Medium`,对应聚类主色(如蓝 / 橙 / 红) | — |
|
||||
| 聚类辅文 | 数值 `12px Regular`,`#6E88B0` | — |
|
||||
| 图例(XXX / XXX) | 方块 marker + 文字,置右下角 | §35.5 |
|
||||
| 更新提示(如「近30分钟更新数据」) | `12px Regular`,`#6E88B0`,右下角 | — |
|
||||
|
||||
### 40.5 控制区(关系图侧栏)
|
||||
|
||||
设计稿左侧含「选择目标」下拉 + 分类勾选列表(主页发帖 / 群组发帖 / 私信 / 点赞 / 转发 / 帖子评论 / Pages内容 / 目标的主页帖子)+「添加账号 / 全选账号」按钮。
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 「选择目标」下拉 | 沿用 §15 选择器 | §15 |
|
||||
| 分类列表项 | `14px Regular`,前缀分类色圆点 `8px`,沿用 §16 多选 | §16 |
|
||||
| 「添加账号」 | §5.2.2 默认按钮(含 `+` 图标) | §5.3.2 |
|
||||
| 「全选账号」 | §5.2.3 文本按钮 | §5.2.3 |
|
||||
| 刷新图标(右上 ⟳) | `16px`,`#6E88B0`,hover `#4096FF` | §8.2.5 |
|
||||
|
||||
### 40.6 交互
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 力导向布局 | 节点入场后力导向收敛,`tick` 动画 `~800ms` 后静止 |
|
||||
| Hover 节点 | 高亮关联边与邻接节点(§40.2),其余降透明;弹出 §35.6 Tooltip(节点名 / 类型 / 指标) |
|
||||
| 点击节点 | 居中聚焦该节点并展开其一度关系;可下钻 |
|
||||
| 缩放 / 平移 | 滚轮缩放 `0.5×~3×`,拖拽平移画布 |
|
||||
| 拖拽节点 | 可手动拖拽固定节点位置 |
|
||||
|
||||
---
|
||||
|
||||
## 41. 图表色值(Chart Palette · 多系列色序)
|
||||
|
||||
> 对应设计稿「8.7 图表-色值」。这是**全站图表多系列填充的权威色序**(淡色系,深蓝背景上柔和、区分度高)。按系列数量从「三色」到「十色」各有固定取色顺序——系列数为 N 时直接取「N 色」整行,**不要自行截取或乱序**。如需超过十色或特殊场景,由 UI 设计师按整体风格补充。
|
||||
|
||||
### 41.1 基础色板
|
||||
|
||||
| 色名 | 色值 | 色相 |
|
||||
|------|------|------|
|
||||
| 粉红 | `#FA9196` | 红 |
|
||||
| 橙红 | `#FCA58F` | 橙红 |
|
||||
| 橙 | `#FDB887` | 橙 |
|
||||
| 浅橙 | `#FFCC80` | 黄橙 |
|
||||
| 黄绿 | `#DCD69A` | 黄绿 |
|
||||
| 浅绿 | `#BAE1B3` | 绿 |
|
||||
| 青绿 | `#97EBCD` | 青绿 |
|
||||
| 浅青 | `#9EE4EA` | 青 |
|
||||
| 浅蓝 | `#A2E1F9` | 天蓝 |
|
||||
| 蓝 | `#80BCFF` | 蓝 |
|
||||
|
||||
### 41.2 按系列数取色序
|
||||
|
||||
| 系列数 | 取色顺序 |
|
||||
|--------|----------|
|
||||
| 三色 | `#FA9196` · `#97EBCD` · `#80BCFF` |
|
||||
| 四色 | `#FA9196` · `#FFCC80` · `#97EBCD` · `#A2E1F9` |
|
||||
| 五色 | `#FA9196` · `#FFCC80` · `#97EBCD` · `#A2E1F9` · `#80BCFF` |
|
||||
| 六色 | `#FA9196` · `#FFCC80` · `#BAE1B3` · `#97EBCD` · `#A2E1F9` · `#80BCFF` |
|
||||
| 七色 | `#FA9196` · `#FCA58F` · `#FFCC80` · `#BAE1B3` · `#97EBCD` · `#A2E1F9` · `#80BCFF` |
|
||||
| 八色 | `#FA9196` · `#FCA58F` · `#FDB887` · `#FFCC80` · `#BAE1B3` · `#97EBCD` · `#A2E1F9` · `#80BCFF` |
|
||||
| 九色 | `#FA9196` · `#FCA58F` · `#FDB887` · `#FFCC80` · `#DCD69A` · `#BAE1B3` · `#97EBCD` · `#A2E1F9` · `#80BCFF` |
|
||||
| 十色 | `#FA9196` · `#FCA58F` · `#FDB887` · `#FFCC80` · `#DCD69A` · `#BAE1B3` · `#97EBCD` · `#9EE4EA` · `#A2E1F9` · `#80BCFF` |
|
||||
|
||||
> 规律:色序整体沿「红 → 橙 → 黄绿 → 绿 → 青 → 蓝」色相环渐变铺开;系列数增加时在中间插入过渡色,**首色恒为 `#FA9196`、末色恒为 `#80BCFF`**,保证冷暖两端锚定不变。
|
||||
|
||||
### 41.3 与既有规范的关系
|
||||
|
||||
| 色序 | 用途 | 来源 |
|
||||
|------|------|------|
|
||||
| §41 淡色系列(本节) | 图表**多系列填充**(柱 / 折线 / 环形 / 散点分类)默认色序 | 设计稿 8.7 |
|
||||
| §1.1.8 通用图表色序(高彩度) | 强对比强调:单色渐变进度条、KPI 高亮、需要醒目的单系列 | §1.1.8 |
|
||||
| §27.4 / §1.1.2 语义色 | 带语义的系列(成功 / 警告 / 错误 / 信息) | §27.4 |
|
||||
|
||||
> 三者优先级:**有语义 → 用语义色;多分类并列 → 用 §41;需强调单值 → 用 §1.1.8 高彩度**。§36–§40 中标注的具体系列色为语义示例,实际并列分类应回落到本节色序。
|
||||
|
||||
### 41.4 CSS Token 参考
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* §41 图表多系列色板(淡色系,设计稿 8.7) */
|
||||
--chart-p-red: #FA9196;
|
||||
--chart-p-redorange:#FCA58F;
|
||||
--chart-p-orange: #FDB887;
|
||||
--chart-p-amber: #FFCC80;
|
||||
--chart-p-olive: #DCD69A;
|
||||
--chart-p-green: #BAE1B3;
|
||||
--chart-p-teal: #97EBCD;
|
||||
--chart-p-cyan: #9EE4EA;
|
||||
--chart-p-skyblue: #A2E1F9;
|
||||
--chart-p-blue: #80BCFF;
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// 按系列数取色序(接入 ECharts 时用作 option.color)
|
||||
export const CHART_PALETTES = {
|
||||
3: ['#FA9196', '#97EBCD', '#80BCFF'],
|
||||
4: ['#FA9196', '#FFCC80', '#97EBCD', '#A2E1F9'],
|
||||
5: ['#FA9196', '#FFCC80', '#97EBCD', '#A2E1F9', '#80BCFF'],
|
||||
6: ['#FA9196', '#FFCC80', '#BAE1B3', '#97EBCD', '#A2E1F9', '#80BCFF'],
|
||||
7: ['#FA9196', '#FCA58F', '#FFCC80', '#BAE1B3', '#97EBCD', '#A2E1F9', '#80BCFF'],
|
||||
8: ['#FA9196', '#FCA58F', '#FDB887', '#FFCC80', '#BAE1B3', '#97EBCD', '#A2E1F9', '#80BCFF'],
|
||||
9: ['#FA9196', '#FCA58F', '#FDB887', '#FFCC80', '#DCD69A', '#BAE1B3', '#97EBCD', '#A2E1F9', '#80BCFF'],
|
||||
10: ['#FA9196', '#FCA58F', '#FDB887', '#FFCC80', '#DCD69A', '#BAE1B3', '#97EBCD', '#9EE4EA', '#A2E1F9', '#80BCFF'],
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
# 深蓝色 UI 规范 · 05 页面范例(§42–§44)
|
||||
|
||||
> 《深蓝色 UI 规范》分册之一。基础令牌见 `00-基础-色彩字体间距.md`,可 import 的变量见 `tokens.css`,总目录与 §索引见 `README.md`。`§N` 编号全局唯一。
|
||||
|
||||
**本篇目录**:`42` 表单弹窗范例 · `43` 卡片列表页 · `44` 数据概览仪表盘
|
||||
|
||||
---
|
||||
|
||||
## 42. 表单弹窗范例(添加 / 编辑标题)
|
||||
|
||||
> 对应设计稿「添加/编辑标题」弹窗(截图 ui-25)。这是 §21 弹出式窗口在「专项 / 标题录入」场景下的落地范例:容器 / 遮罩 / 标题栏 / 底部按钮全部沿用 §21,本节补充截图中出现而 §21 未单列的两个原子——**复合输入行**(输入框 + 行内下拉 + 行内按钮)与**行内「添加项」实心按钮**(+ 类别一 / + 类别二),并给出完整表单项清单。配色从 §1.1.2 渐红系(必填星号)、§1.1.3 渐蓝系(ZS-002,主色 / 下拉 / 按钮)、§1.1.5 深蓝系(ZS-004,label / 边框 / 容器)取。
|
||||
|
||||
### 42.1 整体布局
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────┐
|
||||
│ 添加/编辑标题 ✕ │ ← 标题居中 + 关闭
|
||||
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ ← 发光分割线
|
||||
│ │
|
||||
│ * 专项名称 [请输入内容 ] [一键导入历史专项模板▾] [预览] │ ← 复合输入行
|
||||
│ * 专项简介 [请输入内容 ] │
|
||||
│ * 国家地区 [ ▾ ] │
|
||||
│ * 涉及类别 [ + 类别一 ] [ + 类别二 ] │ ← 行内添加按钮
|
||||
│ * 显示指数 [请选择 ▾ ] │
|
||||
│ │
|
||||
│ [ 取消 ] [ 保存 ] │ ← 底部居中
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 42.2 容器与标题(沿用 §21)
|
||||
|
||||
| 元素 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 遮罩 / 容器 / 圆角 / 阴影 | 全部沿用 §21.1 | §21.1 |
|
||||
| 容器宽度 | 大档 `800px`(复合输入行需要横向空间) | §21.1 |
|
||||
| 标题文字 | `添加/编辑标题`,`20px Bold`,`#FFFFFF`,居中 | §21.2 |
|
||||
| 标题发光分割线 | `linear-gradient(90deg, transparent, #1677FF, transparent)`,`1px` 高 | §8.2.4 / §21.2 |
|
||||
| 关闭 `✕` | `16px`,`#6E88B0` (ZS-004-04),hover `#4096FF` (ZS-002-05) | §21.2 |
|
||||
|
||||
### 42.3 表单项(左 label + 右控件,沿用 §21.4)
|
||||
|
||||
| 行 | label | 控件 | 复用 |
|
||||
|----|-------|------|------|
|
||||
| 1 | `* 专项名称` | 复合输入行(见 §42.4) | §42.4 |
|
||||
| 2 | `* 专项简介` | 单行输入框,占位「请输入内容」 | §14.1 |
|
||||
| 3 | `* 国家地区` | 选择器(▾,空态占位) | §15.1 |
|
||||
| 4 | `* 涉及类别` | 行内「添加项」实心按钮组(见 §42.5) | §42.5 |
|
||||
| 5 | `* 显示指数` | 选择器(▾,占位「请选择」) | §15.1 |
|
||||
|
||||
- label `14px Regular`,`#C5CFE0` (ZS-004-02),右对齐;必填星号 `*` `#F5222D` (ZS-001-06) 置于 label 前(§21.4)
|
||||
- 表单项纵向间距 `--spacing-4` (16px)(§7.1)
|
||||
|
||||
### 42.4 复合输入行(输入框 + 行内下拉 + 行内按钮)
|
||||
|
||||
「专项名称」行把主输入框、「一键导入历史专项模板」下拉、「预览」主按钮拼在同一行。
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 主输入框 | 沿用 §14.1,弹性撑满左侧剩余宽 | §14.1 |
|
||||
| 行内下拉「一键导入历史专项模板 ▾」 | 沿用 §15.1 选择器触发器,固定宽(约 `200px`),占位文字 `#6E88B0` | §15.1 |
|
||||
| 行内按钮「预览」 | §5.2.1 主按钮(实心 `#1677FF` + 白字) | §5.2.1 |
|
||||
| 元素间水平间距 | `--spacing-2` (8px) | §7.1 |
|
||||
| 三者垂直对齐 | 统一 `32px` 高,基线居中 | §5.1 |
|
||||
|
||||
### 42.5 行内「添加项」实心按钮(+ 类别一 / + 类别二)
|
||||
|
||||
「涉及类别」用一排实心主色蓝按钮,左侧 `+` 图标,点击进入对应类别的添加 / 编辑流程。
|
||||
|
||||
| 状态 | 背景 | 文字 / 图标 | 来源 |
|
||||
|------|------|-------------|------|
|
||||
| 默认 | `#1677FF` (ZS-002-06) | `#FFFFFF` | §5.2.1 / §5.3.2 |
|
||||
| Hover | `#0958D9` (ZS-002-07) | `#FFFFFF` | §5.2.1 |
|
||||
| Active | `#003EB3` (ZS-002-08) | `#FFFFFF` | §5.2.1 |
|
||||
|
||||
- 高度 `32px`,圆角 `2px`(§4.1),内边距 `0 14px`(§5.1)
|
||||
- `+` 图标与文字同色 `#FFFFFF`,间距 `--spacing-1` (4px)(§5.3.2)
|
||||
- 按钮之间间距 `--spacing-2` (8px)
|
||||
- 与 §21.5.1 分段按钮组的区别:分段组是**互斥单选**(选中才高亮);此处每个按钮都是**独立的添加入口**,常驻主色实心。
|
||||
|
||||
### 42.6 底部操作(沿用 §21.6)
|
||||
|
||||
| 元素 | 规格 | 来源 |
|
||||
|------|------|------|
|
||||
| 对齐 | 居中(跟随截图) | §21.6 |
|
||||
| 「取消」 | §5.2.2 默认按钮(Outline) | §5.2.2 |
|
||||
| 「保存」 | §5.2.1 主按钮(实心蓝) | §5.2.1 |
|
||||
| 顺序 / 间距 | 取消在左、保存在右;间距 `--spacing-2` (8px) | §5.3.4 |
|
||||
|
||||
### 42.7 CSS Token 参考
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* 复合输入行 */
|
||||
--field-row-gap: 8px; /* --spacing-2 元素间距 */
|
||||
--field-addon-select-w: 200px; /* 行内下拉固定宽 */
|
||||
--field-row-h: 32px; /* 统一高度 */
|
||||
|
||||
/* 行内添加按钮(沿用主按钮) */
|
||||
--addbtn-bg: #1677FF; /* ZS-002-06 */
|
||||
--addbtn-bg-hover: #0958D9; /* ZS-002-07 */
|
||||
--addbtn-bg-active: #003EB3; /* ZS-002-08 */
|
||||
--addbtn-text: #FFFFFF;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 43. 卡片列表页(监测任务卡片)
|
||||
|
||||
> 对应设计稿「监测任务卡片列表」(截图 ui-26)。这是 §22 卡片在「监测任务管理」场景下的整页范例:顶部导航沿用 §8、左侧三级菜单沿用 §8.3、卡片容器沿用 §22,本节补充**页面工具条**(搜索 + 添加 + 排序)与**监测任务卡片**的专用布局(头部 + 总量 KPI + 平台统计矩阵 + 底部操作 + 空态)。配色从 §1.1.3 渐蓝系(ZS-002,主色 / KPI 数字)与 §1.1.5 深蓝系(ZS-004,容器 / 文字)取。
|
||||
|
||||
### 43.1 整体布局
|
||||
|
||||
```
|
||||
┌─ Header(§8.2)──────────────────────────────────────────────┐
|
||||
├──┬────────────────────────────────────────────────────────────┤
|
||||
│三│ [🔍 搜索关键词/任务名称 ] [+ 添加任务] 排序: 创建时间▾ ↑升序 │ ← 工具条
|
||||
│级│ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌──────────┐ │
|
||||
│菜│ │ 莫某某 10247│ │ 冯某某 10247│ │ 钱某艺 10247│ │ 赵磊 12 │ │ ← 卡片网格
|
||||
│单│ │ 社交媒体(52)│ │ 社交媒体(52)│ │ 社交媒体(52)│ │ ... │ │
|
||||
│ │ │ [开始监测] │ │ [开始监测] │ │ [开始监测] │ │ │ │
|
||||
│ │ └────────────┘ └────────────┘ └────────────┘ └──────────┘ │
|
||||
└──┴────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 43.2 页面工具条
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 搜索框 | 沿用 §14.2 基本搜索框,占位「搜索关键词 / 任务名称」 | §14.2 |
|
||||
| 「+ 添加任务」 | §5.3.2 图标 + 文字主按钮(实心 `#1677FF` + 白字 + `+`) | §5.3.2 |
|
||||
| 排序标签「排序」 | `14px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 排序字段「创建时间 ▾」 | §15.1 选择器触发器(小号) | §15.1 |
|
||||
| 升 / 降序切换「↑ 升序 / ↓ 降序」 | §5.2.3 文本按钮,激活向 `#4096FF` (ZS-002-05) | §5.2.3 |
|
||||
| 工具条 → 卡片区间距 | `--spacing-5` (24px) | §7.1 |
|
||||
| 工具条内元素间距 | `--spacing-3` (12px) | §7.1 |
|
||||
|
||||
### 43.3 监测任务卡片
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────┐
|
||||
│ 👤 莫某某 10247 │ ← 头部:头像+名称 / 右上总量
|
||||
│ 2023-09-09 09:13:00 总数量 │
|
||||
│ ──────────────────────────────────── │
|
||||
│ 社交媒体 (52) │ ← 统计区标题
|
||||
│ 微博 16 推特 8 facebook 16 │ ← 平台统计矩阵
|
||||
│ 抖音 12 土豆 6 大牛网 9 │
|
||||
│ ──────────────────────────────────── │
|
||||
│ url: t.djxqbjhgf9y.cn 也方开夫某利地址│
|
||||
│ [ 开始监测 ] │ ← 底部操作
|
||||
└──────────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### 43.3.1 结构与配色
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 卡片容器 | 同 §22.1(背景 `#122347` / 边框 `#1A2F5A` / 圆角 `4px` / 一级阴影) | §22.1 |
|
||||
| 头像占位 | 圆 `40px`,底 `#1A2F5A` (ZS-004-07),图标 `#6E88B0` | §22.3 |
|
||||
| 任务名(莫某某) | `16px Medium`,`#FFFFFF` | §22.3 |
|
||||
| 创建时间 | `12px Regular`(D-DIN 数字),`#6E88B0` (ZS-004-04) | §8.2.5 |
|
||||
| 总量数值(10247) | `26px Bold`(D-DIN),`#4096FF` (ZS-002-05) | §2.1.2 / §1.1.3 |
|
||||
| 总量标签「总数量」 | `12px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 头部底分割线 | `1px solid #1A2F5A` (ZS-004-07) | §6.1 |
|
||||
|
||||
#### 43.3.2 平台统计矩阵
|
||||
|
||||
统计区为「平台名 + 数值」多列网格(如 社交媒体 (52) 下的 微博 / 推特 / facebook…)。
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 区标题「社交媒体 (52)」 | `14px Medium`,`#C5CFE0` (ZS-004-02);括号计数 `#6E88B0` | — |
|
||||
| 平台名 | `14px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 平台数值(数字) | `16px Bold`(D-DIN),`#C5CFE0` (ZS-004-02) | §2.1.2 |
|
||||
| 矩阵列数 | 3 列等分,行间距 `--spacing-2` (8px) | §7.1 |
|
||||
| 名 / 值间距 | `--spacing-1` (4px) | §7.1 |
|
||||
|
||||
#### 43.3.3 底部操作
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 「开始监测」 | §5.2.1 主按钮(实心 `#1677FF`);运行中切 §5.4.2 加载态 | §5.2.1 / §5.4.2 |
|
||||
| 次要链接(如 url / 地址) | §5.2.3 文本按钮 `#4096FF` (ZS-002-05) | §5.2.3 |
|
||||
| 操作区上分割线 | `1px solid #2D4473`(弱化) | §6.1 |
|
||||
|
||||
#### 43.3.4 空态卡片变体
|
||||
|
||||
部分卡片暂无数据(总量 `0` + 占位):
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 总量数值 | `0`,`26px Bold`,`#6E88B0` (ZS-004-04,弱化非主色) | — |
|
||||
| 占位文字「暂无数据」 | `14px Regular`,`#6E88B0` (ZS-004-04),居中 | §35.9 |
|
||||
| 占位插画 | 灰度线性图标,`#4A6491` (ZS-004-05) | §35.9 |
|
||||
|
||||
### 43.4 卡片栅格(沿用 §22.4)
|
||||
|
||||
| 规则 | 取值 | 来源 |
|
||||
|------|------|------|
|
||||
| 列数 | 自适应,常用 3~4 列 | — |
|
||||
| 卡片横 / 纵间距 | `--spacing-6` (32px) | §22.4 |
|
||||
| 卡片内边距 | `--spacing-4` (16px) | §22.4 |
|
||||
|
||||
### 43.5 CSS Token 参考
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* 监测任务卡片 */
|
||||
--task-card-name: #FFFFFF;
|
||||
--task-card-time: #6E88B0; /* ZS-004-04 */
|
||||
--task-kpi-num: #4096FF; /* ZS-002-05 总量数字 */
|
||||
--task-kpi-label: #6E88B0; /* ZS-004-04 */
|
||||
--task-stat-name: #6E88B0; /* ZS-004-04 平台名 */
|
||||
--task-stat-num: #C5CFE0; /* ZS-004-02 平台数值 */
|
||||
--task-divider: #1A2F5A; /* ZS-004-07 头部分割 */
|
||||
--task-divider-weak: #2D4473; /* ZS-004-06 操作区分割 */
|
||||
--task-empty-text: #6E88B0; /* ZS-004-04 空态 */
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 44. 数据概览仪表盘(KPI 指标条 + 综合图表)
|
||||
|
||||
> 对应设计稿「资源使用率概览大屏」(截图 ui-27)。这是一张把 §35–§41 各图表与 §28 表格、§9.1 页签组合在一起的概览页。本节补充截图顶部出现而前文未单列的新原子——**KPI 指标卡条**(图标 + 标签 + 大数值 + 已用 + 迷你环 + 同比 / 环比箭头徽标),其余区块均引用既有章节。配色从 §1.1.3 渐蓝系(ZS-002,主色 / 数值)、§1.1.4 渐青系(ZS-003,辅色)、§1.1.5 深蓝系(ZS-004,容器 / 文字)取;涨跌语义色见 §44.2。
|
||||
|
||||
### 44.1 整体布局
|
||||
|
||||
```
|
||||
┌──┬────────────────────────────────────────────────────────────┐
|
||||
│三│ ▓ KPI 指标条(账号/设备/浏览器/代理IP/VPS/邮箱/手机卡/链卡服 使用率)▓│
|
||||
│级│ ┌─ ▌XXX标题 ───────────────┐ ┌─ ▌XXX标题(资源列表)────────┐│
|
||||
│菜│ │ [全部|账号资源|设备指标…] │ │ 🔍搜索 排序 ││
|
||||
│单│ │ ◐异常率40% ╱╲折线异常点 │ │ 资源资料 关联设备 2024-… ││
|
||||
│ │ │ 总量300 正常270 异常30 │ │ …(§28 表格行) ││
|
||||
│ │ └───────────────────────────┘ └──────────────────────────────┘│
|
||||
│ │ ┌─ ▌XXX标题 ───────────────────────┐ ┌─ ▌XXX标题 ──────────┐│
|
||||
│ │ │ 异常分析 饼 + 折线(§37 / §39) │ │ ◐300/270 + 趋势饼 ││
|
||||
│ │ └────────────────────────────────────┘ └─────────────────────┘│
|
||||
└──┴────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 44.2 涨跌语义色
|
||||
|
||||
| 语义 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 上升 / 正向(▲) | `#13C2C2` (ZS-003-06,辅色青) | §1.1.4 |
|
||||
| 下降 / 负向(▼) | `#F5222D` (ZS-001-06,主色红) | §1.1.2 |
|
||||
| 持平 | `#6E88B0` (ZS-004-04) | §1.1.5 |
|
||||
|
||||
> 涨跌仅用语义色,不混入图表多系列色;正向用辅色青(ZS-003)而非主色蓝,避免与 KPI 数值蓝撞色。
|
||||
|
||||
### 44.3 KPI 指标卡条
|
||||
|
||||
横向一排等宽指标卡,每张承载一个使用率指标(如「账号使用率 139 已用」+ 迷你环 + 同比箭头)。
|
||||
|
||||
```
|
||||
┌────────────────────────┐
|
||||
│ 🅰 账号使用率 │ ← 图标 + 标签
|
||||
│ 139 ◐ 45% ▲ │ ← 大数值 + 迷你环 + 同比
|
||||
│ 已用 同比 │
|
||||
└────────────────────────┘
|
||||
```
|
||||
|
||||
| 元素 | 色值 / 规格 | 来源 |
|
||||
|------|-------------|------|
|
||||
| 卡片容器 | 背景 `#122347` (ZS-004-08),边框 `1px solid #1A2F5A`,圆角 `4px`,一级阴影 | §22.1 |
|
||||
| 指标图标 | `20px`,主色 `#4096FF` (ZS-002-05) 单色化 | §1.1.6 |
|
||||
| 指标标签(账号使用率) | `14px Regular`,`#C5CFE0` (ZS-004-02) | — |
|
||||
| 大数值(139) | `26px Bold`(D-DIN),`#FFFFFF` | §2.1.2 |
|
||||
| 单位 / 说明「已用」 | `12px Regular`,`#6E88B0` (ZS-004-04) | — |
|
||||
| 迷你环(mini-donut) | 直径 `32px`,环宽 `4px`,已用段 `#1677FF` (ZS-002-06),底环 `#2D4473` (ZS-004-06) | §39.2 |
|
||||
| 环内百分比 | `12px Bold`(D-DIN),`#FFFFFF` | §39.3 |
|
||||
| 同比 / 环比箭头徽标 | `12px`,▲ 用 `#13C2C2`、▼ 用 `#F5222D`(见 §44.2) | §44.2 |
|
||||
| 卡片宽度 | 等分横排(8 张则各占 1/8),最小宽 `160px` | — |
|
||||
| 卡片间距 | `--spacing-4` (16px) | §7.1 |
|
||||
| 卡片内边距 | `--spacing-4` (16px) | §7.1 |
|
||||
|
||||
### 44.4 区块组合引用
|
||||
|
||||
| 区块 | 复用 | 备注 |
|
||||
|------|------|------|
|
||||
| 区块标题(▌XXX标题) | §35.2 图表标题(主色蓝竖条 + 文字) | — |
|
||||
| 分类页签(全部 / 账号资源 / …) | §9.1.1 横向页签 | 激活 `#4096FF` + `2px` 下划线 |
|
||||
| 日期筛选(右上 `2023-02`) | §17.1 日期触发器 | — |
|
||||
| 异常率环形图(40% / 总量300 / 正常270 / 异常30) | §39 环形图 | 正常段主色蓝、异常段 `#F5222D`(§44.2) |
|
||||
| 折线异常点图(1月10日 异常率12.9%) | §37.3 单线异常点图 + §35.6 Tooltip | 异常点用红 `#F5222D` 强调 |
|
||||
| 资源列表表格 | §28 表格 + §14.2 搜索 + §13 分页 | — |
|
||||
| 异常分析饼 / 趋势饼 | §39 环形图 | 多系列回落 §41 色序 |
|
||||
| 容器 / 内边距 / 多图间距 | §35.1 图表容器 | `--spacing-5` / `--spacing-6` |
|
||||
|
||||
### 44.5 交互
|
||||
|
||||
| 行为 | 规则 |
|
||||
|------|------|
|
||||
| KPI 卡 hover | 卡片阴影升二级(§3.1.4),迷你环高亮,弹出 §35.6 Tooltip(已用 / 总量 / 同比明细) |
|
||||
| 页签切换 | 切换分类后下方图表与表格联动刷新(§9.1.1) |
|
||||
| 图表 hover | 沿用各图表节交互(§37.6 / §39.4 等) |
|
||||
| 日期筛选变更 | 重新拉取区块数据,图表入场动画重放 |
|
||||
|
||||
### 44.6 CSS Token 参考
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* KPI 指标卡 */
|
||||
--kpi-card-bg: #122347; /* ZS-004-08 */
|
||||
--kpi-card-border: #1A2F5A; /* ZS-004-07 */
|
||||
--kpi-icon: #4096FF; /* ZS-002-05 */
|
||||
--kpi-label: #C5CFE0; /* ZS-004-02 */
|
||||
--kpi-value: #FFFFFF;
|
||||
--kpi-sub: #6E88B0; /* ZS-004-04 已用 */
|
||||
--kpi-ring-used: #1677FF; /* ZS-002-06 迷你环已用段 */
|
||||
--kpi-ring-track: #2D4473; /* ZS-004-06 迷你环底 */
|
||||
|
||||
/* 涨跌语义 */
|
||||
--trend-up: #13C2C2; /* ZS-003-06 上升(辅色青) */
|
||||
--trend-down: #F5222D; /* ZS-001-06 下降(红) */
|
||||
--trend-flat: #6E88B0; /* ZS-004-04 持平 */
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,82 @@
|
||||
# 深蓝色 UI 规范(拆分版)
|
||||
|
||||
面向开发的深蓝主题设计规范。原单文件 `../ui修改-深蓝.md`(约 5200 行)已按模块拆分到本目录,便于按需查阅、减少 diff 冲突,也方便配合 AI 只加载相关分册。
|
||||
|
||||
> **颜色唯一来源**:所有色值以 **§1 色彩**(见 [`00-基础-色彩字体间距.md`](./00-基础-色彩字体间距.md))为准,可执行变量见 [`tokens.css`](./tokens.css)。业务代码 **import `tokens.css` 并用 `var(--token)`**,不要硬编码 HEX。
|
||||
|
||||
## 分册
|
||||
|
||||
| 文件 | 章节 | 内容 |
|
||||
|------|------|------|
|
||||
| [`00-基础-色彩字体间距.md`](./00-基础-色彩字体间距.md) | §1–§7 | 色彩 / 字体 / 阴影 / 圆角 / 按钮 / 分割线 / 间距 |
|
||||
| [`01-导航.md`](./01-导航.md) | §8–§13 | 导航组件 / 锚点页签 / 步骤条 / 面包屑 / 页头 / 分页 |
|
||||
| [`02-表单.md`](./02-表单.md) | §14–§21 | 输入框 / 选择器 / 单复选 / 日期 / 穿梭框 / 树选择 / 上传 / 弹窗 |
|
||||
| [`03-数据展示.md`](./03-数据展示.md) | §22–§34 | 卡片 / 折叠 / 描述列表 / 列表 / 时间轴 / 进度条 / 表格 / 标签 / 树 / 对话框 / 提示 / 气泡确认 |
|
||||
| [`04-图表.md`](./04-图表.md) | §35–§41 | 图表通用 / 柱状 / 折线 / 甘特 / 环形 / 关系散点 / 图表色值 |
|
||||
| [`05-页面范例.md`](./05-页面范例.md) | §42–§44 | 表单弹窗 / 卡片列表页 / 数据概览仪表盘 |
|
||||
| [`tokens.css`](./tokens.css) | — | 全量 CSS 变量(颜色 / 间距 / 圆角 / 阴影 / 字体),可直接 import |
|
||||
|
||||
## § 索引(编号 → 所在文件)
|
||||
|
||||
章节编号 `§N` 全局唯一、跨文件不变;文中 `§N` / `§N.x` 引用按下表定位。
|
||||
|
||||
| § | 标题 | 文件 |
|
||||
|---|------|------|
|
||||
| §1 | 色彩 | 00 |
|
||||
| §2 | 字体 | 00 |
|
||||
| §3 | 阴影 | 00 |
|
||||
| §4 | 圆角 | 00 |
|
||||
| §5 | 按钮 | 00 |
|
||||
| §6 | 分割线 | 00 |
|
||||
| §7 | 间距 | 00 |
|
||||
| §8 | 导航组件 | 01 |
|
||||
| §9 | 锚点与页签 | 01 |
|
||||
| §10 | 步骤条 | 01 |
|
||||
| §11 | 面包屑 | 01 |
|
||||
| §12 | 页头 | 01 |
|
||||
| §13 | 分页 | 01 |
|
||||
| §14 | 输入框(搜索框) | 02 |
|
||||
| §15 | 选择器 | 02 |
|
||||
| §16 | 单选与多选 | 02 |
|
||||
| §17 | 日期选择器 | 02 |
|
||||
| §18 | 穿梭框 | 02 |
|
||||
| §19 | 树选择 | 02 |
|
||||
| §20 | 上传 | 02 |
|
||||
| §21 | 弹出式窗口(Modal) | 02 |
|
||||
| §22 | 卡片 | 03 |
|
||||
| §23 | 折叠面板 | 03 |
|
||||
| §24 | 描述列表 | 03 |
|
||||
| §25 | 列表 | 03 |
|
||||
| §26 | 时间轴(节点型) | 03 |
|
||||
| §27 | 进度条 | 03 |
|
||||
| §28 | 表格 | 03 |
|
||||
| §29 | 标签 | 03 |
|
||||
| §30 | 树形控件 | 03 |
|
||||
| §31 | 时间轴(长文本) | 03 |
|
||||
| §32 | 对话框(确认框) | 03 |
|
||||
| §33 | 全局提示 | 03 |
|
||||
| §34 | 气泡确认 | 03 |
|
||||
| §35 | 图表通用规范 | 04 |
|
||||
| §36 | 柱状图 | 04 |
|
||||
| §37 | 折线图 | 04 |
|
||||
| §38 | 甘特图 | 04 |
|
||||
| §39 | 环形图 | 04 |
|
||||
| §40 | 关系图 / 散点图 | 04 |
|
||||
| §41 | 图表色值 | 04 |
|
||||
| §42 | 表单弹窗范例 | 05 |
|
||||
| §43 | 卡片列表页 | 05 |
|
||||
| §44 | 数据概览仪表盘 | 05 |
|
||||
|
||||
## 约定
|
||||
|
||||
- **颜色**:以 §1 为准,代码用 `tokens.css` 的 `var(--token)`。功能语义色(成功/警告/错误/信息/处理中)见 §1.1.9 / `--func-*`。
|
||||
- **间距**:仅用 §7 的 8px 阶梯(`--spacing-1..8`),禁用 5px / 13px 等非阶梯值。
|
||||
- **圆角**:按钮/输入/标签 `2px`,卡片/分栏/弹窗 `4px`(`--radius-*`)。
|
||||
- **跨节引用**:保留 `§N` 编号,用上方「§ 索引」定位文件。
|
||||
- **名称易混点**:§26 时间轴(节点型) ↔ §31 时间轴(长文本);§21 弹出式窗口(Modal) ↔ §32 对话框(确认框)。
|
||||
- **图表两套色板**:§1.1.8(高彩度,强调单值)与 §41(淡色系,多分类并列)并存,优先级见 §41.3。
|
||||
|
||||
## 维护
|
||||
|
||||
- 改色 / 改间距 → 先改 **`tokens.css` + §1/§7**,组件分册回落引用,不在分册里另立硬编码。
|
||||
- 新增整页范例 → 进 `05-页面范例.md`,沿用既有组件 § 与 `tokens.css`。
|
||||
@@ -0,0 +1,211 @@
|
||||
/* =============================================================================
|
||||
* 深蓝色 UI 规范 · 设计令牌(tokens.css)
|
||||
* -----------------------------------------------------------------------------
|
||||
* 这是《深蓝色 UI 规范》全站颜色 / 间距 / 圆角 / 阴影 / 字体的唯一可执行来源。
|
||||
* 开发时优先 import 本文件并使用 var(--token),不要在业务代码里硬编码 HEX。
|
||||
*
|
||||
* 文档对应:
|
||||
* §1 色彩 → 原始色阶 --zs-*、功能语义 --func-*、装饰/图表色板
|
||||
* §2 字体 → --font-* / --fs-*
|
||||
* §3 阴影 → --shadow-*
|
||||
* §4 圆角 → --radius-*
|
||||
* §7 间距 → --spacing-*
|
||||
* 组件级 token(--card-* / --modal-* / --kpi-* 等)保留在各分册的「CSS Token 参考」
|
||||
* 小节中,均回落到本文件的原始/语义 token。
|
||||
* ========================================================================== */
|
||||
|
||||
:root {
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 1. 原始色阶(§1.1.2–§1.1.5)—— 01 最浅 → 10 最深
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
/* 渐红系 ZS-001 —— 警示 / 错误 / 强调 */
|
||||
--zs-001-01: #FFF1F0;
|
||||
--zs-001-02: #FFCCC7;
|
||||
--zs-001-03: #FFA39E;
|
||||
--zs-001-04: #FF7875;
|
||||
--zs-001-05: #FF4D4F;
|
||||
--zs-001-06: #F5222D;
|
||||
--zs-001-07: #CF1322;
|
||||
--zs-001-08: #A8071A;
|
||||
--zs-001-09: #820014;
|
||||
--zs-001-10: #5C0011;
|
||||
|
||||
/* 渐蓝系 ZS-002 —— 信息 / 链接 / 次级操作(含主色) */
|
||||
--zs-002-01: #E6F4FF;
|
||||
--zs-002-02: #BAE0FF;
|
||||
--zs-002-03: #91CAFF;
|
||||
--zs-002-04: #69B1FF;
|
||||
--zs-002-05: #4096FF;
|
||||
--zs-002-06: #1677FF;
|
||||
--zs-002-07: #0958D9;
|
||||
--zs-002-08: #003EB3;
|
||||
--zs-002-09: #002C8C;
|
||||
--zs-002-10: #001D6C;
|
||||
|
||||
/* 渐青系 ZS-003 —— 成功 / 在线 / 数据高亮(含辅色) */
|
||||
--zs-003-01: #E6FFFB;
|
||||
--zs-003-02: #B5F5EC;
|
||||
--zs-003-03: #87E8DE;
|
||||
--zs-003-04: #5CDBD3;
|
||||
--zs-003-05: #36CFC9;
|
||||
--zs-003-06: #13C2C2;
|
||||
--zs-003-07: #08979C;
|
||||
--zs-003-08: #006D75;
|
||||
--zs-003-09: #00474F;
|
||||
--zs-003-10: #002329;
|
||||
|
||||
/* 深蓝系 ZS-004 —— 背景 / 容器 / 导航 / 文字(主题核心) */
|
||||
--zs-004-01: #E8EDF5;
|
||||
--zs-004-02: #C5CFE0;
|
||||
--zs-004-03: #9BADC8;
|
||||
--zs-004-04: #6E88B0;
|
||||
--zs-004-05: #4A6491;
|
||||
--zs-004-06: #2D4473;
|
||||
--zs-004-07: #1A2F5A;
|
||||
--zs-004-08: #122347;
|
||||
--zs-004-09: #0C1836;
|
||||
--zs-004-10: #060E24;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 2. 功能角色色(§1.1.6)—— 从色阶提取的语义别名
|
||||
* ------------------------------------------------------------------------ */
|
||||
--color-primary: var(--zs-002-06); /* #1677FF 主操作 */
|
||||
--color-primary-hover: var(--zs-002-07); /* #0958D9 */
|
||||
--color-primary-active: var(--zs-002-08); /* #003EB3 */
|
||||
--color-link: var(--zs-002-05); /* #4096FF 链接 / 文本按钮 */
|
||||
--color-accent: var(--zs-003-06); /* #13C2C2 辅色 */
|
||||
|
||||
--color-text: var(--zs-004-02); /* #C5CFE0 正文字体 */
|
||||
--color-text-secondary: var(--zs-004-04); /* #6E88B0 次级字体 */
|
||||
--color-text-disabled: var(--zs-004-05); /* #4A6491 禁用字体 */
|
||||
--color-text-strong: #FFFFFF; /* 标题 / 强调 */
|
||||
|
||||
--color-bg-page: var(--zs-004-09); /* #0C1836 页面背景 */
|
||||
--color-bg-container: var(--zs-004-07); /* #1A2F5A 容器背景 */
|
||||
--color-bg-card: var(--zs-004-08); /* #122347 卡片背景 */
|
||||
--color-bg-deepest: var(--zs-004-10); /* #060E24 全局底色 */
|
||||
--color-border: var(--zs-004-07); /* #1A2F5A 容器边框 */
|
||||
--color-border-strong: var(--zs-004-04); /* #6E88B0 控件边框 */
|
||||
--color-white: #FFFFFF;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 3. 功能语义色(§1.1.9)—— 成功/警告/错误/信息/处理中
|
||||
* 成功绿、警告橙为标准色系外补充色;其余复用色阶。
|
||||
* ------------------------------------------------------------------------ */
|
||||
--func-success: #52C41A; /* 补充色 · 成功绿 */
|
||||
--func-warning: #FAAD14; /* 补充色 · 警告橙 */
|
||||
--func-error: var(--zs-001-06); /* #F5222D */
|
||||
--func-info: var(--zs-002-06); /* #1677FF */
|
||||
--func-processing: var(--zs-003-06); /* #13C2C2 */
|
||||
|
||||
/* 浅底变体(Message / Alert / Tag 背景,16% 透明度) */
|
||||
--func-success-bg: rgba(82, 196, 26, 0.16);
|
||||
--func-warning-bg: rgba(250, 173, 20, 0.16);
|
||||
--func-error-bg: rgba(245, 34, 45, 0.16);
|
||||
--func-info-bg: rgba(22, 119, 255, 0.16);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 4. 小面积装饰色(§1.1.7)—— 仅点缀 / 徽标,勿做大面积背景
|
||||
* ------------------------------------------------------------------------ */
|
||||
--deco-violet: #6388FF;
|
||||
--deco-danger: #F5222D;
|
||||
--deco-brand-blue: #12306C;
|
||||
--deco-teal: #478880;
|
||||
--deco-alert: #950404;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 5. 字体(§2)
|
||||
* ------------------------------------------------------------------------ */
|
||||
--font-zh: 'Noto Sans S Chinese', 'Noto Sans SC', system-ui, sans-serif;
|
||||
--font-num: 'D-DIN', 'Noto Sans S Chinese', sans-serif; /* 数据数字 */
|
||||
--font-digital:'DS-Digital', 'D-DIN', sans-serif; /* 大屏特殊数字 */
|
||||
--font-logo: 'DOUYUFont', 'Noto Sans S Chinese', sans-serif;
|
||||
--font-table: 'Arial', 'Noto Sans S Chinese', sans-serif; /* 表格数字 */
|
||||
|
||||
/* 常用字号(后台系统,§2.1.2) */
|
||||
--fs-12: 12px;
|
||||
--fs-14: 14px;
|
||||
--fs-16: 16px;
|
||||
--fs-18: 18px;
|
||||
--fs-20: 20px;
|
||||
--fs-24: 24px;
|
||||
--fs-26: 26px;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 6. 间距(§7)—— 8px 基准,密(≤16) / 疏(≥24),禁用非阶梯值
|
||||
* ------------------------------------------------------------------------ */
|
||||
--spacing-1: 4px;
|
||||
--spacing-2: 8px;
|
||||
--spacing-3: 12px;
|
||||
--spacing-4: 16px;
|
||||
--spacing-5: 24px;
|
||||
--spacing-6: 32px;
|
||||
--spacing-7: 40px;
|
||||
--spacing-8: 56px;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 7. 圆角(§4)
|
||||
* ------------------------------------------------------------------------ */
|
||||
--radius-button: 2px;
|
||||
--radius-input: 2px;
|
||||
--radius-tag: 2px;
|
||||
--radius-card: 4px;
|
||||
--radius-panel: 4px;
|
||||
--radius-modal: 4px;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 8. 阴影(§3.1.4)
|
||||
* ------------------------------------------------------------------------ */
|
||||
--shadow-1: 0 2px 8px rgba(22, 119, 255, 0.12); /* 卡片悬浮 */
|
||||
--shadow-2: 0 4px 16px rgba(22, 119, 255, 0.24); /* hover / 弹出层 */
|
||||
--shadow-3: 0 8px 32px rgba(6, 14, 36, 0.6); /* Dialog / Drawer */
|
||||
--shadow-modal-mask: rgba(6, 14, 36, 0.6); /* 遮罩 */
|
||||
|
||||
/* 常用渐变 */
|
||||
--gradient-header: linear-gradient(180deg, #122347 0%, #0C1836 100%); /* 顶栏 §8.2.1 */
|
||||
--gradient-title-line: linear-gradient(90deg, transparent 0%, #1677FF 50%, transparent 100%); /* 标题发光线 §8.2.4 */
|
||||
}
|
||||
|
||||
/* =============================================================================
|
||||
* 图表多系列色板
|
||||
* ========================================================================== */
|
||||
:root {
|
||||
/* 通用图表色序(§1.1.8,面积大:柱/折线/饼,高彩度) */
|
||||
--chart-g-1: #1677FF;
|
||||
--chart-g-2: #13C2C2;
|
||||
--chart-g-3: #4096FF;
|
||||
--chart-g-4: #36CFC9;
|
||||
--chart-g-5: #69B1FF;
|
||||
--chart-g-6: #5CDBD3;
|
||||
--chart-g-7: #91CAFF;
|
||||
--chart-g-8: #87E8DE;
|
||||
|
||||
/* 小面积图表色序(§1.1.8,散点/迷你图/徽标) */
|
||||
--chart-s-1: #4096FF;
|
||||
--chart-s-2: #36CFC9;
|
||||
--chart-s-3: #FF4D4F;
|
||||
--chart-s-4: #FFA39E;
|
||||
--chart-s-5: #6388FF;
|
||||
--chart-s-6: #478880;
|
||||
|
||||
/* 多系列填充色板(§41,淡色系,分类并列默认色序) */
|
||||
--chart-p-red: #FA9196;
|
||||
--chart-p-redorange: #FCA58F;
|
||||
--chart-p-orange: #FDB887;
|
||||
--chart-p-amber: #FFCC80;
|
||||
--chart-p-olive: #DCD69A;
|
||||
--chart-p-green: #BAE1B3;
|
||||
--chart-p-teal: #97EBCD;
|
||||
--chart-p-cyan: #9EE4EA;
|
||||
--chart-p-skyblue: #A2E1F9;
|
||||
--chart-p-blue: #80BCFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* 图表配色优先级(§41.3):
|
||||
* 有语义 → 用 --func-*;多分类并列 → 用 --chart-p-*(§41 色板);
|
||||
* 需强调单值 → 用 --chart-g-* / --chart-s-*(§1.1.8 高彩度)。
|
||||
*
|
||||
* 接入 ECharts 时按系列数取 option.color,见 §41.4 的 CHART_PALETTES。
|
||||
*/
|
||||
@@ -0,0 +1,156 @@
|
||||
# DeerFlow 上游升级对比与回合建议
|
||||
|
||||
> 对比对象:`bytedance/deer-flow`(上游,HEAD `9f3be2a` @ 2026-05-30)vs 本仓库 fork。
|
||||
> 生成日期:2026-05-31。
|
||||
> 说明:按用户要求,**多语言 (i18n)** 与 **播客 / TTS (podcast)** 不在本次升级范围内,已剔除。
|
||||
|
||||
---
|
||||
|
||||
## 0. 背景与对比结论
|
||||
|
||||
| 项 | 结论 |
|
||||
|---|---|
|
||||
| fork 切出时间 | **≈ 2026-05-12**(与目录名 `offline-backend-20260512` 吻合) |
|
||||
| 上游当前 HEAD | `9f3be2a` @ 2026-05-30,完整历史 2186 提交 |
|
||||
| fork 之后上游新增 | **95 个提交**(7 feat / 1 perf / 60 fix / 依赖与文档若干) |
|
||||
| 后端核心框架 `packages/harness/deerflow/` | **高度同源、目录结构完全一致**,差异主要来自这 95 个提交 |
|
||||
| 前端 | 技术栈已分道扬镳:上游仍是 **Next.js**,本仓库已迁到 **Vite + React Router**,文件几乎全不同 |
|
||||
|
||||
「升级」分两类,本文都覆盖:
|
||||
- **A 类**:fork 之后上游真正新增的(95 提交)——同源、可 cherry-pick,**优先回合**。
|
||||
- **B 类**:fork 时就裁掉/换了路线、上游一直保留的能力——成本高、按业务取舍。
|
||||
|
||||
---
|
||||
|
||||
## 1. 后端升级(A 类:fork 后上游新增)
|
||||
|
||||
### 1.1 新能力(feat / perf)
|
||||
|
||||
| 日期 | 升级 | 提交 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 05-29 | ToolOutputBudgetMiddleware | #3303 | 给超大工具输出做预算保护,防止单个结果撑爆上下文 |
|
||||
| 05-28 | MiMo reasoning 支持 | #3298 | 兼容小米 MiMo 模型思维链回传 |
|
||||
| 05-21 | 链路追踪命名优化 | #3101 | 图名改 `lead_agent`、用自定义 agent 名作 run_name |
|
||||
| 05-21 | 循环检测延迟告警 | #2752 | 警告延迟注入,减少对正常多轮对话的误打断 |
|
||||
| 05-20 | Sandbox 下载文件接口 | #3038 | 可把沙箱内产物取回 |
|
||||
| 05-15 | Discord 渠道增强 | #2842 | 仅@提及、thread 路由、typing 指示 |
|
||||
| 05-13 | 子代理 token 用量流式上报 | #2882 | subagent 消耗实时汇总到 header,利于展示/计费 |
|
||||
| 05-12 | perf:线程元数据过滤下推 SQL | #2865 | 线程列表筛选走 SQL,性能提升 |
|
||||
|
||||
能力性增强(fix 前缀实为增强):MCP 跨调用持久化会话、支持有状态 server(#3089 / #3203);摘要触发阈值调优(#3174)。
|
||||
|
||||
### 1.2 重要稳定性修复
|
||||
|
||||
| 主题 | 提交 | 价值 |
|
||||
|---|---|---|
|
||||
| 摘要压缩后保留消息 | #3280 | 数据正确性关键 |
|
||||
| 重启后从持久化恢复 runs / interrupted 状态 | #2932(破坏性)、#2989、#3152、#3155 | 网关重启不丢运行 |
|
||||
| JWT secret 持久化、多 worker 共享网关 token | #2933、#3184 | 重启/多进程登录态不失效 |
|
||||
| memory 更新按 agent 隔离 + 包裹 JSON 解析健壮性 | #2941、#3252 | 记忆串号/解析修复 |
|
||||
| MCP 配置接口脱敏 | #2667 | 防密钥泄露 |
|
||||
| 阻塞 IO 移出事件循环 | #3311、#2822(+检测门禁 #3229) | 消除事件循环阻塞 |
|
||||
|
||||
### 1.3 依赖升级
|
||||
- Python:`langsmith 0.7.36 → 0.8.0`、`idna 3.13 → 3.15`
|
||||
|
||||
### 1.4 怎么做(回合 A 类后端升级)
|
||||
|
||||
> 前提:本仓库 `packages/harness/deerflow/` 与上游高度同源,cherry-pick 冲突面小。
|
||||
|
||||
1. **加上游为远程并拉取历史**(在后端所在 git 仓库根执行):
|
||||
```bash
|
||||
git remote add upstream https://github.com/bytedance/deer-flow.git
|
||||
git fetch upstream
|
||||
```
|
||||
2. **逐条预览某个提交的改动范围**:
|
||||
```bash
|
||||
git show <commit_hash> --stat
|
||||
git show <commit_hash> -- backend/packages/harness/deerflow/...
|
||||
```
|
||||
3. **单条回合**(推荐用 `-x` 记录来源;如路径前缀不一致需先确认):
|
||||
```bash
|
||||
git cherry-pick -x <commit_hash>
|
||||
# 冲突时:解决后
|
||||
git cherry-pick --continue
|
||||
```
|
||||
> 注意:上游后端在 `backend/` 子目录,本仓库后端在 `offline-backend-20260512/backend/`。若 cherry-pick 因路径不匹配失败,改用按文件打补丁:
|
||||
> ```bash
|
||||
> git show <hash> -- backend/<path> | git apply --directory=offline-backend-20260512/backend -p2 -3
|
||||
> ```
|
||||
4. **回合后必跑校验**(在 `offline-backend-20260512/backend/`):
|
||||
```bash
|
||||
make test # PYTHONPATH=. uv run pytest tests/ -v
|
||||
make lint
|
||||
```
|
||||
重点确认 `tests/test_harness_boundary.py`(harness→app 防火墙)与中间件链顺序未被破坏。
|
||||
5. **依赖升级**:同步上游 `pyproject.toml` 对应行后执行 `uv lock && make install`;离线环境需同步更新 `requirements-offline.txt` / `wheelhouse`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 前端升级(B 类:上游有、本仓库缺)
|
||||
|
||||
> 已剔除多语言、播客。下表为关键词核验结果(本仓库 vs 上游命中文件数)。
|
||||
|
||||
| 功能 | 本仓库 | 上游 | 状态 |
|
||||
|---|---|---|---|
|
||||
| Prose 文本润色 | 0 | 8 | 上游独有 |
|
||||
| Replay 研究回放 | 2 | 29 | 上游完整,本仓库近乎无 |
|
||||
| PPT / PPTX 生成 | 2 | 14 | 上游完整,本仓库近乎无 |
|
||||
| Landing 落地页 | 0 | 11 | 上游独有(营销/介绍页,按需) |
|
||||
| 静态 demo 模式 | 无 | #3170 | fork 后上游新增 |
|
||||
|
||||
前端体验类修复(可参考实现):流式渲染、消息去重、历史消息 Mermaid 预览、新建会话即时入侧栏。
|
||||
前端依赖升级:`brace-expansion 1.x → 5.0.5`(安全)、`uuid 10 → 14`。
|
||||
|
||||
### 2.1 怎么做(前端能力移植)
|
||||
|
||||
> 前端技术栈已不同(Next.js → Vite + React Router),**不能直接 cherry-pick**,需按"读上游实现 → 适配到本仓库"的方式重写。
|
||||
|
||||
通用步骤:
|
||||
1. 在上游 `frontend/src/` 定位目标功能的页面/组件/hook 与对应的后端 API 调用。
|
||||
2. 后端能力是否具备:Prose / PPT / Replay 依赖后端相应接口,先确认本仓库后端有无对应路由(多为 deep_research/skills 相关),**没有则前端无法独立完成**,需连带回合后端。
|
||||
3. 适配差异点:
|
||||
- 路由:上游 app router (`src/app/...`) → 本仓库 `src/pages/` + `PageRoutes.tsx` / `WorkspaceRoutes.tsx`。
|
||||
- 导航 API:用本仓库 `src/shims/`(`next/link`、`next/navigation` 已 polyfill)。
|
||||
- 数据流:沿用本仓库 TanStack Query + `@langchain/langgraph-sdk` 流式。
|
||||
4. 验证:`pnpm typecheck` + `pnpm dev` 实测。
|
||||
|
||||
---
|
||||
|
||||
## 3. 推荐升级清单(按优先级)
|
||||
|
||||
### P0 — 强烈建议(低风险、高价值,A 类)
|
||||
- **摘要压缩后保留消息 #3280** —— 数据正确性,直接影响长对话可用性。
|
||||
- **重启后恢复 runs / interrupted #2932 #2989 #3152 #3155** —— 生产稳定性核心。
|
||||
- **JWT secret 持久化 / 多 worker 共享 token #2933 #3184** —— 否则重启或多进程部署会掉登录态。
|
||||
- **阻塞 IO 移出事件循环 #3311 #2822** —— 并发吞吐与响应延迟改善。
|
||||
|
||||
### P1 — 建议(实用增强)
|
||||
- **ToolOutputBudgetMiddleware #3303** —— 防超大工具输出拖垮上下文,对 agent 稳定性有实际帮助。
|
||||
- **MCP 持久化会话 / 有状态 server #3089 #3203** —— 若用到有状态 MCP server 则必需。
|
||||
- **MCP 配置接口脱敏 #2667** —— 安全加固。
|
||||
- **子代理 token 用量流式上报 #2882** —— 计费/可观测。
|
||||
- **线程元数据过滤下推 SQL #2865(perf)** —— 列表性能。
|
||||
|
||||
### P2 — 按需(看是否用到对应模型/渠道)
|
||||
- MiMo reasoning #3298(用小米模型才需要)
|
||||
- Discord 渠道增强 #2842(用 Discord 才需要)
|
||||
- Sandbox 下载文件接口 #3038、追踪命名 #3101、循环检测延迟告警 #2752
|
||||
|
||||
### 前端(按业务价值)
|
||||
- **Replay 研究回放** —— 对"深研/写作"类产品体验提升明显,建议优先(需后端配合)。
|
||||
- **Prose 文本润色** —— 与写作工作台契合,建议评估接入。
|
||||
- **PPT 生成** —— 若有汇报/导出诉求再做。
|
||||
- **Landing 落地页** —— 仅当面向外部用户时考虑。
|
||||
|
||||
### 暂不做
|
||||
- 多语言 i18n(本次明确排除)
|
||||
- 播客 / TTS(本次明确排除)
|
||||
|
||||
---
|
||||
|
||||
## 4. 建议执行节奏
|
||||
1. 先做 **P0 后端 4 项** + 跑全量测试,单独提交一个"上游稳定性回合"分支。
|
||||
2. 再做 **P1**,逐条 cherry-pick、逐条验证。
|
||||
3. 前端 **Replay / Prose** 立项评估(确认后端依赖),单独排期重写适配。
|
||||
4. 依赖升级随回合同步,离线包 (`wheelhouse` / `requirements-offline.txt`) 一并更新。
|
||||
@@ -0,0 +1,514 @@
|
||||
# 浅红色 UI 规范 · 一、基础样式
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:色彩 · 字体 · 阴影 · 圆角 · 间距 · 语义状态色
|
||||
|
||||
---
|
||||
|
||||
## 1. 色彩
|
||||
|
||||
### 1.1 标准色
|
||||
|
||||
色彩体系分为**主色**与**辅色**两大类。
|
||||
|
||||
- **主色**:渐红系(ZS-001)、渐蓝系(ZS-002),用于品牌表达与核心交互。
|
||||
- **辅色**:渐橙系(FS-001)、渐绿系(FS-002)、渐青系(FS-003)、中性灰系(FS-004),用于状态提示、数据可视化与文字 / 背景 / 分割线。
|
||||
|
||||
每个色系按明度从浅到深编号(`-01` 最浅,数字越大越深),并附两种渐变色(`-14` 线性渐变、`-15` 径向渐变)。本主题为**浅色主题**:以白 / 浅灰作大面积背景,以深色作正文,红色为品牌强调主色。
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.1 色系总览
|
||||
|
||||
| 类别 | 色系 | 用途定位 | 代码前缀 |
|
||||
|------|------|----------|----------|
|
||||
| 主色 | 渐红系 | 品牌主色、强调操作、警示与错误 | ZS-001 |
|
||||
| 主色 | 渐蓝系 | 信息、链接、次级操作 | ZS-002 |
|
||||
| 辅色 | 渐橙系 | 警告、进行中、提示标签 | FS-001 |
|
||||
| 辅色 | 渐绿系 | 成功、在线、通过状态 | FS-002 |
|
||||
| 辅色 | 渐青系 | 数据高亮、图表、辅助信息 | FS-003 |
|
||||
| 辅色 | 中性灰系 | 背景、文字、图标、分割线 | FS-004 |
|
||||
|
||||
> 每个色系内:`-01 ~ -03` 为**浅色**(用于大面积底色);`-04 ~ -09` 为**中亮色**(用于标签、图表、提示等);`-10` 及以后为**深色**(用于小面积按钮、图标等);`-14 / -15` 为渐变色(用于特殊装饰性小面积底色)。
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.2 主色 · 渐红系(ZS-001)
|
||||
|
||||
品牌主色系。用于主操作按钮、重要强调、错误与危险告警。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| ZS-001 | `#CF1322` | 深色 | 品牌代表红(默认主色基准) |
|
||||
| ZS-001-01 | `#FEFAFA` | 浅色 | 极浅红,大面积底色 |
|
||||
| ZS-001-02 | `#FEF6F6` | 浅色 | 浅红底色 |
|
||||
| ZS-001-03 | `#FEEDED` | 浅色 | 浅红底色 / 错误背景 |
|
||||
| ZS-001-04 | `#FDDADC` | 中亮色 | — |
|
||||
| ZS-001-05 | `#FCB5B9` | 中亮色 | — |
|
||||
| ZS-001-06 | `#FA9196` | 中亮色 | — |
|
||||
| ZS-001-07 | `#F86C73` | 中亮色 | 浅红 Tag / 图表 |
|
||||
| ZS-001-08 | `#F74750` | 中亮色 | — |
|
||||
| ZS-001-09 | `#F5222D` | 中亮色 | **标准红**,主按钮 / 图标 |
|
||||
| ZS-001-10 | `#BC0D1E` | 深色 | 深红,Hover |
|
||||
| ZS-001-11 | `#A8071A` | 深色 | 深红,Active / Press |
|
||||
| ZS-001-12 | `#820014` | 深色 | 极深红 |
|
||||
| ZS-001-13 | `#5C0011` | 深色 | 最深红 |
|
||||
| ZS-001-14 | `#F5222D → #A8071A` | 线性渐变 | 装饰底色 |
|
||||
| ZS-001-15 | `#F86C73 → #F5222D` | 径向渐变 | 装饰底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.3 主色 · 渐蓝系(ZS-002)
|
||||
|
||||
用于信息提示、链接、次级按钮与图表。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| ZS-002 | `#0062D9` | 深色 | 蓝色代表色(基准) |
|
||||
| ZS-002-01 | `#F9FCFF` | 浅色 | 极浅蓝,大面积底色 |
|
||||
| ZS-002-02 | `#F4F9FF` | 浅色 | 浅蓝底色 |
|
||||
| ZS-002-03 | `#EAF4FF` | 浅色 | 浅蓝底色 / 信息背景 |
|
||||
| ZS-002-04 | `#D4E9FF` | 中亮色 | — |
|
||||
| ZS-002-05 | `#AAD2FF` | 中亮色 | — |
|
||||
| ZS-002-06 | `#80BCFF` | 中亮色 | — |
|
||||
| ZS-002-07 | `#55A6FE` | 中亮色 | 浅蓝 Tag / 图表 |
|
||||
| ZS-002-08 | `#2B8FFE` | 中亮色 | — |
|
||||
| ZS-002-09 | `#0079FE` | 中亮色 | **标准蓝**,链接 / 信息主色 |
|
||||
| ZS-002-10 | `#0056C6` | 深色 | 深蓝,Hover |
|
||||
| ZS-002-11 | `#004AB3` | 深色 | 深蓝,Active |
|
||||
| ZS-002-12 | `#00368C` | 深色 | 极深蓝 |
|
||||
| ZS-002-13 | `#002466` | 深色 | 最深蓝 |
|
||||
| ZS-002-14 | `#0079FE → #004AB3` | 线性渐变 | 装饰底色 |
|
||||
| ZS-002-15 | `#55A6FE → #0079FE` | 径向渐变 | 装饰底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.4 辅色 · 渐橙系(FS-001)
|
||||
|
||||
用于警告、进行中、待处理等中性偏提醒状态。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| FS-001 | `#D97B00` | 深色 | 橙色代表色(基准) |
|
||||
| FS-001-01 | `#FFFCF9` | 浅色 | 极浅橙,大面积底色 |
|
||||
| FS-001-02 | `#FFFAF4` | 浅色 | 浅橙底色 |
|
||||
| FS-001-03 | `#FFF6EA` | 浅色 | 浅橙底色 / 警告背景 |
|
||||
| FS-001-04 | `#FFEED4` | 中亮色 | — |
|
||||
| FS-001-05 | `#FFDDAA` | 中亮色 | — |
|
||||
| FS-001-06 | `#FFCC80` | 中亮色 | — |
|
||||
| FS-001-07 | `#FFBB55` | 中亮色 | 浅橙 Tag / 图表 |
|
||||
| FS-001-08 | `#FFAA2B` | 中亮色 | — |
|
||||
| FS-001-09 | `#FF9900` | 中亮色 | **标准橙**,警告主色 |
|
||||
| FS-001-10 | `#C66D00` | 深色 | 深橙,Hover |
|
||||
| FS-001-11 | `#B35F00` | 深色 | 深橙,Active |
|
||||
| FS-001-12 | `#8C4600` | 深色 | 极深橙 |
|
||||
| FS-001-13 | `#663000` | 深色 | 最深橙 |
|
||||
| FS-001-14 | `#FF9900 → #B35F00` | 线性渐变 | 装饰底色 |
|
||||
| FS-001-15 | `#FFBB55 → #FF9900` | 径向渐变 | 装饰底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.5 辅色 · 渐绿系(FS-002)
|
||||
|
||||
用于成功、在线、通过、已完成等正向状态。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| FS-002 | `#1EB07F` | 深色 | 绿色代表色(基准) |
|
||||
| FS-002-01 | `#FAFEFD` | 浅色 | 极浅绿,大面积底色 |
|
||||
| FS-002-02 | `#F6FDFB` | 浅色 | 浅绿底色 |
|
||||
| FS-002-03 | `#EEFCF7` | 浅色 | 浅绿底色 / 成功背景 |
|
||||
| FS-002-04 | `#DCF8EE` | 中亮色 | — |
|
||||
| FS-002-05 | `#BAF1DD` | 中亮色 | — |
|
||||
| FS-002-06 | `#97EBCD` | 中亮色 | — |
|
||||
| FS-002-07 | `#74E4BC` | 中亮色 | 浅绿 Tag / 图表 |
|
||||
| FS-002-08 | `#52DDAB` | 中亮色 | — |
|
||||
| FS-002-09 | `#2FD69A` | 中亮色 | **标准绿**,成功主色 |
|
||||
| FS-002-10 | `#189D72` | 深色 | 深绿,Hover |
|
||||
| FS-002-11 | `#118A65` | 深色 | 深绿,Active |
|
||||
| FS-002-12 | `#07634B` | 深色 | 极深绿 |
|
||||
| FS-002-13 | `#043D30` | 深色 | 最深绿 |
|
||||
| FS-002-14 | `#2FD69A → #118A65` | 线性渐变 | 装饰底色 |
|
||||
| FS-002-15 | `#74E4BC → #2FD69A` | 径向渐变 | 装饰底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.6 辅色 · 渐青系(FS-003)
|
||||
|
||||
用于数据高亮、图表配色、辅助信息标识。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| FS-003 | `#2F9ACC` | 深色 | 青色代表色(基准) |
|
||||
| FS-003-01 | `#FBFDFE` | 浅色 | 极浅青,大面积底色 |
|
||||
| FS-003-02 | `#F7FCFE` | 浅色 | 浅青底色 |
|
||||
| FS-003-03 | `#EFFAFE` | 浅色 | 浅青底色 |
|
||||
| FS-003-04 | `#E0F5FD` | 中亮色 | — |
|
||||
| FS-003-05 | `#C1EBFB` | 中亮色 | — |
|
||||
| FS-003-06 | `#A2E1F9` | 中亮色 | — |
|
||||
| FS-003-07 | `#83D7F7` | 中亮色 | 浅青 Tag / 图表 |
|
||||
| FS-003-08 | `#64CDF5` | 中亮色 | — |
|
||||
| FS-003-09 | `#45C3F3` | 中亮色 | **标准青**,数据高亮主色 |
|
||||
| FS-003-10 | `#2788B9` | 深色 | 深青,Hover |
|
||||
| FS-003-11 | `#1E76A6` | 深色 | 深青,Active |
|
||||
| FS-003-12 | `#115580` | 深色 | 极深青 |
|
||||
| FS-003-13 | `#0B3959` | 深色 | 最深青 |
|
||||
| FS-003-14 | `#45C3F3 → #1E76A6` | 线性渐变 | 装饰底色 |
|
||||
| FS-003-15 | `#83D7F7 → #45C3F3` | 径向渐变 | 装饰底色 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.7 辅色 · 中性灰系(FS-004)
|
||||
|
||||
承载页面背景、正文、备注文字、图标与分割线。浅色主题的核心承载色系。
|
||||
|
||||
| 编号 | 色值 | 明度分组 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| FS-004 | `#222222` | 深色 | 中性代表色(基准) |
|
||||
| FS-004-01 | `#FFFFFF` | 浅色 | 纯白,页面 / 容器背景、白色文字 |
|
||||
| FS-004-02 | `#FAFAFA` | 浅色 | 浅灰背景 |
|
||||
| FS-004-03 | `#F5F5F5` | 浅色 | 浅灰背景 / 分割区底 |
|
||||
| FS-004-04 | `#E8E8E8` | 中亮色 | 分割线 / 边框 |
|
||||
| FS-004-05 | `#DBDBDB` | 中亮色 | 边框 / 禁用底 |
|
||||
| FS-004-06 | `#C1C1C1` | 中亮色 | 禁用文字 / 占位符 |
|
||||
| FS-004-07 | `#A6A6A6` | 中亮色 | 备注文字 / 图标 |
|
||||
| FS-004-08 | `#7F7F7F` | 中亮色 | 次级文字 |
|
||||
| FS-004-09 | `#575757` | 中亮色 | 次要正文 |
|
||||
| FS-004-10 | `#3D3D3D` | 深色 | 正文加强 |
|
||||
|
||||
> 灰系用途分层:`01 ~ 03` 背景 / 白色文字 / 分割线;`04 ~ 09` 备注文字及图标;`10` 与基准 `#222222` 用于正文。
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.8 功能色(主色 / 字体色 / 辅色 / 背景色)
|
||||
|
||||
从标准色系中提取,用于具体 UI 角色指定。
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 主色(Primary) | `#F5222D` | ZS-001-09 |
|
||||
| 主色 Hover | `#CF1322` | ZS-001 |
|
||||
| 主色 Active | `#A8071A` | ZS-001-11 |
|
||||
| 信息 / 链接色 | `#0079FE` | ZS-002-09 |
|
||||
| 成功色 | `#2FD69A` | FS-002-09 |
|
||||
| 警告色 | `#FF9900` | FS-001-09 |
|
||||
| 错误色 | `#F5222D` | ZS-001-09 |
|
||||
| 正文字体色 | `#222222` | FS-004 |
|
||||
| 次级字体色 | `#575757` | FS-004-09 |
|
||||
| 备注 / 占位字体色 | `#A6A6A6` | FS-004-07 |
|
||||
| 禁用字体色 | `#C1C1C1` | FS-004-06 |
|
||||
| 页面背景色 | `#FAFAFA` | FS-004-02 |
|
||||
| 容器背景色 | `#FFFFFF` | FS-004-01 |
|
||||
| 分割线 | `#E8E8E8` | FS-004-04 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.9 小面积装饰色
|
||||
|
||||
用于图标点缀、徽标、少量强调,不用于大面积背景。
|
||||
|
||||
| 色值 | 来源 | 说明 |
|
||||
|------|------|------|
|
||||
| `#F5222D` | ZS-001-09 | 红色,危险 / 品牌徽标 |
|
||||
| `#0079FE` | ZS-002-09 | 蓝色,信息点缀 |
|
||||
| `#FF9900` | FS-001-09 | 橙色,提醒点缀 |
|
||||
| `#2FD69A` | FS-002-09 | 绿色,在线点 |
|
||||
| `#45C3F3` | FS-003-09 | 青色,数据点缀 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.10 图表配色
|
||||
|
||||
> **以 §25.1 图表通用色序为准**。本小节给出的是从主 / 辅色提取的强调型色序,适用于需要突出对比的少量序列;柱状 / 饼 / 环 / 面积等多分类图表的标准柔和色序见 [05-图表](05-图表.md)(§25)。
|
||||
|
||||
**通用图表色序**(面积较大,如柱状图、折线图、饼图):
|
||||
|
||||
| 序号 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 1 | `#F5222D` | ZS-001-09 |
|
||||
| 2 | `#0079FE` | ZS-002-09 |
|
||||
| 3 | `#FF9900` | FS-001-09 |
|
||||
| 4 | `#2FD69A` | FS-002-09 |
|
||||
| 5 | `#45C3F3` | FS-003-09 |
|
||||
| 6 | `#FA9196` | ZS-001-06 |
|
||||
| 7 | `#55A6FE` | ZS-002-07 |
|
||||
| 8 | `#FFBB55` | FS-001-07 |
|
||||
|
||||
**小面积图表色序**(面积较小,如散点、小徽章、迷你图):
|
||||
|
||||
| 序号 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 1 | `#F86C73` | ZS-001-07 |
|
||||
| 2 | `#55A6FE` | ZS-002-07 |
|
||||
| 3 | `#74E4BC` | FS-002-07 |
|
||||
| 4 | `#FFBB55` | FS-001-07 |
|
||||
| 5 | `#83D7F7` | FS-003-07 |
|
||||
| 6 | `#A6A6A6` | FS-004-07 |
|
||||
|
||||
---
|
||||
|
||||
#### 1.1.11 CSS Token 建议
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* 主色 · 渐红系 ZS-001 */
|
||||
--zs-001: #CF1322;
|
||||
--zs-001-01: #FEFAFA; --zs-001-02: #FEF6F6; --zs-001-03: #FEEDED;
|
||||
--zs-001-04: #FDDADC; --zs-001-05: #FCB5B9; --zs-001-06: #FA9196;
|
||||
--zs-001-07: #F86C73; --zs-001-08: #F74750; --zs-001-09: #F5222D;
|
||||
--zs-001-10: #BC0D1E; --zs-001-11: #A8071A; --zs-001-12: #820014;
|
||||
--zs-001-13: #5C0011;
|
||||
|
||||
/* 主色 · 渐蓝系 ZS-002 */
|
||||
--zs-002: #0062D9;
|
||||
--zs-002-01: #F9FCFF; --zs-002-02: #F4F9FF; --zs-002-03: #EAF4FF;
|
||||
--zs-002-04: #D4E9FF; --zs-002-05: #AAD2FF; --zs-002-06: #80BCFF;
|
||||
--zs-002-07: #55A6FE; --zs-002-08: #2B8FFE; --zs-002-09: #0079FE;
|
||||
--zs-002-10: #0056C6; --zs-002-11: #004AB3; --zs-002-12: #00368C;
|
||||
--zs-002-13: #002466;
|
||||
|
||||
/* 辅色 · 渐橙系 FS-001 */
|
||||
--fs-001: #D97B00;
|
||||
--fs-001-01: #FFFCF9; --fs-001-02: #FFFAF4; --fs-001-03: #FFF6EA;
|
||||
--fs-001-04: #FFEED4; --fs-001-05: #FFDDAA; --fs-001-06: #FFCC80;
|
||||
--fs-001-07: #FFBB55; --fs-001-08: #FFAA2B; --fs-001-09: #FF9900;
|
||||
--fs-001-10: #C66D00; --fs-001-11: #B35F00; --fs-001-12: #8C4600;
|
||||
--fs-001-13: #663000;
|
||||
|
||||
/* 辅色 · 渐绿系 FS-002 */
|
||||
--fs-002: #1EB07F;
|
||||
--fs-002-01: #FAFEFD; --fs-002-02: #F6FDFB; --fs-002-03: #EEFCF7;
|
||||
--fs-002-04: #DCF8EE; --fs-002-05: #BAF1DD; --fs-002-06: #97EBCD;
|
||||
--fs-002-07: #74E4BC; --fs-002-08: #52DDAB; --fs-002-09: #2FD69A;
|
||||
--fs-002-10: #189D72; --fs-002-11: #118A65; --fs-002-12: #07634B;
|
||||
--fs-002-13: #043D30;
|
||||
|
||||
/* 辅色 · 渐青系 FS-003 */
|
||||
--fs-003: #2F9ACC;
|
||||
--fs-003-01: #FBFDFE; --fs-003-02: #F7FCFE; --fs-003-03: #EFFAFE;
|
||||
--fs-003-04: #E0F5FD; --fs-003-05: #C1EBFB; --fs-003-06: #A2E1F9;
|
||||
--fs-003-07: #83D7F7; --fs-003-08: #64CDF5; --fs-003-09: #45C3F3;
|
||||
--fs-003-10: #2788B9; --fs-003-11: #1E76A6; --fs-003-12: #115580;
|
||||
--fs-003-13: #0B3959;
|
||||
|
||||
/* 辅色 · 中性灰系 FS-004 */
|
||||
--fs-004: #222222;
|
||||
--fs-004-01: #FFFFFF; --fs-004-02: #FAFAFA; --fs-004-03: #F5F5F5;
|
||||
--fs-004-04: #E8E8E8; --fs-004-05: #DBDBDB; --fs-004-06: #C1C1C1;
|
||||
--fs-004-07: #A6A6A6; --fs-004-08: #7F7F7F; --fs-004-09: #575757;
|
||||
--fs-004-10: #3D3D3D;
|
||||
|
||||
/* 功能色(语义别名) */
|
||||
--color-primary: var(--zs-001-09); /* #F5222D */
|
||||
--color-primary-hover: var(--zs-001); /* #CF1322 */
|
||||
--color-primary-active: var(--zs-001-11); /* #A8071A */
|
||||
--color-link: var(--zs-002-09); /* #0079FE */
|
||||
--color-success: var(--fs-002-09); /* #2FD69A */
|
||||
--color-warning: var(--fs-001-09); /* #FF9900 */
|
||||
--color-error: var(--zs-001-09); /* #F5222D */
|
||||
--color-text: var(--fs-004); /* #222222 */
|
||||
--color-text-secondary: var(--fs-004-09); /* #575757 */
|
||||
--color-text-tertiary: var(--fs-004-07); /* #A6A6A6 */
|
||||
--color-text-disabled: var(--fs-004-06); /* #C1C1C1 */
|
||||
--color-bg-page: var(--fs-004-02); /* #FAFAFA */
|
||||
--color-bg-container: var(--fs-004-01); /* #FFFFFF */
|
||||
--color-border: var(--fs-004-04); /* #E8E8E8 */
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. 字体
|
||||
|
||||
字体规范分**大屏页面**与**后台系统**两套,分别对应可视化大屏与管理后台两类场景。
|
||||
|
||||
### 2.1 大屏页面字体规范
|
||||
|
||||
#### 2.1.1 中文字体:Noto Sans S Chinese
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 24px Bold | 一级标题 |
|
||||
| 24px Medium | 次要一级标题 |
|
||||
| 22px Medium | 二级标题 |
|
||||
| 22px Regular | 正文 |
|
||||
| 20px Regular | 排版空间有限的正文 |
|
||||
|
||||
#### 2.1.2 数字字体:D-DIN
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 32px Bold | 重要数据展示 |
|
||||
| 32px Regular | 普通数据展示 |
|
||||
| 26px Bold | 常规数据展示 |
|
||||
| 26px Regular | 常规数据展示 |
|
||||
|
||||
#### 2.1.3 特殊数字:DS-Digital
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 50px Bold | 大屏主数据展示 |
|
||||
|
||||
#### 2.1.4 表格数字:Arial
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 20px Regular | 表格横纵轴数字 |
|
||||
|
||||
---
|
||||
|
||||
### 2.2 后台系统字体规范
|
||||
|
||||
#### 2.2.1 中文字体:Noto Sans S Chinese
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 18px Bold | 导航、一级标题 |
|
||||
| 18px Medium | 次要一级标题 |
|
||||
| 16px Bold | 二级标题 |
|
||||
| 16px Medium | 次要二级标题 |
|
||||
| 16px Regular | 正文、按钮内部文字等 |
|
||||
| 16px Light | 次要正文 |
|
||||
|
||||
#### 2.2.2 数字字体:D-DIN
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 26px Bold | 重要数据展示 |
|
||||
| 26px Regular | 普通数据展示 |
|
||||
| 24px Bold | 常规数据展示(小) |
|
||||
| 24px Regular | 常规数据展示(小) |
|
||||
|
||||
#### 2.2.3 LOGO 字体:DOUYUFont
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 20px 文字样式 | 页面顶部系统名称 |
|
||||
|
||||
#### 2.2.4 表格数字:Arial
|
||||
|
||||
| 样式 | 使用场景 |
|
||||
|------|----------|
|
||||
| 16px Regular | 表格横纵轴数字 |
|
||||
| 14px Regular | 表格横纵轴的数字(空间有限) |
|
||||
|
||||
---
|
||||
|
||||
## 3. 阴影
|
||||
|
||||
> 浅色主题采用**中性投影**(基于 FS-004 `#222222`)营造层级,避免使用彩色外发光。卡片以纯白 `#FFFFFF` 浮于浅灰页面背景 `#FAFAFA` 之上,靠投影与边框区分。
|
||||
|
||||
### 3.1 容器与卡片配色
|
||||
|
||||
#### 3.1.1 卡片(标题 + 操作)
|
||||
|
||||
白底卡片,标题在左、操作区在右(文字操作或图标操作)。
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 卡片背景 | `#FFFFFF` | FS-004-01 |
|
||||
| 卡片边框 | `#E8E8E8` | FS-004-04 |
|
||||
| 卡片阴影 | `0 2px 8px rgba(34, 34, 34, 0.08)` | 基于 FS-004 中性投影 |
|
||||
| 标题文字(16px Bold) | `#222222` | FS-004(正文色) |
|
||||
| 操作按钮文字 | `#F5222D` | ZS-001-09(主色红,链接型操作) |
|
||||
| 次级操作图标(✏️ / ⋯) | `#A6A6A6` | FS-004-07(备注图标色) |
|
||||
|
||||
#### 3.1.2 卡片新增(占位卡片)
|
||||
|
||||
虚线描边的"新增入口"卡片,用于引导用户添加内容。
|
||||
|
||||
| 角色 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 卡片背景 | `#FFFFFF` | FS-004-01 |
|
||||
| 虚线边框 | `#DBDBDB` | FS-004-05 |
|
||||
| 加号图标 | `#A6A6A6` | FS-004-07 |
|
||||
| Hover 边框 | `#F5222D` | ZS-001-09(悬停时提示可点击) |
|
||||
| Hover 加号 | `#F5222D` | ZS-001-09 |
|
||||
|
||||
#### 3.1.3 阴影投影规则
|
||||
|
||||
| 层级 | 阴影值 | 使用场景 |
|
||||
|------|--------|----------|
|
||||
| 一级阴影(卡片浮起) | `0 2px 8px rgba(34, 34, 34, 0.08)` | 普通卡片 |
|
||||
| 二级阴影(hover / 强调) | `0 4px 16px rgba(34, 34, 34, 0.12)` | 卡片 hover、悬浮按钮、弹出层 |
|
||||
| 三级阴影(弹窗 / Modal) | `0 8px 32px rgba(34, 34, 34, 0.16)` | Dialog、Drawer |
|
||||
|
||||
---
|
||||
|
||||
## 4. 圆角
|
||||
|
||||
### 4.1 圆角统一规范
|
||||
|
||||
| 元素 | 圆角值 | 说明 |
|
||||
|------|--------|------|
|
||||
| 按钮 | `2px` | 所有按钮(主 / 次要 / 默认 / 文本)统一使用 |
|
||||
| 卡片 | `4px` | 内容卡片、标题+操作卡片、卡片新增占位 |
|
||||
| 页面分栏框 | `4px` | 外层容器、分栏区域 |
|
||||
| 输入框 / 选择器 | `2px` | 与按钮一致,保持表单内对齐 |
|
||||
| Tag / Badge | `2px` | 与按钮一致 |
|
||||
| Modal / Drawer | `4px` | 与卡片一致 |
|
||||
|
||||
---
|
||||
|
||||
## 6. 间距
|
||||
|
||||
> 全站以 `8px (0.5rem)` 为对照基准单位,划分"密 / 疏"两个层次。所有间距取值均来自下列阶梯,禁止使用非阶梯值(如 5px、13px)。
|
||||
|
||||
### 6.1 间距阶梯
|
||||
|
||||
| 阶 | px | rem | 分组 | 典型场景 |
|
||||
|----|------|--------|------|----------|
|
||||
| 1 | `4px` | `0.25rem` | 密 | 图标与文字间距、Tag 内边距、紧凑徽标 |
|
||||
| 2 | `8px` | `0.5rem` | 密 | 行内元素相邻、按钮组间距、表单 label 与控件 |
|
||||
| 3 | `12px` | `0.75rem` | 密 | 表单项垂直间距、列表项内边距 |
|
||||
| 4 | `16px` | `1rem` | 密 | 卡片内容内边距、模块内分隔 |
|
||||
| 5 | `24px` | `1.5rem` | 疏 | 模块之间、Section 内边距 |
|
||||
| 6 | `32px` | `2rem` | 疏 | 卡片之间、表单组之间 |
|
||||
| 7 | `40px` | `2.5rem` | 疏 | 主区块之间、页面 Header / Footer 内边距 |
|
||||
| 8 | `56px` | `3.5rem` | 疏 | 页面段落级隔断、Banner 区域 |
|
||||
|
||||
> "密"对应紧凑信息密度(表格、表单、卡片内部);"疏"对应视觉呼吸(模块之间、页面整体留白)。**16px 是"密"的上限,24px 是"疏"的下限**,两者之间不应再插入自定义值。
|
||||
|
||||
### 6.2 使用原则
|
||||
|
||||
- **同层级一致**:同一布局层级内的间距必须使用同一阶值;多种取值会破坏节奏。
|
||||
- **就近取阶**:相邻区块的间距尽量从相邻阶梯取值(如 `16px → 24px`),跨越过多阶(如 `8px → 56px`)会让视觉断裂。
|
||||
- **密疏不混用**:一个组件内部全部用"密",外部用"疏",避免内 / 外间距颠倒。
|
||||
- **优先 8 的倍数**:除最小阶 `4px` 外,所有阶皆为 8 的倍数,方便 4/8 网格对齐。
|
||||
- **响应式按比例衰减**:移动端可整体降一阶(如 `24px → 16px`),但仍在阶梯内。
|
||||
|
||||
### 6.3 CSS Token 建议
|
||||
|
||||
```css
|
||||
:root {
|
||||
--spacing-1: 4px; /* 0.25rem */
|
||||
--spacing-2: 8px; /* 0.5rem */
|
||||
--spacing-3: 12px; /* 0.75rem */
|
||||
--spacing-4: 16px; /* 1rem */
|
||||
--spacing-5: 24px; /* 1.5rem */
|
||||
--spacing-6: 32px; /* 2rem */
|
||||
--spacing-7: 40px; /* 2.5rem */
|
||||
--spacing-8: 56px; /* 3.5rem */
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 20. 语义状态色(统一约定)
|
||||
|
||||
> 进度、状态标签、表格状态、时间轴等大量组件共用同一套语义色。后续章节直接引用本表。
|
||||
|
||||
| 语义 | 文字色 | 浅底背景 | 实填背景 | 来源 |
|
||||
|------|--------|----------|----------|------|
|
||||
| 成功 / 完成(绿) | `#189D72` (FS-002-10) | `#EEFCF7` (FS-002-03) | `#2FD69A` (FS-002-09) | 渐绿系 |
|
||||
| 警告 / 进行中(橙) | `#FF9900` (FS-001-09) | `#FFF6EA` (FS-001-03) | `#FF9900` (FS-001-09) | 渐橙系 |
|
||||
| 错误 / 失败(红) | `#F5222D` (ZS-001-09) | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) | 渐红系 |
|
||||
| 信息 / 等待(蓝) | `#0079FE` (ZS-002-09) | `#EAF4FF` (ZS-002-03) | `#0079FE` (ZS-002-09) | 渐蓝系 |
|
||||
| 待更新(青) | `#45C3F3` (FS-003-09) | `#EFFAFE` (FS-003-03) | `#45C3F3` (FS-003-09) | 渐青系 |
|
||||
| 未开始 / 中性(灰) | `#7F7F7F` (FS-004-08) | `#F5F5F5` (FS-004-03) | `#A6A6A6` (FS-004-07) | 中性灰系 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,314 @@
|
||||
# 浅红色 UI 规范 · 二、按钮与表单输入
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:按钮 · 表单 · 输入框 · 选择按钮 · 标签输入框 · 上传
|
||||
|
||||
---
|
||||
|
||||
## 5. 按钮
|
||||
|
||||
> 全部圆角 `2px`,文字字号 `14px`,字体 Noto Sans S Chinese Regular。配色取自 ZS-001 主色红与 FS-004 中性灰。
|
||||
|
||||
### 5.1 按钮尺寸
|
||||
|
||||
| 规格 | 高度 | 内边距 | 使用场景 |
|
||||
|------|------|--------|----------|
|
||||
| 小 | `24px` | `0 8px` | 空间小的板块内部,如表格中、卡片标题等 |
|
||||
| 正常 | `32px` | `0 14px` | 默认尺寸,所有常用按钮 |
|
||||
|
||||
### 5.2 按钮类型与配色
|
||||
|
||||
#### 5.2.1 主按钮(Primary)
|
||||
|
||||
> 一个操作区域只能有一个主按钮。
|
||||
|
||||
| 状态 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `#F5222D` (ZS-001-09) | — | `#FFFFFF` |
|
||||
| Hover | `#CF1322` (ZS-001) | — | `#FFFFFF` |
|
||||
| Active | `#A8071A` (ZS-001-11) | — | `#FFFFFF` |
|
||||
| 失效 | `#A6A6A6` (FS-004-07) | — | `#FFFFFF` |
|
||||
|
||||
#### 5.2.2 次要按钮(Secondary / Outline-Primary)
|
||||
|
||||
重要度低于主按钮、高于默认按钮。红色描边 + 红色文字。
|
||||
|
||||
| 状态 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `#FFFFFF` | `#F5222D` (ZS-001-09) | `#F5222D` (ZS-001-09) |
|
||||
| Hover | `#FEEDED` (ZS-001-03) | `#CF1322` (ZS-001) | `#CF1322` (ZS-001) |
|
||||
| Active | `#FDDADC` (ZS-001-04) | `#A8071A` (ZS-001-11) | `#A8071A` (ZS-001-11) |
|
||||
| 失效 | `#FFFFFF` | `#FCB5B9` (ZS-001-05) | `#FCB5B9` (ZS-001-05) |
|
||||
|
||||
#### 5.2.3 默认按钮(Default)
|
||||
|
||||
用于"取消 / 返回"等次要操作,与主按钮成对出现时主按钮在右。中性描边。
|
||||
|
||||
| 状态 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 默认 | `#FFFFFF` | `#DBDBDB` (FS-004-05) | `#222222` (FS-004) |
|
||||
| Hover | `#FAFAFA` (FS-004-02) | `#F5222D` (ZS-001-09) | `#F5222D` (ZS-001-09) |
|
||||
| Active | `#F5F5F5` (FS-004-03) | `#CF1322` (ZS-001) | `#CF1322` (ZS-001) |
|
||||
| 禁用 | `#F5F5F5` (FS-004-03) | `#E8E8E8` (FS-004-04) | `#C1C1C1` (FS-004-06) |
|
||||
|
||||
#### 5.2.4 文本按钮(Text)
|
||||
|
||||
用于表格操作、文件下载等。无背景与边框,靠文字色识别。
|
||||
|
||||
| 状态 | 文字 | 装饰 |
|
||||
|------|------|------|
|
||||
| 默认 | `#F5222D` (ZS-001-09) | 无下划线 |
|
||||
| Hover | `#CF1322` (ZS-001) | 显示下划线(与文字同色) |
|
||||
| Active | `#A8071A` (ZS-001-11) | 下划线 |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) | 无装饰 |
|
||||
|
||||
#### 5.2.5 图标按钮(Icon-only)
|
||||
|
||||
用于增强辨识度或节省空间。仅图标,无文字。
|
||||
|
||||
| 变体 | 背景 | 边框 | 图标颜色 |
|
||||
|------|------|------|----------|
|
||||
| 描边(默认) | `#FFFFFF` | `#DBDBDB` (FS-004-05) | `#575757` (FS-004-09) |
|
||||
| 描边 Hover | `#FAFAFA` | `#F5222D` (ZS-001-09) | `#F5222D` (ZS-001-09) |
|
||||
| 主色(填充) | `#F5222D` (ZS-001-09) | — | `#FFFFFF` |
|
||||
| 主色 Hover | `#CF1322` (ZS-001) | — | `#FFFFFF` |
|
||||
| 浅色(弱填充) | `#FEEDED` (ZS-001-03) | — | `#F5222D` (ZS-001-09) |
|
||||
|
||||
### 5.3 按钮组合
|
||||
|
||||
#### 5.3.1 文字 + 下拉按钮(含 ⌄)
|
||||
|
||||
| 形态 | 配色规则 |
|
||||
|------|----------|
|
||||
| 默认(Outline) | 沿用 §5.2.3 默认按钮,箭头 ⌄ 与文字同色 `#222222` |
|
||||
| 主色(Filled) | 沿用 §5.2.1 主按钮,箭头 ⌄ 同步白色 `#FFFFFF` |
|
||||
|
||||
#### 5.3.2 图标 + 文字按钮(如 `+ 正常`)
|
||||
|
||||
| 形态 | 配色规则 |
|
||||
|------|----------|
|
||||
| 默认(Outline) | 沿用 §5.2.3,左侧图标颜色与文字一致 `#222222` |
|
||||
| 主色(Filled) | 沿用 §5.2.1,左侧图标与文字一致 `#FFFFFF` |
|
||||
|
||||
#### 5.3.3 文本按钮 + 图标("更多 »"、"展开 ⌄"、"下一页 »"、"« 上一页"、"收起 ^")
|
||||
|
||||
| 角色 | 色值 |
|
||||
|------|------|
|
||||
| 文字 + 图标(默认) | `#F5222D` (ZS-001-09) |
|
||||
| 文字 + 图标(Hover) | `#CF1322` (ZS-001) |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) |
|
||||
|
||||
> 图标可在文字前或后;多个文本按钮排成一行时,间距 `16px`,无分隔符。
|
||||
|
||||
#### 5.3.4 主按钮 + 默认按钮组合(如"确定 / 取消 / 返回")
|
||||
|
||||
- **排列顺序**:默认按钮在左,主按钮在右(最右侧为主操作)
|
||||
- **按钮间距**:`8px`
|
||||
- **示例**:`[ 返回 ] [ 取消 ] [ 确定 ]`
|
||||
- **配色**:主按钮沿用 §5.2.1,其余沿用 §5.2.3
|
||||
|
||||
### 5.4 其他按钮
|
||||
|
||||
#### 5.4.1 悬浮状态(Floating)
|
||||
|
||||
用于 Banner / 登录 / 视觉冲击强等展示场景。配色与主按钮一致,叠加阴影抬升。
|
||||
|
||||
| 状态 | 阴影 |
|
||||
|------|------|
|
||||
| 默认 | `0 2px 8px rgba(34, 34, 34, 0.08)`(§3.1.3 一级阴影) |
|
||||
| Hover | `0 4px 16px rgba(34, 34, 34, 0.12)`(§3.1.3 二级阴影) |
|
||||
| Active | 阴影消失,按下感 |
|
||||
|
||||
#### 5.4.2 加载中(Loading)
|
||||
|
||||
用于异步操作等待反馈。点击瞬间将按钮锁定,文字前显示旋转图标。
|
||||
|
||||
| 角色 | 色值 |
|
||||
|------|------|
|
||||
| 背景 | `#F5222D` (ZS-001-09) |
|
||||
| 文字 | `#FFFFFF` |
|
||||
| 加载图标 | `#FFFFFF`,旋转动画 `1.2s linear infinite` |
|
||||
| 不可点击 | 鼠标 `cursor: not-allowed` |
|
||||
|
||||
> 与失效态的区别:失效是"不可操作",加载是"操作进行中"——保留品牌主色,只是不可再次触发。
|
||||
|
||||
---
|
||||
|
||||
## 12. 表单(Form)
|
||||
|
||||
> 页面级表单可参照弹窗表单,**操作按钮置于左下角**。容器为白底卡片,标题下叠 `1px solid #E8E8E8` 分割线。
|
||||
|
||||
### 12.1 基础表单结构
|
||||
|
||||
| 元素 | 规格 / 配色 |
|
||||
|------|-------------|
|
||||
| 容器背景 | `#FFFFFF` (FS-004-01),圆角 `4px` |
|
||||
| 表单标题 | `16px Bold`,`#222222` (FS-004),下叠 `1px solid #E8E8E8` |
|
||||
| 字段标签(label) | `14px Regular`,`#575757` (FS-004-09),左对齐 |
|
||||
| 字段垂直间距 | `--spacing-3` (12px) |
|
||||
| 输入控件 | 见 §13 输入框 |
|
||||
| 操作按钮区 | 置于左下角,主按钮 + 默认按钮(§5.3.4),间距 `--spacing-2` (8px) |
|
||||
|
||||
### 12.2 开关(Switch)
|
||||
|
||||
| 状态 | 轨道背景 | 滑块 | 文字 |
|
||||
|------|----------|------|------|
|
||||
| 开(ON) | `#F5222D` (ZS-001-09) | `#FFFFFF` 圆点 | "开" `#FFFFFF` |
|
||||
| 关(OFF) | `#DBDBDB` (FS-004-05) | `#FFFFFF` 圆点 | "关" `#A6A6A6` (FS-004-07) |
|
||||
| 禁用 | `#E8E8E8` (FS-004-04) | `#FFFFFF` | `#C1C1C1` |
|
||||
|
||||
- 轨道高 `20px`,圆角全圆;切换过渡 `transform 160ms ease-out`
|
||||
|
||||
### 12.3 表格内报错(Table 报错)
|
||||
|
||||
行内可编辑表格的校验错误态。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 表头背景 | `#FEEDED` (ZS-001-03) |
|
||||
| 表头文字 | `#222222` (FS-004),`14px Medium` |
|
||||
| 行(默认) | 背景 `#FFFFFF`,底边 `1px solid #F5F5F5` (FS-004-03) |
|
||||
| 行(hover / 选中) | 背景 `#FEF6F6` (ZS-001-02) |
|
||||
| 正文文字 | `#222222` (FS-004) |
|
||||
| 错误输入框边框 | `1px solid #F5222D` (ZS-001-09) |
|
||||
| 单位后缀(如 `M`) | addon 背景 `#FAFAFA`,边框 `#DBDBDB`,文字 `#575757` |
|
||||
| 错误提示气泡 | 背景 `#F5222D`,文字 `#FFFFFF` `12px`,圆角 `2px`,带向上箭头,定位于出错输入框下方 |
|
||||
| 复选框(选中) | 勾选填充 `#F5222D`,对勾 `#FFFFFF` |
|
||||
|
||||
---
|
||||
|
||||
## 13. 输入框(Input)
|
||||
|
||||
> 字号 `16px`,高度 `32px`,圆角 `2px`,内边距 `0 12px`,背景 `#FFFFFF`。
|
||||
|
||||
### 13.1 基础状态
|
||||
|
||||
| 状态 | 边框 | 背景 | 文字 / 占位符 |
|
||||
|------|------|------|--------------|
|
||||
| 未填(默认) | `1px solid #DBDBDB` (FS-004-05) | `#FFFFFF` | 占位符 `#A6A6A6` (FS-004-07) |
|
||||
| 聚焦(Focus) | `1px solid #F5222D` (ZS-001-09) | `#FFFFFF` | 文字 `#222222` |
|
||||
| 已填 | `1px solid #DBDBDB` | `#FFFFFF` | 文字 `#222222` (FS-004) |
|
||||
| 未填 · 禁用 | `1px solid #E8E8E8` (FS-004-04) | `#F5F5F5` (FS-004-03) | 占位符 `#C1C1C1` (FS-004-06),`cursor: not-allowed` |
|
||||
| 已填 · 禁用 | `1px solid #E8E8E8` | `#F5F5F5` | 文字 `#A6A6A6` |
|
||||
| 错误(Error) | `1px solid #F5222D` | `#FFFFFF` | 文字 `#222222`,下方红色提示文字 `12px #F5222D` |
|
||||
|
||||
### 13.2 带操作 / 特殊输入框
|
||||
|
||||
| 类型 | 说明 | 配色 |
|
||||
|------|------|------|
|
||||
| 未填 / 已填 · 操作 | 尾部带操作图标(如 ⚙) | 图标 `#A6A6A6`,hover `#F5222D` |
|
||||
| 密码 · 不可见 | 尾部带可见性切换 👁 | 图标 `#A6A6A6`,点击切换明 / 密文 |
|
||||
| 前置标签 | 头部下拉(如 `http:// ▾`) | addon 背景 `#FAFAFA`,边框 `#DBDBDB`,文字 `#575757` |
|
||||
| 后置标签 | 尾部下拉(如 `.com ▾`) | 同前置标签 |
|
||||
| 前后置标签 | 头尾各一段 addon | 同上;输入区与 addon 共用一条外边框 |
|
||||
|
||||
---
|
||||
|
||||
## 14. 选择按钮(单选 / 多选式)
|
||||
|
||||
> 以按钮形态替代传统单选 / 复选,提升点击区域与辨识度。每组提供三种"已选"填充强度,可按对比需要选用;布局分**相连**(segmented)与**分离**两种。
|
||||
|
||||
### 14.1 选择按钮(基础)
|
||||
|
||||
| 状态 / 变体 | 背景 | 边框 | 文字 |
|
||||
|------|------|------|------|
|
||||
| 未选 | `#FFFFFF` | `1px solid #DBDBDB` (FS-004-05) | `#222222` (FS-004) |
|
||||
| 已选 · 描边 | `#FFFFFF` | `1px solid #F5222D` (ZS-001-09) | `#F5222D` (ZS-001-09) |
|
||||
| 已选 · 浅填 | `#FEEDED` (ZS-001-03) | `1px solid #FCB5B9` (ZS-001-05) | `#F5222D` (ZS-001-09) |
|
||||
| 已选 · 实填 | `#F5222D` (ZS-001-09) | — | `#FFFFFF` |
|
||||
| 禁用 | `#F5F5F5` (FS-004-03) | `1px solid #E8E8E8` | `#C1C1C1` (FS-004-06) |
|
||||
|
||||
- 高度 `32px`,内边距 `0 14px`,圆角 `2px`,字号 `14px`
|
||||
- **相连布局**:按钮紧贴,仅最外两端圆角,相邻共用边框
|
||||
- **分离布局**:按钮间距 `--spacing-2` (8px),各自独立圆角
|
||||
|
||||
### 14.2 选择按钮(带统计)
|
||||
|
||||
在文案后附计数,如 `已选(230)`。配色完全沿用 §14.1,计数文字与主文字同色(实填态为 `#FFFFFF`)。
|
||||
|
||||
### 14.3 按钮式页签(带图标)
|
||||
|
||||
文案前带图标(如 `田`),用于视图 / 模式切换。
|
||||
|
||||
| 状态 / 变体 | 背景 | 边框 | 图标 + 文字 |
|
||||
|------|------|------|-------------|
|
||||
| 正常(未激活) | `#FFFFFF` | `1px solid #DBDBDB` | `#222222` |
|
||||
| 激活 · 描边 | `#FFFFFF` | `1px solid #F5222D` | `#F5222D` |
|
||||
| 激活 · 实填 | `#F5222D` (ZS-001-09) | — | `#FFFFFF` |
|
||||
|
||||
- 图标与文字间距 `--spacing-1` (4px),其余规格同 §14.1
|
||||
|
||||
---
|
||||
|
||||
## 15. 标签输入框(Tag Input)
|
||||
|
||||
> 在输入框内以"标签 + 自由输入"混合录入,支持单行 / 多行,含字数统计。
|
||||
|
||||
### 15.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器边框 | `1px solid #DBDBDB` (FS-004-05),圆角 `2px` |
|
||||
| 聚焦边框 | `1px solid #F5222D` (ZS-001-09) |
|
||||
| 容器背景 | `#FFFFFF` |
|
||||
| 内边距 | `--spacing-2` (8px) |
|
||||
| 标签与标签间距 | `--spacing-1` (4px) |
|
||||
| 右下角支持拖拽缩放(多行) | `resize: vertical` |
|
||||
|
||||
### 15.2 标签(Tag)配色
|
||||
|
||||
| 元素 | 色值 | 来源 |
|
||||
|------|------|------|
|
||||
| 标签背景 | `#F5F5F5` (FS-004-03) | — |
|
||||
| 标签文字 | `#575757` (FS-004-09) | — |
|
||||
| 关闭图标 `×` | `#A6A6A6` (FS-004-07) | hover `#F5222D` |
|
||||
| 占位符(请输入) | `#A6A6A6` (FS-004-07) | — |
|
||||
| 字数统计(如 `2/100`) | `#A6A6A6` (FS-004-07) | 超限时变 `#F5222D` |
|
||||
|
||||
> 折叠多标签时可用 `+N` 形式聚合(如 `+1 ×`),样式同普通标签。
|
||||
|
||||
---
|
||||
|
||||
## 16. 上传(Upload)
|
||||
|
||||
> 含单文件、批量上传、拖拽上传三种形态。操作按钮中"开始上传 / 上传"为主按钮,"取消"为默认按钮。
|
||||
|
||||
### 16.1 上传触发器
|
||||
|
||||
| 形态 | 配色 |
|
||||
|------|------|
|
||||
| 上传按钮(⬆ 上传文件) | 默认按钮(§5.2.3),含上传图标 |
|
||||
| 选择文件输入 | 只读输入框(§13)+ 右侧"选择文件"默认按钮 |
|
||||
| 提示文字 | `12px Regular`,`#A6A6A6` (FS-004-07),如"支持 DOCX/ZIP/PDF,文件大小不超过 2MB" |
|
||||
| 示例文件链接(下载 / 查看示例文件) | 文本按钮 `#F5222D` (ZS-001-09),hover `#CF1322` |
|
||||
|
||||
### 16.2 拖拽区(Drop Zone)
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 背景 | `#FAFAFA` (FS-004-02) |
|
||||
| 边框 | `1px dashed #DBDBDB` (FS-004-05) |
|
||||
| 拖入高亮 | 边框 `1px dashed #F5222D` (ZS-001-09),背景 `#FEF6F6` (ZS-001-02) |
|
||||
| 提示文字(释放鼠标) | `#A6A6A6` (FS-004-07) |
|
||||
|
||||
### 16.3 文件列表与状态
|
||||
|
||||
列表表头:文件名 / 大小 / 状态 / 操作。各状态配色:
|
||||
|
||||
| 状态 | 图标 | 文字色 |
|
||||
|------|------|--------|
|
||||
| 上传成功 | ✓ 圆形,`#2FD69A` (FS-002-09) | `#189D72` (FS-002-10) |
|
||||
| 文件格式有误 / 失败 | ❗ 圆形,`#F5222D` (ZS-001-09) | `#F5222D` |
|
||||
| 上传中(如 上传 40%) | ⟳ 旋转,`#F5222D` (ZS-001-09) | `#575757` (FS-004-09) |
|
||||
| 待上传 | 🕐 时钟,`#A6A6A6` (FS-004-07) | `#A6A6A6` |
|
||||
| 操作列「删除」 | — | 文本按钮 `#A6A6A6`,hover `#F5222D` |
|
||||
|
||||
### 16.4 底部操作
|
||||
|
||||
`[ 取消 ](默认按钮) [ 开始上传 ](主按钮 #F5222D)`,间距 `--spacing-2` (8px),右对齐。
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,495 @@
|
||||
# 浅红色 UI 规范 · 三、导航
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:导航组件 · 面包屑 · 页头与分页 · 步骤条 · 页签与锚点
|
||||
|
||||
---
|
||||
|
||||
## 7. 导航组件
|
||||
|
||||
> 适用于"后台 / 控制台"类浅红主题界面。整体结构 = 顶部导航(红底)+ 二级导航(白底)+ 左侧分级菜单 + 多级下拉。颜色取自 ZS-001 主色红与 FS-004 中性灰。
|
||||
|
||||
### 7.1 顶部导航(Header · 红底)
|
||||
|
||||
#### 7.1.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 高度 | `56px` |
|
||||
| 左右 padding | `--spacing-4` (16px) |
|
||||
| 背景 | `linear-gradient(90deg, #A8071A 0%, #CF1322 100%)`(ZS-001-11 → ZS-001) |
|
||||
| LOGO 区切角装饰 | 叠深红斜切块 `#A8071A` (ZS-001-11),`clip-path` 斜边 |
|
||||
| 底边 | 无(与二级导航白底直接相接) |
|
||||
| 文字基线 | `Noto Sans S Chinese`,垂直居中 |
|
||||
|
||||
#### 7.1.2 系统标题(LOGO + ******系统)
|
||||
|
||||
- 字号 `20px Bold`,颜色 `#FFFFFF`,字体 `DOUYUFont` 或 Noto Sans Medium
|
||||
- LOGO 图标 `#FFFFFF`,置于左侧切角块上
|
||||
|
||||
#### 7.1.3 一级导航(中部主导航,红底白字)
|
||||
|
||||
| 状态 | 文字 | 背景 / 装饰 |
|
||||
|------|------|------------|
|
||||
| 默认 | `#FFFFFF` | `transparent` |
|
||||
| Hover | `#FFFFFF` | 背景 `rgba(255, 255, 255, 0.12)` |
|
||||
| 激活 | `#FFFFFF` | 底部 `2px solid #FFFFFF` 高亮线,背景 `rgba(255, 255, 255, 0.16)` |
|
||||
|
||||
- 字号 `16px Medium`,项间距 `--spacing-5` (24px)
|
||||
|
||||
#### 7.1.4 右侧工具区(图标 / 用户 / 退出)
|
||||
|
||||
| 元素 | 字号/尺寸 | 颜色 |
|
||||
|------|----------|------|
|
||||
| 工具图标(消息 / 通知等) | `16px` | `#FFFFFF`,hover `rgba(255,255,255,0.7)` |
|
||||
| 用户名(如"李向前") | `14px Regular` | `#FFFFFF` |
|
||||
| 用户头像 | `28px` 圆形 | — |
|
||||
| 退出图标 | `16px` | `#FFFFFF` |
|
||||
|
||||
- 元素间距 `--spacing-3` (12px),整体右 padding `--spacing-4` (16px)
|
||||
|
||||
#### 7.1.5 用户下拉菜单(右上角)
|
||||
|
||||
白底面板,规格同 §7.4 下拉面板。
|
||||
|
||||
| 状态 | 背景 | 文字 / 图标 |
|
||||
|------|------|-------------|
|
||||
| 默认 | `transparent` | `#575757` (FS-004-09) |
|
||||
| Hover / 激活 | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) |
|
||||
|
||||
> 项示例:用户中心 / 修改密码 / 退出;每项左侧带 16px 图标,图标色与文字同步。
|
||||
|
||||
### 7.2 二级导航(白底 Tab 行)
|
||||
|
||||
紧贴顶部导航下方的白底标签行。
|
||||
|
||||
#### 7.2.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 高度 | `48px` |
|
||||
| 背景 | `#FFFFFF` (FS-004-01) |
|
||||
| 底边 | `border-bottom: 1px solid #E8E8E8` (FS-004-04) |
|
||||
| 项间距 | `--spacing-6` (32px) |
|
||||
| 字号 | `16px Medium` |
|
||||
|
||||
#### 7.2.2 状态配色
|
||||
|
||||
| 状态 | 文字 | 下划线 / 装饰 |
|
||||
|------|------|--------------|
|
||||
| 默认 | `#222222` (FS-004) | 无 |
|
||||
| Hover | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#F5222D` (ZS-001-09) | 底部 `2px solid #F5222D`,含下拉箭头 `▾` 同色 |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) | 无 |
|
||||
|
||||
### 7.3 侧边栏(分级菜单)
|
||||
|
||||
#### 7.3.1 规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 宽度 | `200px`(展开)/ `64px`(折叠仅图标) |
|
||||
| 背景 | `#FFFFFF` (FS-004-01) |
|
||||
| 右边界 | `border-right: 1px solid #E8E8E8` (FS-004-04) |
|
||||
| 项高度 | `40px` |
|
||||
| 项左 padding | 二级 `--spacing-4` (16px);三级 `--spacing-6` (32px) |
|
||||
| 字号 | `16px Regular`(二级)/ `14px Regular`(三级) |
|
||||
|
||||
#### 7.3.2 二级菜单项配色
|
||||
|
||||
| 状态 | 背景 | 文字 | 图标 | 左侧指示条 |
|
||||
|------|------|------|------|-----------|
|
||||
| 默认 | `transparent` | `#222222` (FS-004) | `#A6A6A6` (FS-004-07) | 无 |
|
||||
| Hover | `#FAFAFA` (FS-004-02) | `#F5222D` (ZS-001-09) | `#F5222D` | 无 |
|
||||
| 激活 | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) | `#F5222D` | 左侧 `2px solid #F5222D` |
|
||||
|
||||
#### 7.3.3 三级菜单项配色(前缀 `-` 短横线)
|
||||
|
||||
| 状态 | 背景 | 文字 | 左侧指示条 |
|
||||
|------|------|------|-----------|
|
||||
| 默认 | `transparent` | `#575757` (FS-004-09) | 无 |
|
||||
| Hover | `#FAFAFA` (FS-004-02) | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) | 左侧 `2px solid #F5222D` |
|
||||
|
||||
### 7.4 下拉菜单面板
|
||||
|
||||
#### 7.4.1 列表型面板(如二级导航的"浏览器容器 / 手机板卡容器…")
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 背景 | `#FFFFFF` (FS-004-01) |
|
||||
| 边框 | `1px solid #E8E8E8` (FS-004-04) |
|
||||
| 阴影 | `0 4px 16px rgba(34, 34, 34, 0.12)`(§3.1.3 二级阴影) |
|
||||
| 圆角 | `4px` |
|
||||
| 内边距 | 上下 `--spacing-2` (8px) |
|
||||
| 最小宽度 | `150px` |
|
||||
| 行高 | `36px` |
|
||||
|
||||
| 状态 | 背景 | 文字 |
|
||||
|------|------|------|
|
||||
| 默认 | `transparent` | `#575757` (FS-004-09) |
|
||||
| Hover / 激活 | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) |
|
||||
| 失效 | `transparent` | `#C1C1C1` (FS-004-06) |
|
||||
|
||||
#### 7.4.2 卡片宫格型面板(一级导航的图标宫格下拉)
|
||||
|
||||
白底大面板内以网格陈列"图标 + 二级导航名"卡片。
|
||||
|
||||
| 角色 | 背景 | 图标 / 文字 |
|
||||
|------|------|-------------|
|
||||
| 卡片(默认) | `#FEF6F6` (ZS-001-02) | 图标 `#F5222D`,文字 `#575757` |
|
||||
| 卡片(Hover) | `#FEEDED` (ZS-001-03) | 图标 / 文字 `#F5222D` |
|
||||
| 卡片(激活 / 当前) | `#F5222D` (ZS-001-09) | 图标 / 文字 `#FFFFFF` |
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 卡片尺寸 | `80px × 72px`(自适应等分) |
|
||||
| 卡片圆角 | `4px` |
|
||||
| 卡片间距 | `--spacing-2` (8px) |
|
||||
| 面板内边距 | `--spacing-4` (16px) |
|
||||
| 面板阴影 | `0 8px 32px rgba(34, 34, 34, 0.16)`(§3.1.3 三级阴影) |
|
||||
|
||||
### 7.5 交互与动画
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 下拉面板展开 | `transform-origin: top; scaleY(0.95) → scaleY(1); opacity 0 → 1`,`200ms ease-out` |
|
||||
| 展开箭头旋转 | `rotate(0 → 180deg)`,`200ms ease-out` |
|
||||
| Hover 背景过渡 | `background-color 120ms ease-out` |
|
||||
| 激活底部高亮线 | `width 0% → 100%`,`240ms ease-out` |
|
||||
|
||||
### 7.6 侧边栏布局变体
|
||||
|
||||
> 侧边栏宽度通常固定,按"是否分级 / 是否展开"分为四种形态。关键区分:**叶子节点选中**用实心红填充 + 白字 + 左侧红指示条;**父级(含子项的可展开项)选中**仅用红字 + 红图标,不填充。
|
||||
|
||||
#### 7.6.1 上下分级 · 收起(仅图标)
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 宽度 | `64px`,仅图标 |
|
||||
| 图标项(默认) | 图标 `#A6A6A6`,背景 `transparent` |
|
||||
| 图标项(激活) | 图标 `#FFFFFF`,背景 `#F5222D` (ZS-001-09) 圆角方块 `4px` |
|
||||
| Hover 弹出浮层 | **深色浮层**:背景 `#3D3D3D` (FS-004-10),圆角 `4px`,阴影 §3.1.3 三级 |
|
||||
| 浮层内二级标题 | `14px Medium`,`#FFFFFF` |
|
||||
| 浮层内三级项(前缀 `-`) | `14px Regular`,`#FFFFFF`;hover 背景 `rgba(255,255,255,0.1)` |
|
||||
|
||||
#### 7.6.2 上下分级 · 展开
|
||||
|
||||
完整宽度列表,二级为可展开组(`^ / ▾`),其下挂三级项。
|
||||
|
||||
| 层级 / 状态 | 背景 | 文字 / 图标 | 左侧指示条 |
|
||||
|------|------|-------------|-----------|
|
||||
| 二级(默认) | `transparent` | 文字 `#222222`、图标 `#A6A6A6` | 无 |
|
||||
| 二级(展开 / 当前父级) | `transparent` | 文字 `#F5222D`、图标 `#F5222D` | 无 |
|
||||
| 三级(默认,前缀 `-`) | `transparent` | `#575757` (FS-004-09) | 无 |
|
||||
| 三级(选中 · 叶子) | `#F5222D` (ZS-001-09) | `#FFFFFF` | 左侧 `2px solid #F5222D` |
|
||||
|
||||
#### 7.6.3 只有二级标题 · 不分级
|
||||
|
||||
扁平列表,二级即叶子节点,无三级。
|
||||
|
||||
| 状态 | 背景 | 文字 / 图标 | 左侧指示条 |
|
||||
|------|------|-------------|-----------|
|
||||
| 默认 | `transparent` | 文字 `#222222`、图标 `#A6A6A6` | 无 |
|
||||
| Hover | `#FAFAFA` (FS-004-02) | 文字 `#F5222D`、图标 `#F5222D` | 无 |
|
||||
| 选中 | `#F5222D` (ZS-001-09) | `#FFFFFF` | 左侧 `2px solid #F5222D` |
|
||||
|
||||
#### 7.6.4 二级选中 · 分级(含四级浮层)
|
||||
|
||||
二级展开后选中三级,三级再向右弹出**白底四级浮层**。
|
||||
|
||||
| 角色 | 配色 |
|
||||
|------|------|
|
||||
| 三级选中(叶子) | 背景 `#F5222D`,文字 `#FFFFFF`,左侧 `2px solid #F5222D` |
|
||||
| 四级浮层背景 | `#FFFFFF`,边框 `1px solid #E8E8E8`,阴影 §3.1.3 二级 |
|
||||
| 四级项(默认) | `#575757` (FS-004-09) |
|
||||
| 四级项(Hover) | 背景 `#FEEDED` (ZS-001-03),文字 `#F5222D` |
|
||||
| 四级项(选中) | 文字 `#F5222D`,左侧 `2px solid #F5222D` |
|
||||
|
||||
---
|
||||
|
||||
## 8. 面包屑(Breadcrumb)
|
||||
|
||||
> 用于标识当前页面在层级结构中的位置,并提供逐级返回与跳转。建议层级**不超过四级**。
|
||||
|
||||
### 8.1 顶部路径式(🏠 | 概况 / 总概况)
|
||||
|
||||
页面顶部的简版面包屑,靠 `/` 分隔。
|
||||
|
||||
| 元素 | 色值 | 来源 | 说明 |
|
||||
|------|------|------|------|
|
||||
| 首页图标 🏠 | `#A6A6A6` (FS-004-07) | — | hover `#F5222D` |
|
||||
| 竖分隔 `\|` | `#E8E8E8` | FS-004-04 | 首页图标与路径间 |
|
||||
| 父级路径文字 | `#575757` (FS-004-09) | — | 可点击,hover `#F5222D` |
|
||||
| 路径分隔 `/` | `#C1C1C1` | FS-004-06 | — |
|
||||
| 当前页文字 | `#222222` (FS-004) | — | `Medium`,不可点击 |
|
||||
|
||||
### 8.2 返回 + 路径式(含 ← 返回)
|
||||
|
||||
左侧"← 返回"按钮 + 竖分隔 + 文字路径。按层级展开:
|
||||
|
||||
```
|
||||
一级: ← 返回 │ 现在位置
|
||||
二级: ← 返回 │ 上一级位置 / 现在位置
|
||||
三级: ← 返回 │ 上二级位置 / 上一级位置 / 现在位置
|
||||
四级: ← 返回 │ 上三级位置 / 上二级位置 / 上一级位置 / 现在位置
|
||||
```
|
||||
|
||||
| 元素 | 色值 | 来源 | 说明 |
|
||||
|------|------|------|------|
|
||||
| 返回箭头 ← + "返回" | `#F5222D` (ZS-001-09) | — | hover `#CF1322`,文本按钮态 |
|
||||
| 竖分隔 `\|` | `#E8E8E8` | FS-004-04 | 返回与路径间 |
|
||||
| 历史层级文字 | `#575757` (FS-004-09) | — | 可点击,hover `#F5222D` |
|
||||
| 路径分隔 `/` | `#C1C1C1` | FS-004-06 | — |
|
||||
| 当前位置文字 | `#222222` (FS-004) | — | `Medium`,不可点击 |
|
||||
|
||||
### 8.3 行为规则
|
||||
|
||||
- 点击「返回」按钮逐步向上返回一级。
|
||||
- 点击文字路径,快速返回到该层级页面。
|
||||
- 层级尽可能不超过四级;超出时中间层折叠为 `…`。
|
||||
- 字号 `14px Regular`,元素间距 `--spacing-2` (8px),竖分隔高度约 `12–14px`。
|
||||
|
||||
---
|
||||
|
||||
## 9. 页头与分页
|
||||
|
||||
### 9.1 页头(Page Header)
|
||||
|
||||
内容区顶部的标题区,底部叠一条 `1px solid #E8E8E8` (FS-004-04) 分割线。
|
||||
|
||||
| 变体 | 构成 | 配色 |
|
||||
|------|------|------|
|
||||
| 基础页头 | 页头标题 | 标题 `16px Bold #222222` (FS-004) |
|
||||
| 页头 + 说明 | 标题 +(简要说明) | 说明 `14px Regular #A6A6A6` (FS-004-07) |
|
||||
| 页头 + 说明 icon | 标题 + `?` 帮助图标 | 图标 `#A6A6A6`,hover `#F5222D` |
|
||||
| 分 Tabs 页头 | 多个标题 Tab | 见 §9.2 |
|
||||
|
||||
### 9.2 分 Tabs 页头
|
||||
|
||||
横向页签形态,激活态红色下划线。
|
||||
|
||||
| 状态 | 文字 | 下划线 |
|
||||
|------|------|--------|
|
||||
| 默认 | `#222222` (FS-004) | 无 |
|
||||
| Hover | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#F5222D` (ZS-001-09) | `2px solid #F5222D`,宽度与文字齐 |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) | 无 |
|
||||
|
||||
- 字号 `14px Medium`,项间距 `--spacing-5` (24px),下划线与文字底部间距 `--spacing-2` (8px)
|
||||
|
||||
### 9.3 分页(Pagination)
|
||||
|
||||
#### 9.3.1 正常分页
|
||||
|
||||
`共 240 项 [1] 2 3 4 5 … 24 > 每页 [10 ▾] 条 前往 [ ] 页`
|
||||
|
||||
| 元素 | 默认 | Hover | 激活 | 失效 |
|
||||
|------|------|-------|------|------|
|
||||
| 总数 / 辅助文字(共N项 / 每页 / 条 / 前往 / 页) | `#575757` (FS-004-09) | — | — | — |
|
||||
| 页码数字 | `#222222` (FS-004) | `#F5222D` (ZS-001-09) | 背景 `#F5222D` + 文字 `#FFFFFF` | `#C1C1C1` (FS-004-06) |
|
||||
| 翻页箭头 `< >` | `#575757` (FS-004-09) | `#F5222D` | — | `#C1C1C1` |
|
||||
| 省略号 `…` | `#A6A6A6` (FS-004-07) | — | — | — |
|
||||
| 每页选择器 / 跳转输入框 | 边框 `#DBDBDB` (FS-004-05) | 边框 `#F5222D` | — | 边框 `#E8E8E8` |
|
||||
|
||||
- 页码项尺寸 `28px × 28px`,圆角 `2px`,激活态为实心红方块;项间距 `--spacing-1` (4px)
|
||||
|
||||
#### 9.3.2 精简分页
|
||||
|
||||
`共 1 项 < [1] / 10 >`
|
||||
|
||||
| 元素 | 色值 |
|
||||
|------|------|
|
||||
| 总数文字 | `#575757` (FS-004-09) |
|
||||
| 当前页输入框 | 边框 `#DBDBDB`,文字 `#222222` |
|
||||
| 总页数 `/ N` | `#A6A6A6` (FS-004-07) |
|
||||
| 翻页箭头 `< >` | `#575757`,hover `#F5222D`,失效 `#C1C1C1` |
|
||||
|
||||
#### 9.3.3 导航式分页
|
||||
|
||||
仅"下一页 » / « 上一页"文本按钮,无页码。配色沿用 §5.3.3 文本按钮 + 图标:
|
||||
|
||||
| 状态 | 色值 |
|
||||
|------|------|
|
||||
| 默认 | `#F5222D` (ZS-001-09) |
|
||||
| Hover | `#CF1322` (ZS-001) |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) |
|
||||
|
||||
---
|
||||
|
||||
## 10. 步骤条(Steps)
|
||||
|
||||
> 用于多步流程的进度指引。按布局分**横向**(弹窗 / 页面)与**纵向**两类。颜色取自 ZS-001 主色红与 FS-004 中性灰。
|
||||
|
||||
### 10.1 步骤节点(公共)
|
||||
|
||||
每个步骤由「指示圆 + 标题(可选描述)」组成。指示圆按状态切换形态:
|
||||
|
||||
| 状态 | 圆形外观 | 圆内符号 | 来源 |
|
||||
|------|----------|----------|------|
|
||||
| 已完成(Completed) | 描边圆 `2px solid #F5222D`,背景 `transparent` | `✓`(对勾,`#F5222D`) | ZS-001-09 |
|
||||
| 当前(Current) | 实心圆,背景 `#F5222D` | 步骤数字,`#FFFFFF` | ZS-001-09 / 白 |
|
||||
| 未开始(Upcoming) | 描边圆 `1px solid #C1C1C1`,背景 `transparent` | 步骤数字,`#A6A6A6` | FS-004-06 / FS-004-07 |
|
||||
| 失效(Disabled) | 描边圆 `1px solid #E8E8E8`,背景 `transparent` | 步骤数字,`#C1C1C1` | FS-004-04 / FS-004-06 |
|
||||
|
||||
**指示圆规格**:
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 直径 | `24px` |
|
||||
| 圆内字号 | `12px Bold`(D-DIN 或 Noto Sans Bold) |
|
||||
| 对勾图标 | `12px`,居中 |
|
||||
|
||||
**标题与描述文字**:
|
||||
|
||||
| 元素 | 状态 | 字号 / 颜色 | 来源 |
|
||||
|------|------|-------------|------|
|
||||
| 标题 | 已完成 / 当前 | `14px Medium`,`#222222` | FS-004 |
|
||||
| 标题 | 未开始 / 失效 | `14px Medium`,`#A6A6A6` → `#C1C1C1` | FS-004-07 → FS-004-06 |
|
||||
| 描述 | 已完成 / 当前 | `12px Regular`,`#575757` | FS-004-09 |
|
||||
| 描述 | 未开始 / 失效 | `12px Regular`,`#A6A6A6` → `#C1C1C1` | FS-004-07 → FS-004-06 |
|
||||
|
||||
**连接线(步骤之间)**:
|
||||
|
||||
| 类型 | 色值 | 来源 | 样式 |
|
||||
|------|------|------|------|
|
||||
| 已完成段 | `#F5222D` | ZS-001-09 | `1px dashed`(弹窗)/ `1px solid`(页面) |
|
||||
| 未完成段 | `#C1C1C1` | FS-004-06 | `1px dashed` |
|
||||
|
||||
> 连接线在指示圆两侧水平居中(横向)或正下方垂直(纵向);线两端与圆外缘留 `--spacing-1` (4px) 间隙。
|
||||
|
||||
### 10.2 弹窗步骤条(横向 · 描边圆为主)
|
||||
|
||||
用于 Modal / Drawer 内的紧凑步骤条。完成态用**描边 + 红色对勾**,避免在弹窗内过于抢眼。
|
||||
|
||||
```
|
||||
( ✓ ) ┄┄┄ (●2) ┄┄┄ ( 3 ) ┄┄┄ ( 4 ) ┄┄┄ ( 5 )
|
||||
标题 标题 标题 标题 标题
|
||||
(描述) (描述) (描述) (描述) (描述)
|
||||
```
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器水平 padding | `--spacing-5` (24px) |
|
||||
| 指示圆 → 标题间距 | `--spacing-2` (8px) |
|
||||
| 标题 → 描述间距 | `--spacing-1` (4px) |
|
||||
| 连接线 | `1px dashed`,完成段 `#F5222D`,未完成段 `#C1C1C1` |
|
||||
| 文字对齐 | 标题、描述居中于指示圆下方 |
|
||||
| 两种变体 | 仅标题 / 标题 + 描述 |
|
||||
|
||||
### 10.3 页面步骤条(横向 · 实心圆 + 自定义首项标题)
|
||||
|
||||
用于页面级向导(如「新建集群」)。完成态连接线改为**实线**,首步标题可显示具体名称。
|
||||
|
||||
```
|
||||
(✓) ──── (●2) ┄┄┄ ( 3 ) ┄┄┄ ( 4 ) ┄┄┄ ( 5 )
|
||||
新建集群 标题 标题 标题 标题
|
||||
(描述文本) (描述文本) (描述文本) (描述文本) (描述文本)
|
||||
```
|
||||
|
||||
| 维度 | 弹窗步骤条 | 页面步骤条 |
|
||||
|------|-----------|-----------|
|
||||
| 完成态圆形 | 描边圆 + 红色对勾 | 描边圆 + 红色对勾(同) |
|
||||
| 完成段连接线 | `1px dashed #F5222D` | `1px solid #F5222D` |
|
||||
| 第一项 | 通用「标题」占位 | 可显示具体名称(自定义文案) |
|
||||
|
||||
### 10.4 纵向步骤条
|
||||
|
||||
用于侧栏 / 详情页内的纵向流程指引。两种变体——「仅标题」与「标题 + 描述」。
|
||||
|
||||
```
|
||||
仅标题: 标题 + 描述:
|
||||
|
||||
(✓) 新建集群 (✓) 新建集群
|
||||
┊ 描述文本描述
|
||||
(●2) 标题 ┊
|
||||
┊ (●2) 标题
|
||||
( 3 ) 标题 描述文本描述
|
||||
┊ ┊
|
||||
( 4 ) 标题 ( 3 ) 标题
|
||||
描述文本描述
|
||||
```
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 指示圆 → 标题水平间距 | `--spacing-2` (8px) |
|
||||
| 节点垂直间距(仅标题) | `--spacing-5` (24px),圆心到圆心 |
|
||||
| 节点垂直间距(标题 + 描述) | `--spacing-6` (32px),圆心到圆心 |
|
||||
| 标题 → 描述间距 | `--spacing-1` (4px) |
|
||||
| 连接线位置 | 上下指示圆正下方垂直,居中于圆心 |
|
||||
| 连接线样式 | `1px dashed`,完成段 `#F5222D`,未完成段 `#C1C1C1` |
|
||||
| 文字对齐 | 标题与描述左对齐 |
|
||||
|
||||
### 10.5 交互与动画
|
||||
|
||||
| 行为 | 动效 |
|
||||
|------|------|
|
||||
| 步骤切换(next) | 当前圆 `background: transparent → #F5222D`,`200ms ease-out`;上一步圆 `border-color: #C1C1C1 → #F5222D`,再 `200ms` 切换为对勾图标淡入 |
|
||||
| 连接线进度 | 完成段 `width 0% → 100%`,`240ms ease-out` |
|
||||
|
||||
---
|
||||
|
||||
## 11. 页签与锚点
|
||||
|
||||
> 共用主色红指示当前位置:页签用于同层级内容切换,锚点用于长页面内章节跳转。
|
||||
|
||||
### 11.1 页签(Tabs)
|
||||
|
||||
#### 11.1.1 横向页签(下划线 · 横向)
|
||||
|
||||
| 状态 | 文字 | 下划线 |
|
||||
|------|------|--------|
|
||||
| 默认 | `#222222` (FS-004) | 无 |
|
||||
| Hover | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#F5222D` (ZS-001-09) | `2px solid #F5222D`,宽度与文字齐 |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) | 无 |
|
||||
|
||||
- 字号 `14px Medium`,项间距 `--spacing-5` (24px),下划线与文字底部间距 `--spacing-2` (8px)
|
||||
- 容器底边叠一条 `1px solid #E8E8E8` (FS-004-04) 基线,激活高亮线压在其上
|
||||
|
||||
#### 11.1.2 纵向页签(下划线 · 纵向)
|
||||
|
||||
| 状态 | 文字 | 右侧指示线 |
|
||||
|------|------|-----------|
|
||||
| 默认 | `#222222` (FS-004) | 无 |
|
||||
| Hover | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#F5222D` (ZS-001-09) | 右侧 `2px solid #F5222D`,高度与文字齐 |
|
||||
| 失效 | `#C1C1C1` (FS-004-06) | 无 |
|
||||
|
||||
- 字号 `14px Medium`,项高度 `32px`,项间距 `--spacing-2` (8px)
|
||||
- 容器右边叠一条 `1px solid #E8E8E8` 基线,激活指示线压在其上
|
||||
|
||||
### 11.2 锚点(Anchor)
|
||||
|
||||
用于长内容页的章节快速跳转,支持一 / 二级缩进。
|
||||
|
||||
```
|
||||
│ 一级
|
||||
│ 一级 (active)
|
||||
│ 二级
|
||||
│ 二级
|
||||
│ 一级
|
||||
│ 一级
|
||||
```
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 左侧基线 | `1px solid #E8E8E8` (FS-004-04) 通栏 |
|
||||
| 项高度 | `32px` |
|
||||
| 一级项左 padding | `--spacing-3` (12px) |
|
||||
| 二级项左 padding | `--spacing-5` (24px) |
|
||||
| 字号 | `14px Regular` |
|
||||
|
||||
| 状态 | 一级文字 | 二级文字 | 左侧指示条 |
|
||||
|------|----------|----------|-----------|
|
||||
| 默认 | `#222222` (FS-004) | `#A6A6A6` (FS-004-07) | 无 |
|
||||
| Hover | `#F5222D` (ZS-001-09) | `#F5222D` (ZS-001-09) | 无 |
|
||||
| 激活 | `#F5222D` (ZS-001-09) | — | 左侧 `2px solid #F5222D`,覆盖容器基线 |
|
||||
|
||||
- 二级项不单独支持激活态:选中二级时其父级一级显示激活态,指示条按父级位置渲染
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,308 @@
|
||||
# 浅红色 UI 规范 · 四、数据展示
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:弹出式窗口 · 卡片 · 折叠面板 · 进度条 · 表格 · 标签 · 时间轴
|
||||
|
||||
---
|
||||
|
||||
## 17. 弹出式窗口(Modal / Dialog)
|
||||
|
||||
> 用于聚焦的多步表单 / 确认操作。内部可承载页签、步骤条、表单控件。
|
||||
|
||||
### 17.1 容器规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 背景 | `#FFFFFF` (FS-004-01),圆角 `4px` |
|
||||
| 阴影 | `0 8px 32px rgba(34, 34, 34, 0.16)`(§3.1.3 三级阴影) |
|
||||
| 遮罩层 | `rgba(34, 34, 34, 0.45)`(基于 FS-004) |
|
||||
| 标题区 | 左侧 `3px` 主色红竖条 `#F5222D` + 标题 `16px Bold #222222` |
|
||||
| 关闭按钮 `×` | `#A6A6A6` (FS-004-07),hover `#F5222D` |
|
||||
| 内边距 | `--spacing-5` (24px) |
|
||||
| 底部操作区 | 右对齐,主按钮在最右(§5.3.4) |
|
||||
|
||||
### 17.2 内部页签与步骤条
|
||||
|
||||
- 顶部页签沿用 §11.1 横向页签(Tab 激活红字 + 红下划线,基线 `#E8E8E8`)。
|
||||
- 步骤条沿用 §10.2 弹窗步骤条(完成态红描边对勾、当前态红实心、未开始灰描边,连接线 `1px dashed`)。
|
||||
|
||||
### 17.3 表单控件补充(Modal 内常用)
|
||||
|
||||
| 控件 | 配色 |
|
||||
|------|------|
|
||||
| 必填星号 `*` | `#F5222D` (ZS-001-09),置于 label 前 |
|
||||
| 下拉选择(Select,`请选择 ▾`) | 同输入框(§13),箭头 `#A6A6A6`,聚焦边框 `#F5222D` |
|
||||
| 日期 / 时间选择器(📅) | 输入框 + 日历图标 `#A6A6A6`;区间用"起 至 止"两段 |
|
||||
| 文本区域(Textarea) | 同输入框,`resize: vertical`,最小高度约 `80px` |
|
||||
| 数值 + 单位(如 `100 天`) | 输入框 + 尾部 addon(背景 `#FAFAFA`,边框 `#DBDBDB`,文字 `#575757`) |
|
||||
| 复选框(Checkbox) | 未选边框 `#DBDBDB`;选中背景 `#F5222D` + 对勾 `#FFFFFF` |
|
||||
| 错误态 | 控件边框 `1px solid #F5222D`,下方红色提示文字 `12px #F5222D`(如"输入表单内容报错") |
|
||||
|
||||
---
|
||||
|
||||
## 18. 数据展示 · 卡片(Card)
|
||||
|
||||
> 用于陈列结构化信息(人物 / 媒体 / 群组等档案)。在 §3 卡片基础上扩展"分级信息卡片"。
|
||||
|
||||
### 18.1 卡片头部
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 类目竖条(标题前) | `3px` 主色红 `#F5222D` (ZS-001-09) |
|
||||
| 标题(如「个体」「媒体」) | `16px Bold`,`#222222` (FS-004) |
|
||||
| 关闭 `×` | `#A6A6A6` (FS-004-07),hover `#F5222D` |
|
||||
| 右上操作(查看档案) | 小尺寸主按钮 `#F5222D` + 白字(§5.1 小,含图标) |
|
||||
|
||||
### 18.2 标签 / 属性 Tag
|
||||
|
||||
| 类型 | 背景 | 文字 | 来源 |
|
||||
|------|------|------|------|
|
||||
| 人物属性 / 红色标签 | `#FEEDED` (ZS-001-03) | `#F5222D` (ZS-001-09) | 主色红 |
|
||||
| 立场 / 成功类(绿) | `#EEFCF7` (FS-002-03) | `#189D72` (FS-002-10) | 渐绿系 |
|
||||
| 状态签(右上角强调) | `transparent` | `#F5222D` (ZS-001-09) | 主色红 |
|
||||
| 话题标签(#话题) | `transparent` | `#F5222D` (ZS-001-09) | 主色红,`#` 前缀 |
|
||||
|
||||
- Tag 圆角 `2px`,内边距 `0 8px`,字号 `12px`
|
||||
|
||||
### 18.3 卡片内页签与信息行
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 页签(基本信息 / 线下活动 / 线上发声) | 激活 `#F5222D` + 红下划线;默认 `#222222`(§11.1.1) |
|
||||
| 页签红点提示(•) | `#F5222D` (ZS-001-09),标识有更新 |
|
||||
| 信息项标签(国家/地区、职务…) | `#A6A6A6` (FS-004-07) |
|
||||
| 信息项取值 | `#222222` (FS-004) |
|
||||
| 来源平台图标(如 Facebook) | 平台原色(蓝 `#0079FE` 近似),不纳入主题强调色 |
|
||||
|
||||
---
|
||||
|
||||
## 19. 数据展示 · 折叠面板(Collapse)
|
||||
|
||||
> 用于长内容的收起 / 展开。含列表概览折叠、带图标折叠、手风琴折叠、信息流折叠四类。
|
||||
|
||||
### 19.1 列表概览折叠(含 + 图标变体)
|
||||
|
||||
| 状态 | 构成 | 配色 |
|
||||
|------|------|------|
|
||||
| 收起 | 标题 + 描述 + 右侧 `▾` | 标题 `#222222` (FS-004)、描述 `#A6A6A6` (FS-004-07)、箭头 `#A6A6A6` |
|
||||
| 展开 | 上述 + 下方内容区 | 内容区背景 `#FAFAFA` (FS-004-02),箭头旋转为 `^` |
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 容器边框 | `1px solid #DBDBDB` (FS-004-05),圆角 `4px` |
|
||||
| 头部内边距 | `--spacing-4` (16px) |
|
||||
| 左侧图标(带图标变体) | 占位 `40px`,图标 `#A6A6A6` |
|
||||
|
||||
### 19.2 手风琴折叠(Accordion)
|
||||
|
||||
多面板同列堆叠,同一时刻通常仅展开一项。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 项分隔 | `1px solid #E8E8E8` (FS-004-04) |
|
||||
| 标题 | `#222222` (FS-004),前置 `▾ / >` 箭头 `#A6A6A6` |
|
||||
| 收起 / 展开 链接 | 文本按钮 `#F5222D` (ZS-001-09) |
|
||||
| 展开正文 | `#575757` (FS-004-09),背景 `#FFFFFF` |
|
||||
|
||||
### 19.3 信息流折叠(Feed)
|
||||
|
||||
用于资讯流条目的展开详情。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 前置「标签」Tag | 背景 `#FEEDED` (ZS-001-03),文字 `#F5222D` (ZS-001-09) |
|
||||
| 条目标题 | `#222222` (FS-004),`14px Medium` |
|
||||
| 热度计数(🔥 6405) | 火苗图标 `#FF9900` (FS-001-09),数字 `#575757` (FS-004-09) |
|
||||
| 收起 / 展开 链接 + 箭头 | `#F5222D` (ZS-001-09) |
|
||||
| 分节标题(【热点首发】/【应对建议】) | `#F5222D` (ZS-001-09),`Medium` |
|
||||
| 来源 / 作者行(社交媒体 \| 平台 \| @用户) | `#A6A6A6` (FS-004-07) |
|
||||
| 外链 URL | `#0079FE` (ZS-002-09),hover 下划线 |
|
||||
| 日期 | `#A6A6A6` (FS-004-07) |
|
||||
| 正文 | `#575757` (FS-004-09) |
|
||||
| 缩略图 | 圆角 `2px`,间距 `--spacing-1` (4px) |
|
||||
|
||||
---
|
||||
|
||||
## 21. 数据展示 · 进度条(Progress)
|
||||
|
||||
### 21.1 标准进度条
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 轨道背景 | `#F5F5F5` (FS-004-03) |
|
||||
| 轨道高度 | `8px`,圆角全圆 |
|
||||
| 已完成段 | 按语义取色(§20):成功绿 / 失败红 / 警告橙 |
|
||||
| 百分比文字 | `#222222` (FS-004),置于条右侧 |
|
||||
| 末端状态图标 | 成功 ✓ `#2FD69A`;失败 ✗ `#F5222D`(橙色进行态可不带图标) |
|
||||
|
||||
### 21.2 小型进度条
|
||||
|
||||
放在较窄区域内(如表格单元格)。规格同 §21.1,仅尺寸缩小:
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 轨道高度 | `4px` |
|
||||
| 百分比 / 图标 | 字号缩至 `12px`,图标 `12px` |
|
||||
|
||||
### 21.3 环形进度条
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 轨道环 | `#F5F5F5` (FS-004-03) |
|
||||
| 进度环 | 按语义取色(§20),线宽 `6px`,圆头端点 |
|
||||
| 中心主数字(如 `82.0%`) | `#222222` (FS-004),D-DIN |
|
||||
| 中心名称 | `12px Regular`,`#A6A6A6` (FS-004-07) |
|
||||
|
||||
> 进度环颜色按阈值映射(如低→绿、中→橙、高→红)由业务自定义,但必须取自 §20 语义色。
|
||||
|
||||
---
|
||||
|
||||
## 22. 数据展示 · 表格(Table)
|
||||
|
||||
### 22.1 结构规格
|
||||
|
||||
| 属性 | 取值 |
|
||||
|------|------|
|
||||
| 表头背景 | `#FFFFFF`(或浅红 `#FEF6F6` ZS-001-02 强调首行) |
|
||||
| 表头文字 | `14px Medium`,`#222222` (FS-004) |
|
||||
| 单元格文字 | `14px Regular`,`#222222` |
|
||||
| 行高 | `48px` |
|
||||
| 行分隔 | `1px solid #F5F5F5` (FS-004-03) |
|
||||
| 行 Hover | 背景 `#FAFAFA` (FS-004-02) |
|
||||
| 斑马纹(可选) | 偶数行 `#FAFAFA` (FS-004-02) |
|
||||
| 复选框(选中) | 填充 `#F5222D` + 对勾 `#FFFFFF` |
|
||||
|
||||
### 22.2 状态列(圆点 + 文字)
|
||||
|
||||
| 文字 | 圆点色 | 来源 |
|
||||
|------|--------|------|
|
||||
| 普通 | `#2FD69A`(成功绿) | FS-002-09 |
|
||||
| 异常 | `#F5222D`(错误红) | ZS-001-09 |
|
||||
| 特殊 | `#FF9900`(警告橙) | FS-001-09 |
|
||||
|
||||
- 文字统一 `#222222` (FS-004),圆点直径 `6px`,与文字间距 `--spacing-1` (4px)
|
||||
|
||||
### 22.3 整体状态列(状态标签)
|
||||
|
||||
使用 §23 浅底状态标签:进行中(橙)/ 已完成(绿)/ 已失败(红)。
|
||||
|
||||
### 22.4 操作列
|
||||
|
||||
文本按钮 + 图标,沿用 §5.3.3:查看 / 配置 等均为 `#F5222D` (ZS-001-09),hover `#CF1322`,按钮间距 `--spacing-3` (12px)。
|
||||
|
||||
### 22.5 单元格内编辑报错
|
||||
|
||||
可编辑单元格(如 `100 [M]`)校验失败:输入框边框 `1px solid #F5222D`,红色气泡提示"Table 内输入报错"(背景 `#F5222D`、白字 `12px`,§12.3 同款)。
|
||||
|
||||
---
|
||||
|
||||
## 23. 数据展示 · 标签(Tag / Badge)
|
||||
|
||||
### 23.1 标签形式
|
||||
|
||||
| 形式 | 用途 | 配色 |
|
||||
|------|------|------|
|
||||
| 文字按钮标签 | 重点突出标记属性 | 三种强度:灰底 `#F5F5F5`/`#575757`;浅红底 `#FEEDED`/`#F5222D`;实红 `#F5222D`/`#FFFFFF` |
|
||||
| 图标 + 文字按钮标签 | 增强辨识度 | 灰底 + 平台原色图标(如 Twitter 蓝);或实红 `#F5222D` + 白字 + ✓ |
|
||||
| 圆点 + 文字标签 | 属性多 / 复杂、无需突出 | 圆点按语义色(普通绿 / 特殊橙 / 异常红),文字 `#222222` |
|
||||
| 动态标签 | 可增删(筛选列表、关键词) | 已加:灰底 `#F5F5F5` + `×`;新增入口:虚线框 `#DBDBDB` + "+ 标签" |
|
||||
|
||||
- 标签圆角 `2px`,高度 `24px`,内边距 `0 8px`,字号 `12px`
|
||||
|
||||
### 23.2 状态标签(Status Badge)
|
||||
|
||||
四种呈现风格,颜色全部取自 §20 语义状态色:
|
||||
|
||||
| 风格 | 说明 |
|
||||
|------|------|
|
||||
| ① 浅底彩字 | 浅底背景 + 语义文字色(默认推荐,弱干扰) |
|
||||
| ② 实填白字 | 语义实填背景 + 白字(强调态,用于重点状态) |
|
||||
| ③ 图标 + 浅底彩字 | ① 基础上前置语义图标 |
|
||||
| ④ 图标 + 彩字(无底) | 仅图标 + 文字,最轻量 |
|
||||
|
||||
常见状态与语义映射:
|
||||
|
||||
| 状态 | 语义 / 取色 |
|
||||
|------|-------------|
|
||||
| 未开始 / 就绪 | 中性灰 |
|
||||
| 等待中 / 等待 | 信息蓝 |
|
||||
| 进行中 / 进行 | 警告橙 |
|
||||
| 已完成 / 成功 | 成功绿 |
|
||||
| 已失败 / 失败 | 错误红 |
|
||||
| 待更新 / 待更 | 青 |
|
||||
|
||||
- 图标(②④ 风格):就绪 ⊖、等待 ⊗、进行 🕐、成功 ✓、失败 ✗、待更 🕐,颜色与文字同步
|
||||
|
||||
---
|
||||
|
||||
## 24. 数据展示 · 时间轴(Timeline)
|
||||
|
||||
> 用于按时间顺序陈列事件。分纵向(基础 / 卡片 / 长文本)与横向两种主轴方向,另含全局缩略时间轴。
|
||||
|
||||
### 24.1 纵向时间轴点(基础)
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 轴线 | `1px solid #E8E8E8` (FS-004-04) 或虚线 |
|
||||
| 最新 / 当前节点 | 空心红圆环 `2px solid #F5222D` (ZS-001-09),背景 `#FFFFFF` |
|
||||
| 历史节点 | 实心红点 `#F5222D` (ZS-001-09),直径 `8px` |
|
||||
| 事件标题 | `14px Medium`,`#222222` (FS-004) |
|
||||
| 时间文字 | `12px Regular`,`#A6A6A6` (FS-004-07) |
|
||||
|
||||
### 24.2 卡片式时间轴点
|
||||
|
||||
节点内容置于浅灰卡片中。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 卡片背景 | `#FAFAFA` (FS-004-02),圆角 `4px` |
|
||||
| 卡片内分隔 | `1px solid #E8E8E8` |
|
||||
| 正文标签(如"安全状况:") | `#575757` (FS-004-09) |
|
||||
| 正向取值(如"今日无安全风险") | `#189D72`(成功绿,FS-002-10) |
|
||||
|
||||
### 24.3 横向长文本时间轴
|
||||
|
||||
横轴双向箭头,节点上下交错分布。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 主轴线 + 双向箭头 | `#222222` (FS-004) |
|
||||
| 上方节点标记 + 日期 | 红色 `#F5222D` (ZS-001-09),`▼` 标记 |
|
||||
| 下方节点标记 + 日期 | 橙色 `#FF9900` (FS-001-09),`▲` 标记 |
|
||||
| 节点正文 | `#575757` (FS-004-09),`14px Regular` |
|
||||
|
||||
> 上 / 下用红 / 橙双色区分两类事件或交替排布,避免拥挤。
|
||||
|
||||
### 24.4 纵向长文本时间轴
|
||||
|
||||
带头像、状态标签、富文本与附件的纵向时间流。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 轴线 | `1px dashed #DBDBDB` (FS-004-05) |
|
||||
| 日期分组吸顶标签 | 背景 `#A6A6A6`(FS-004-07) 或 `#F5F5F5`,文字 `#FFFFFF` / `#575757`,圆角 `2px` |
|
||||
| 节点圆点 | 红 `#F5222D`(重点)/ 浅红 `#FCB5B9`(次要) |
|
||||
| 状态标签 | 浅底状态标签:计划(橙 `#FFF6EA`/`#FF9900`)、已成行(红 `#FEEDED`/`#F5222D`)(§23.2 ①) |
|
||||
| 人物名 | `14px Regular`,`#222222` |
|
||||
| 时间 | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 正文 | `#575757` (FS-004-09) |
|
||||
| 地址(📍 地址) | 图标 + 文字 `#A6A6A6` |
|
||||
| 缩略图 | 圆角 `2px`,间距 `--spacing-1` (4px) |
|
||||
|
||||
### 24.5 全局时间轴(缩略 / 范围选择)
|
||||
|
||||
页面顶部用于框选时间范围的缩略轴。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 刻度轴背景 | 灰阶渐变 `linear-gradient(90deg, #7F7F7F, #DBDBDB)`(FS-004-08 → FS-004-05) |
|
||||
| 刻度文字(如 04-03) | `#FFFFFF`,`12px` |
|
||||
| 拖拽游标(handle) | `#FFFFFF` 竖条,带轻微阴影 |
|
||||
| 选区刷选框(brush) | 边框 `1px solid #F5222D`,填充 `rgba(245, 34, 45, 0.08)`(浅红 ZS-001-09 8%) |
|
||||
| 选区内迷你面积图 | 描边 `#F5222D`,填充浅红渐变 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,90 @@
|
||||
# 浅红色 UI 规范 · 五、图表
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:图表通用色序 · 公共元素 · 柱状/折线/甘特/饼环
|
||||
|
||||
---
|
||||
|
||||
## 25. 图表(Charts)
|
||||
|
||||
> 图表配色以**柔和色系**为主(保证大面积色块不刺眼),强调线 / 排行榜可叠加主色红渐变。多分类图表的色序按"用几色取几色",从下表对应行从左到右取用。
|
||||
|
||||
### 25.1 图表通用色序(权威)
|
||||
|
||||
> 如需更多色值,请 UI 设计师按系统整体风格在同色系内扩展。
|
||||
|
||||
| 分类数 | 色序(从左到右) |
|
||||
|--------|------------------|
|
||||
| 三色 | `#FA9196` `#97EBCD` `#80BCFF` |
|
||||
| 四色 | `#FA9196` `#FFCC80` `#97EBCD` `#A2E1F9` |
|
||||
| 五色 | `#FA9196` `#FFCC80` `#97EBCD` `#A2E1F9` `#80BCFF` |
|
||||
| 六色 | `#FA9196` `#FFCC80` `#BAE1B3` `#97EBCD` `#A2E1F9` `#80BCFF` |
|
||||
| 七色 | `#FA9196` `#FCA58F` `#FFCC80` `#BAE1B3` `#97EBCD` `#A2E1F9` `#80BCFF` |
|
||||
| 八色 | `#FA9196` `#FCA58F` `#FDB887` `#FFCC80` `#BAE1B3` `#97EBCD` `#A2E1F9` `#80BCFF` |
|
||||
| 九色 | `#FA9196` `#FCA58F` `#FDB887` `#FFCC80` `#DCD69A` `#BAE1B3` `#97EBCD` `#A2E1F9` `#80BCFF` |
|
||||
| 十色 | `#FA9196` `#FCA58F` `#FDB887` `#FFCC80` `#DCD69A` `#BAE1B3` `#97EBCD` `#9EE4EA` `#A2E1F9` `#80BCFF` |
|
||||
|
||||
- 色值映射:`#FA9196`(ZS-001-06 浅红) / `#FCA58F`·`#FDB887`(橙红过渡) / `#FFCC80`(FS-001-06 浅橙) / `#DCD69A`(黄绿过渡) / `#BAE1B3`·`#97EBCD`(FS-002-06 浅绿) / `#9EE4EA`·`#A2E1F9`(FS-003-06 浅青) / `#80BCFF`(ZS-002-06 浅蓝)
|
||||
- 取色原则:序列从暖(红)到冷(蓝)渐变排布,相邻类别对比清晰
|
||||
|
||||
### 25.2 图表公共元素
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 坐标轴线 | `1px solid #E8E8E8` (FS-004-04) |
|
||||
| 网格线 | `1px dashed #F5F5F5` (FS-004-03) |
|
||||
| 轴刻度文字 | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 图例文字 | `12px`,`#575757` (FS-004-09),前置色块圆角 `2px` |
|
||||
| Tooltip 浮层 | 背景 `rgba(34,34,34,0.85)`(FS-004),文字 `#FFFFFF` `12px`,圆角 `4px` |
|
||||
| 数值标注气泡 | 背景 `#7F7F7F` (FS-004-08),白字(如悬停值 `59.32`) |
|
||||
| 高亮选区(band) | 填充 `rgba(245,34,45,0.08)`,中线 `1px dashed #F5222D` (ZS-001-09) |
|
||||
|
||||
### 25.3 柱状图(Bar)
|
||||
|
||||
| 形态 | 配色 |
|
||||
|------|------|
|
||||
| 堆叠柱 / 分组柱 | 各序列按 §25.1 取色(如 Paper 绿 `#97EBCD`、Project 橙 `#FFCC80`、Book 红 `#FA9196`) |
|
||||
| 单序列柱 / 条形 | 主序列 `#FA9196`(浅红) |
|
||||
| 排行榜(TOP 渐变条) | 进度条填充 `linear-gradient(90deg, #F5222D 0%, #FF9900 100%)`(红→橙),轨道 `#F5F5F5`,名称 `#222222`、数值 `#222222` 右对齐 |
|
||||
|
||||
- 柱体圆角 `2px`,柱间距按类目自适应
|
||||
|
||||
### 25.4 折线图(Line / Area)
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 主折线 | `#F5222D` (ZS-001-09),线宽 `2px` |
|
||||
| 面积填充 | `linear-gradient(180deg, rgba(245,34,45,0.15), rgba(245,34,45,0))` |
|
||||
| 数据点 | 描边 `#F5222D` + 白色填充,悬停放大并实心 |
|
||||
| 多序列线 | 用饱和主色保证细线可辨:红 `#F5222D` / 蓝 `#0079FE` / 橙 `#FF9900` / 绿 `#2FD69A` |
|
||||
| 涨跌双色线 | 上行 `#F5222D`(红)/ 下行 `#2FD69A`(绿) |
|
||||
| 堆叠面积 | 各层按 §25.1 柔和色 + 各自浅色渐变填充 |
|
||||
| 悬停辅助线 + tooltip | 竖虚线 `#F5222D`,tooltip 见 §25.2(如"异常率 12.3%") |
|
||||
|
||||
### 25.5 甘特图(Gantt)
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 行背景斑马纹 | 浅红 `#FEF6F6` (ZS-001-02) 与 `#FFFFFF` 交替 |
|
||||
| 任务条 | 按 §25.1 取色(每类任务一色),圆角 `2px`,末端可带箭头 |
|
||||
| 网格线 | `1px solid #F5F5F5` (FS-004-03) |
|
||||
| 时间轴 / 月份标签 | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 图例 | 圆点 + 文字,圆点取对应任务色,文字 `#575757` |
|
||||
|
||||
### 25.6 饼图 / 环形图(Pie / Donut)
|
||||
|
||||
支持三环至八环(即 3~8 个分类),扇区按 §25.1 对应行取色。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 扇区 | §25.1 通用色序 |
|
||||
| 中心主数字(如 `34801`) | `#222222` (FS-004),D-DIN |
|
||||
| 中心说明(XXX总数) | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 引导线 + 标签 | 引导线同扇区色,标签文字 `#575757` (FS-004-09),百分比同行 |
|
||||
| 扇区间隙 | `2px` 白色描边分隔,环宽适中(甜甜圈留中心空 ≥ 50%) |
|
||||
|
||||
---
|
||||
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,121 @@
|
||||
# 浅红色 UI 规范 · 六、页面与布局
|
||||
|
||||
> 返回 [规范目录](README.md) | 本篇:统计与汇总卡 · 实体卡片 · 综合页面布局示例
|
||||
|
||||
---
|
||||
|
||||
## 26. 统计与汇总卡(Dashboard)
|
||||
|
||||
> 仪表盘顶部的指标卡与汇总卡,用于一屏概览关键数据。
|
||||
|
||||
### 26.1 指标卡(已用 / 可用 + 迷你环)
|
||||
|
||||
横向排列的使用率卡,左侧数值、右侧迷你环形进度。
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 卡标题(如"账号使用率") | `14px Regular`,`#575757` (FS-004-09) |
|
||||
| 主数值(已用,如 `139`) | D-DIN `26px Bold`,`#222222` (FS-004) |
|
||||
| 次数值(可用,如 `2`) | D-DIN,`#FF9900`(警告橙,FS-001-09) |
|
||||
| 数值下标签(已用 / 可用) | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 迷你环 + 中心百分比 | 按使用率阈值取语义色(§20):低→绿、中→橙、高→红;轨道 `#F5F5F5` |
|
||||
| 卡间竖分隔 | `1px solid #E8E8E8` (FS-004-04) |
|
||||
|
||||
### 26.2 汇总卡(总量 + 正常 / 异常 + 环形)
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 总量数值(如 `300`) | D-DIN,`#222222` (FS-004) |
|
||||
| 正常数值(如 `270`) | `#FF9900`(橙)或成功绿,按业务定 |
|
||||
| 异常数值(如 `30`) | `#F5222D`(错误红,ZS-001-09) |
|
||||
| 标签(总量 / 正常 / 异常) | `#575757` (FS-004-09) |
|
||||
| 环形图 | 正常段绿 `#97EBCD`、异常段红 `#FA9196`(§25.1 色序);中心主数(如 `40%`)`#222222`、说明(异常率)`#A6A6A6` |
|
||||
|
||||
### 26.3 时间范围切换(今日 / 近7日)
|
||||
|
||||
分段选择,沿用 §14.3 按钮式页签:
|
||||
|
||||
| 状态 | 配色 |
|
||||
|------|------|
|
||||
| 选中(今日) | 背景 `#F5222D` (ZS-001-09),文字 `#FFFFFF` |
|
||||
| 未选(近7日) | 背景 `#FFFFFF`,边框 `#DBDBDB`,文字 `#222222` |
|
||||
|
||||
### 26.4 资源检索条
|
||||
|
||||
`[资源类型 ▾] [请输入关键词] [搜索]`:下拉 + 输入框沿用 §13;搜索为主按钮(§5.2.1 红)。配合右侧表格(§22),表头含排序箭头(默认 `#A6A6A6`,激活 `#F5222D`)。
|
||||
|
||||
---
|
||||
|
||||
## 27. 实体卡片(列表卡 / 任务集卡)
|
||||
|
||||
> 卡片网格陈列实体(任务集 / 人物 / 项目等),含主数据、属性表、负责人操作按钮与空状态。
|
||||
|
||||
### 27.1 卡片结构
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 卡片背景 / 边框 / 阴影 | `#FFFFFF` / `1px solid #E8E8E8` / §3.1.3 一级阴影,圆角 `4px` |
|
||||
| 主标题(如人名) | `16px Bold`,`#222222` (FS-004) |
|
||||
| 副标题(项目名) | `14px Regular`,`#575757` (FS-004-09) |
|
||||
| 创建时间 | `12px`,`#A6A6A6` (FS-004-07) |
|
||||
| 主指标(目标数量,如 `10247`) | D-DIN `26px Bold`,`#F5222D` (ZS-001-09);标签"目标数量" `#A6A6A6` |
|
||||
| 属性面板(社交媒体(52)) | 背景 `#FEF6F6` (ZS-001-02);条目名 `#575757`、数值 `#F5222D` (ZS-001-09) |
|
||||
| 联系/备注行 | `#575757` (FS-004-09),时间后缀 `#A6A6A6` |
|
||||
| 底部负责人按钮 | 通栏主按钮:背景 `#F5222D`、文字 `#FFFFFF`(§5.2.1) |
|
||||
|
||||
### 27.2 卡片 Hover 操作菜单
|
||||
|
||||
卡片右上 `⋯` 触发**深色下拉**:
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 菜单背景 | `#3D3D3D` (FS-004-10),圆角 `4px`,阴影 §3.1.3 二级 |
|
||||
| 菜单项(修改 / 删除) | 文字 + 图标 `#FFFFFF`;hover 背景 `rgba(255,255,255,0.1)` |
|
||||
|
||||
### 27.3 空状态(暂无任务)
|
||||
|
||||
| 元素 | 配色 |
|
||||
|------|------|
|
||||
| 空状态插图 / 图标 | 中性灰 `#C1C1C1` (FS-004-06) |
|
||||
| 空状态文字(暂无任务) | `14px`,`#A6A6A6` (FS-004-07) |
|
||||
| 主指标归零 | 数值显示 `0`,颜色同 §27.1(红) |
|
||||
|
||||
---
|
||||
|
||||
## 28. 综合页面布局示例
|
||||
|
||||
> 标准后台页面 = 顶部红底导航(§7.1)+ 左侧分级侧边栏(§7.3 / §7.6)+ 右侧内容区。
|
||||
|
||||
### 28.1 仪表盘页
|
||||
|
||||
```
|
||||
┌ Header(红底,§7.1)────────────────────────────────────────────┐
|
||||
├──────┬───────────────────────────────────────────────────────────┤
|
||||
│ 侧栏 │ 面包屑(§8.1) │
|
||||
│(§7.3)│ ┌ 指标卡 × N(§26.1,横向等分,竖线分隔)───────────────┐ │
|
||||
│ │ ├ 汇总卡(§26.2) │ 折线图(§25.4) │ 资源表(§22 + 检索§26.4)│ │
|
||||
│ │ └ 异常分布图 … │ │
|
||||
└──────┴───────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- 内容区背景 `#FAFAFA` (FS-004-02),卡片白底浮起;模块间距 `--spacing-5` (24px),卡内边距 `--spacing-4` (16px)
|
||||
|
||||
### 28.2 列表卡片页
|
||||
|
||||
```
|
||||
┌ Header(红底)─────────────────────────────────────────────────┐
|
||||
├──────┬───────────────────────────────────────────────────────────┤
|
||||
│ 侧栏 │ [搜索框] [搜索] [+ 添加任务集] 排序 [创建时间 ▾]│
|
||||
│ │ ┌实体卡┐ ┌实体卡┐ ┌实体卡┐ ┌实体卡┐ (§27,等宽网格) │
|
||||
│ │ └─────┘ └─────┘ └─────┘ └─────┘ │
|
||||
│ │ ┌实体卡┐ ┌空状态┐ … │
|
||||
└──────┴───────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- 卡片网格列间距 / 行间距 `--spacing-5` (24px)
|
||||
- 顶部工具条:搜索输入(§13)+ 搜索主按钮(§5.2.1)+ "添加"主按钮;右侧排序下拉(§13)
|
||||
- "+ 添加任务集"为主按钮(红 `#F5222D` + 白字 + 加号图标,§5.3.2)
|
||||
|
||||
---
|
||||
|
||||
> 返回 [规范目录](README.md)
|
||||
@@ -0,0 +1,85 @@
|
||||
# 浅红色 UI 规范
|
||||
|
||||
浅色主题设计规范:以白 / 浅灰作大面积背景、深色作正文、**红色(`#F5222D`)为品牌强调主色**。
|
||||
|
||||
> 全文按主题拆分为 6 篇,章节号(§1 ~ §28)全局唯一,跨篇引用(如"沿用 §5.2.1")按下表定位即可。
|
||||
|
||||
## 篇目导航
|
||||
|
||||
| 篇 | 文件 | 内容 |
|
||||
|----|------|------|
|
||||
| 一、基础样式 | [01-基础样式.md](01-基础样式.md) | §1 色彩 · §2 字体 · §3 阴影 · §4 圆角 · §6 间距 · §20 语义状态色 |
|
||||
| 二、按钮与表单 | [02-按钮与表单.md](02-按钮与表单.md) | §5 按钮 · §12 表单 · §13 输入框 · §14 选择按钮 · §15 标签输入框 · §16 上传 |
|
||||
| 三、导航 | [03-导航.md](03-导航.md) | §7 导航组件 · §8 面包屑 · §9 页头与分页 · §10 步骤条 · §11 页签与锚点 |
|
||||
| 四、数据展示 | [04-数据展示.md](04-数据展示.md) | §17 弹窗 · §18 卡片 · §19 折叠面板 · §21 进度条 · §22 表格 · §23 标签 · §24 时间轴 |
|
||||
| 五、图表 | [05-图表.md](05-图表.md) | §25 图表(通用色序 / 柱 / 折线 / 甘特 / 饼环) |
|
||||
| 六、页面与布局 | [06-页面与布局.md](06-页面与布局.md) | §26 统计与汇总卡 · §27 实体卡片 · §28 综合页面布局示例 |
|
||||
|
||||
## 章节速查(§ → 篇)
|
||||
|
||||
| § | 章节 | 所在篇 |
|
||||
|---|------|--------|
|
||||
| 1 | 色彩 | [一](01-基础样式.md) |
|
||||
| 2 | 字体 | [一](01-基础样式.md) |
|
||||
| 3 | 阴影 | [一](01-基础样式.md) |
|
||||
| 4 | 圆角 | [一](01-基础样式.md) |
|
||||
| 5 | 按钮 | [二](02-按钮与表单.md) |
|
||||
| 6 | 间距 | [一](01-基础样式.md) |
|
||||
| 7 | 导航组件 | [三](03-导航.md) |
|
||||
| 8 | 面包屑 | [三](03-导航.md) |
|
||||
| 9 | 页头与分页 | [三](03-导航.md) |
|
||||
| 10 | 步骤条 | [三](03-导航.md) |
|
||||
| 11 | 页签与锚点 | [三](03-导航.md) |
|
||||
| 12 | 表单 | [二](02-按钮与表单.md) |
|
||||
| 13 | 输入框 | [二](02-按钮与表单.md) |
|
||||
| 14 | 选择按钮 | [二](02-按钮与表单.md) |
|
||||
| 15 | 标签输入框 | [二](02-按钮与表单.md) |
|
||||
| 16 | 上传 | [二](02-按钮与表单.md) |
|
||||
| 17 | 弹出式窗口 | [四](04-数据展示.md) |
|
||||
| 18 | 卡片 | [四](04-数据展示.md) |
|
||||
| 19 | 折叠面板 | [四](04-数据展示.md) |
|
||||
| 20 | 语义状态色 | [一](01-基础样式.md) |
|
||||
| 21 | 进度条 | [四](04-数据展示.md) |
|
||||
| 22 | 表格 | [四](04-数据展示.md) |
|
||||
| 23 | 标签 | [四](04-数据展示.md) |
|
||||
| 24 | 时间轴 | [四](04-数据展示.md) |
|
||||
| 25 | 图表 | [五](05-图表.md) |
|
||||
| 26 | 统计与汇总卡 | [六](06-页面与布局.md) |
|
||||
| 27 | 实体卡片 | [六](06-页面与布局.md) |
|
||||
| 28 | 综合页面布局示例 | [六](06-页面与布局.md) |
|
||||
|
||||
## 颜色速查
|
||||
|
||||
完整色板与编号见 [§1 色彩](01-基础样式.md)。最常用的功能色:
|
||||
|
||||
| 角色 | 色值 | 编号 |
|
||||
|------|------|------|
|
||||
| 主色 Primary | `#F5222D` | ZS-001-09 |
|
||||
| 主色 Hover | `#CF1322` | ZS-001 |
|
||||
| 主色 Active | `#A8071A` | ZS-001-11 |
|
||||
| 链接 / 信息 | `#0079FE` | ZS-002-09 |
|
||||
| 正文 | `#222222` | FS-004 |
|
||||
| 次级文字 | `#575757` | FS-004-09 |
|
||||
| 备注 / 占位 | `#A6A6A6` | FS-004-07 |
|
||||
| 禁用文字 | `#C1C1C1` | FS-004-06 |
|
||||
| 页面背景 | `#FAFAFA` | FS-004-02 |
|
||||
| 容器背景 | `#FFFFFF` | FS-004-01 |
|
||||
| 分割线 | `#E8E8E8` | FS-004-04 |
|
||||
|
||||
**语义状态色**(成功 / 警告 / 错误 / 信息 / 待更新 / 中性,详见 [§20](01-基础样式.md)):
|
||||
|
||||
| 语义 | 文字 | 浅底 | 实填 |
|
||||
|------|------|------|------|
|
||||
| 成功(绿) | `#189D72` | `#EEFCF7` | `#2FD69A` |
|
||||
| 警告(橙) | `#FF9900` | `#FFF6EA` | `#FF9900` |
|
||||
| 错误(红) | `#F5222D` | `#FEEDED` | `#F5222D` |
|
||||
| 信息(蓝) | `#0079FE` | `#EAF4FF` | `#0079FE` |
|
||||
| 待更新(青) | `#45C3F3` | `#EFFAFE` | `#45C3F3` |
|
||||
| 中性(灰) | `#7F7F7F` | `#F5F5F5` | `#A6A6A6` |
|
||||
|
||||
## 通用约定速记
|
||||
|
||||
- **圆角**:按钮 / 输入框 / Tag `2px`;卡片 / 分栏 / Modal `4px`(§4)
|
||||
- **间距阶梯**:4 / 8 / 12 / 16(密)· 24 / 32 / 40 / 56(疏),16 是密的上限、24 是疏的下限(§6)
|
||||
- **按钮尺寸**:小 `24px` / 正常 `32px`(§5.1)
|
||||
- **字体**:中文 Noto Sans S Chinese,数字 D-DIN(§2)
|
||||
+11
-307
@@ -1,310 +1,14 @@
|
||||
# 浅色红色 UI 规范对齐 — 实施计划
|
||||
# 浅红色 UI 规范(已拆分)
|
||||
|
||||
> 依据:`H:\页面设计\UI设计规范\浅色红色设计规范-前端用.pdf`(共 104 页)
|
||||
> 范围:**仅对齐 Light 模式(红色主题)**,**不改动图表部分**
|
||||
本规范已按主题拆分到文件夹 **[`浅红色UI规范/`](浅红色UI规范/README.md)**,请从目录进入:
|
||||
|
||||
---
|
||||
👉 **[浅红色UI规范 / README.md](浅红色UI规范/README.md)**
|
||||
|
||||
## ⚠️ 重要约束(必读)
|
||||
|
||||
### 1. 主题切换必须保留
|
||||
项目使用 `next-themes` 实现 Light/Dark 切换:
|
||||
|
||||
- `:root` → Light 模式(红色品牌,对应本规范)
|
||||
- `.dark` → Dark 模式(蓝色品牌,**不在本次范围内**)
|
||||
- 切换组件入口:`src/components/theme-provider.tsx`
|
||||
|
||||
**所有改动只能动 `:root` 块和 light-only 选择器,禁止动 `.dark` 块和 `dark:` 前缀样式。**
|
||||
|
||||
### 2. 不动图表
|
||||
本次跳过 `chart-1` ~ `chart-5` 颜色变量和所有图表组件。
|
||||
|
||||
### 3. 同一 token 双模式都用时如何改
|
||||
若变量同时被 light/dark 使用(如 `--radius`、按钮 `h-*`、`--primary-foreground`),改动后需在 Dark 模式下回归检查,确保没有破坏。
|
||||
|
||||
---
|
||||
|
||||
## 改动总目标对照
|
||||
|
||||
| 类别 | UI 规范 | 现状 | 差异 |
|
||||
|------|--------|------|------|
|
||||
| 主品牌红 | `#F5222D` | `#d92121` (`oklch(0.52 0.19 27)`) | 偏差 |
|
||||
| 深色品牌 | `#CF1322` / `#A8071A` | 未使用 | 缺失 |
|
||||
| 圆角-按钮 | 2px | 12px (`--radius: 0.75rem`) | 严重偏大 |
|
||||
| 圆角-卡片 | 4px | 12px | 严重偏大 |
|
||||
| 按钮高度(正常)| 32px | 36px (`h-9`) | 偏大 4px |
|
||||
| 按钮高度(小)| 24px | 32px (`h-8`) | 偏大 8px |
|
||||
| 输入框高度 | 32px | 36px (`h-9`) | 偏大 4px |
|
||||
| 中文字体 | NotoSansSChinese | 系统字体 | 未引入 |
|
||||
| 数字字体 | D-DIN | 系统字体 | 未引入 |
|
||||
| 间距体系 | 8px 基准(4/8/12/16/24/32/40/56)| Tailwind 默认 | 基本一致 |
|
||||
|
||||
---
|
||||
|
||||
## 分步实施计划
|
||||
|
||||
### Step 1 — 颜色变量对齐(Light 模式)
|
||||
|
||||
**文件**:`src/styles/globals.css`
|
||||
**只动 `:root` 块(第 242-277 行),保持 `.dark` 块原样**
|
||||
|
||||
#### 1.1 主色映射
|
||||
|
||||
| 角色 | 规范值 | 用途 |
|
||||
|------|--------|------|
|
||||
| 主色 | `#F5222D` | `--primary`、`--ring`、`--sidebar-primary` |
|
||||
| 主色 hover | `#CF1322` | 按钮 hover 状态(新增辅助变量) |
|
||||
| 主色 active | `#A8071A` | 按钮按下状态 |
|
||||
| 主色淡 1 | `#FEEDED` | `--accent`(极淡红,背景) |
|
||||
| 主色淡 2 | `#FDDADC` | hover bg、tag 背景 |
|
||||
| 主色淡 3 | `#FCB5B9` | 浅边框、selected 态 |
|
||||
| 危险色 | `#F5222D` | `--destructive` |
|
||||
|
||||
#### 1.2 新增工程变量(建议加在 `:root` 内)
|
||||
|
||||
```css
|
||||
/* 红色主题阶梯色(规范色板)*/
|
||||
--brand-50: #FEFAFA;
|
||||
--brand-100: #FEF6F6;
|
||||
--brand-200: #FEEDED;
|
||||
--brand-300: #FDDADC;
|
||||
--brand-400: #FCB5B9;
|
||||
--brand-500: #FA9196;
|
||||
--brand-600: #F86C73;
|
||||
--brand-700: #F74750;
|
||||
--brand-800: #F5222D; /* ← 主色 */
|
||||
--brand-900: #CF1322; /* ← hover */
|
||||
--brand-950: #A8071A; /* ← active */
|
||||
|
||||
/* 辅色(规范)*/
|
||||
--accent-orange: #FF9900;
|
||||
--accent-green: #2FD69A;
|
||||
--accent-cyan: #45C3F3;
|
||||
```
|
||||
|
||||
#### 1.3 `--workspace-brand` 同步
|
||||
|
||||
`:root` 内:`--workspace-brand: #F5222D;`(从 `#d92121` 改)
|
||||
`.dark` 内:**不动**(保持 `#3b82f6` 蓝色)
|
||||
|
||||
#### 1.4 验收
|
||||
- 切到 Light 模式:所有按钮、链接、选中态使用规范红
|
||||
- 切到 Dark 模式:依然是原蓝色品牌(无变化)
|
||||
|
||||
---
|
||||
|
||||
### Step 2 — 圆角规范化
|
||||
|
||||
**文件**:`src/styles/globals.css`(`--radius` 是全局变量,light/dark 共用)
|
||||
|
||||
#### 2.1 改动方案(推荐)
|
||||
|
||||
按规范:按钮 2px、卡片/页面框 4px。但当前许多组件依赖 `rounded-md` / `rounded-lg`,全局把 `--radius` 改成 4px 会引起视觉跳变。
|
||||
|
||||
**采用细粒度策略:**
|
||||
|
||||
```css
|
||||
:root {
|
||||
--radius: 0.25rem; /* 4px → 卡片/页面框 */
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--radius-sm: 2px; /* 按钮、tag */
|
||||
--radius-md: calc(var(--radius) - 1px); /* 3px → 输入框 */
|
||||
--radius-lg: var(--radius); /* 4px → 卡片 */
|
||||
--radius-xl: calc(var(--radius) + 4px); /* 8px → 弹窗 */
|
||||
--radius-2xl: calc(var(--radius) + 8px); /* 12px → 大卡片 */
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2 例外保留(设计感样式)
|
||||
以下组件**圆角不改**,保持设计稿原貌:
|
||||
- `.workspace-user-bubble`(聊天气泡,圆角 `1.6rem 1.6rem 0.5rem 1.6rem`)
|
||||
- `.workspace-assistant-card`(圆角 `1.75rem`)
|
||||
- `.gemini-gradient-border`(圆角 `1.5rem`)
|
||||
|
||||
#### 2.3 验收
|
||||
- 普通按钮变为近直角(2px)
|
||||
- 卡片维持温和圆角(4px)
|
||||
- 聊天气泡、AI 卡片不变形
|
||||
|
||||
---
|
||||
|
||||
### Step 3 — 按钮组件尺寸对齐
|
||||
|
||||
**文件**:`src/components/ui/button.tsx`
|
||||
|
||||
#### 3.1 改 size 变体(规范:小 24px / 正常 32px)
|
||||
|
||||
| size | 规范 | 当前 | 改后 |
|
||||
|------|------|------|------|
|
||||
| `sm` | 24px | h-8 (32px) | `h-6 px-2 text-xs` |
|
||||
| `default` | 32px | h-9 (36px) | `h-8 px-3 text-sm` |
|
||||
| `lg` | — | h-10 (40px) | 保留 `h-10`(用于 Banner/登录场景)|
|
||||
|
||||
#### 3.2 圆角
|
||||
- 默认按钮:`rounded-sm`(2px)
|
||||
|
||||
#### 3.3 主按钮配色
|
||||
- bg:`bg-primary`
|
||||
- hover:`hover:bg-[var(--brand-900)]`(深红 `#CF1322`)
|
||||
- active:`active:bg-[var(--brand-950)]`(更深 `#A8071A`)
|
||||
- disabled:`disabled:opacity-50`(保留)
|
||||
|
||||
#### 3.4 次要按钮 / 文本按钮
|
||||
- 次要按钮(`outline` variant):边框 `border-primary`,文字 `text-primary`
|
||||
- 文本按钮(`ghost` variant):仅文字色 `text-primary`,hover 背景 `--brand-200`
|
||||
|
||||
#### 3.5 验收
|
||||
检查所有调用 `<Button>` 的页面:
|
||||
- 工具栏按钮(之前 h-9 → 现在 h-8)
|
||||
- 弹窗确认/取消(之前 h-9 → 现在 h-8)
|
||||
- Landing 主 CTA 按钮(保留 `lg`)
|
||||
|
||||
---
|
||||
|
||||
### Step 4 — 输入框尺寸对齐
|
||||
|
||||
#### 4.1 `src/components/ui/input.tsx`
|
||||
- `h-9` → `h-8`(32px)
|
||||
- `rounded-md`(沿用 3px)
|
||||
- 边框:`border-input`(变量已是浅灰,不变)
|
||||
- focus:`focus-visible:ring-[2px] focus-visible:ring-primary/35`
|
||||
|
||||
#### 4.2 `src/components/ui/textarea.tsx`
|
||||
- 最小高度建议 `min-h-16`
|
||||
- 圆角 `rounded-md`
|
||||
|
||||
#### 4.3 `src/components/ui/select.tsx`
|
||||
- `size: default` → `h-8`
|
||||
- `size: sm` → `h-6`
|
||||
|
||||
#### 4.4 验收
|
||||
- 搜索框、表单输入、下拉框高度一致(32px)
|
||||
- 与按钮对齐时高度一致
|
||||
|
||||
---
|
||||
|
||||
### Step 5 — 字体引入
|
||||
|
||||
#### 5.1 引入字体文件
|
||||
在 `frontend-web/public/fonts/` 下放置:
|
||||
- `NotoSansSC-Regular.woff2` / `Medium.woff2` / `Bold.woff2`
|
||||
- `D-DIN-Regular.woff2` / `Bold.woff2`
|
||||
|
||||
> 若需在线方式,可用 Google Fonts CDN:
|
||||
> `https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap`
|
||||
|
||||
#### 5.2 `globals.css` 顶部添加 `@font-face`
|
||||
|
||||
```css
|
||||
@font-face {
|
||||
font-family: 'Noto Sans SC';
|
||||
src: url('/fonts/NotoSansSC-Regular.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
/* Medium / Bold 同上 */
|
||||
|
||||
@font-face {
|
||||
font-family: 'D-DIN';
|
||||
src: url('/fonts/D-DIN-Regular.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
```
|
||||
|
||||
#### 5.3 修改 `--font-sans`(globals.css 第 74 行)
|
||||
|
||||
```css
|
||||
--font-sans:
|
||||
'Noto Sans SC', ui-sans-serif, system-ui, sans-serif,
|
||||
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
|
||||
--font-numeric: 'D-DIN', 'Noto Sans SC', sans-serif;
|
||||
```
|
||||
|
||||
#### 5.4 数字字体工具类
|
||||
新增 `.font-numeric { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }`
|
||||
|
||||
仪表盘、表格中重要数字加 `className="font-numeric"`。
|
||||
|
||||
#### 5.5 验收
|
||||
- 中文文本回退到 Noto Sans SC
|
||||
- Dark 模式同样生效(字体是全局变量)
|
||||
|
||||
---
|
||||
|
||||
### Step 6 — Badge / 状态标签色对齐
|
||||
|
||||
**文件**:`src/components/ui/badge.tsx`
|
||||
|
||||
规范状态色(参考 PDF 第 67 页):
|
||||
|
||||
| 状态 | 颜色定位 | 推荐 token |
|
||||
|------|---------|-----------|
|
||||
| 未开始 | 中性灰 | `bg-muted text-muted-foreground` |
|
||||
| 等待中 | 蓝/青 | `bg-blue-50 text-blue-600`(保留) |
|
||||
| 进行中 | 主红 | `bg-[var(--brand-200)] text-primary` |
|
||||
| 已完成 | 绿 | `bg-emerald-50 text-emerald-600` |
|
||||
| 已失败 | 红/橙 | `bg-red-50 text-red-600` |
|
||||
| 待更新 | 黄/橙 | `bg-amber-50 text-amber-700` |
|
||||
|
||||
需要新增 `variant`:`waiting`、`processing`、`success`、`failed`、`pending`。
|
||||
|
||||
圆角统一 `rounded-sm`,padding `px-2 py-0.5`,字号 `text-xs`。
|
||||
|
||||
---
|
||||
|
||||
### Step 7 — 全局间距 & 阴影规范化
|
||||
|
||||
#### 7.1 间距
|
||||
规范基于 8px 网格(4 / 8 / 12 / 16 / 24 / 32 / 40 / 56)。Tailwind 默认 4px 步进(`p-1`=4, `p-2`=8...)已兼容。
|
||||
|
||||
**只需 review**:检查页面是否有 `p-2.5`、`gap-1.5` 等非 8 的倍数,统一改成 8 的倍数。
|
||||
|
||||
#### 7.2 阴影
|
||||
规范阴影仅用于"标题+操作"和"卡片新增"两类。其余卡片保持平。
|
||||
|
||||
新增工具类(可选):
|
||||
```css
|
||||
.shadow-card { box-shadow: 0 2px 8px 0 rgba(0,0,0,0.06); }
|
||||
.shadow-card-hover { box-shadow: 0 4px 12px 0 rgba(0,0,0,0.08); }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Step 8 — 验收清单
|
||||
|
||||
每步完成后检查:
|
||||
|
||||
- [ ] **Light 模式**视觉对齐规范(参考 PDF 关键页:5、7、10、36、66)
|
||||
- [ ] **Dark 模式**完全无变化(切换主题验证)
|
||||
- [ ] 首页 / Workspace / 聊天 / 设置弹窗 → 按钮和输入框高度统一
|
||||
- [ ] 主题切换按钮点击 → 颜色平滑切换,无错位/闪烁
|
||||
- [ ] `/landing` 强制 Dark 模式仍正常
|
||||
- [ ] 控制台无 CSS 变量未定义警告
|
||||
|
||||
---
|
||||
|
||||
## 执行顺序建议
|
||||
|
||||
```
|
||||
Step 1 (颜色变量) ─┐
|
||||
├→ Step 3 (按钮) ─┐
|
||||
Step 2 (圆角) ─┘ ├→ Step 6 (Badge) ─→ Step 7 (间距/阴影) ─→ Step 8 (验收)
|
||||
│
|
||||
Step 4 (输入框) ──┤
|
||||
Step 5 (字体) ────┘
|
||||
```
|
||||
|
||||
并行可行:Step 1 + Step 2 完成后,Step 3/4/5 可同时推进。
|
||||
|
||||
---
|
||||
|
||||
## 风险提示
|
||||
|
||||
1. **圆角从 12px → 4px 是大幅度视觉变化**,建议先在分支上做、配截图比对再合并
|
||||
2. 字体文件体积较大(NotoSansSC 全字符集 ~10MB),建议子集化或仅引入需要的字重
|
||||
3. `--radius-sm` 改后可能影响 dropdown menu / popover 等小组件外观,需逐个检查
|
||||
4. Dark 模式下的红色 `--workspace-brand` 已是蓝色,**不要把蓝色也改成 #F5222D**
|
||||
| 篇 | 文件 |
|
||||
|----|------|
|
||||
| 一、基础样式(色彩 / 字体 / 阴影 / 圆角 / 间距 / 语义色) | [01-基础样式.md](浅红色UI规范/01-基础样式.md) |
|
||||
| 二、按钮与表单 | [02-按钮与表单.md](浅红色UI规范/02-按钮与表单.md) |
|
||||
| 三、导航 | [03-导航.md](浅红色UI规范/03-导航.md) |
|
||||
| 四、数据展示 | [04-数据展示.md](浅红色UI规范/04-数据展示.md) |
|
||||
| 五、图表 | [05-图表.md](浅红色UI规范/05-图表.md) |
|
||||
| 六、页面与布局 | [06-页面与布局.md](浅红色UI规范/06-页面与布局.md) |
|
||||
@@ -57,6 +57,7 @@
|
||||
"cmdk": "^1.1.1",
|
||||
"codemirror": "^6.0.2",
|
||||
"date-fns": "^4.1.0",
|
||||
"dayjs": "^1.11.21",
|
||||
"docx": "^9.5.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><style>.a{fill:#fff;opacity:0;}.b{fill:url(#a);}</style><linearGradient id="a" x1="0.277" y1="0.03" x2="0.725" y2="1.083" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#92eeff"/><stop offset="1" stop-color="#00c7ff"/></linearGradient></defs><g transform="translate(-128.5 -117)"><rect class="a" width="16" height="16" transform="translate(128.5 117)"/><path class="b" d="M4,0,8,5H0Z" transform="translate(140.5 128) rotate(180)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 589 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="84.499" height="70" viewBox="0 0 84.499 70"><defs><style>.a{fill:url(#a);}</style><linearGradient id="a" x1="0.043" x2="0.978" y2="1.016" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#0062d9" stop-opacity="0.6"/><stop offset="1" stop-color="#0062d9" stop-opacity="0.302"/></linearGradient></defs><path class="a" d="M8855.277-1940.39l-.054-70h78v31.183l6.5,5.257-6.5,5.259v28.3Z" transform="translate(-8855.224 2010.389)"/></svg>
|
||||
|
After Width: | Height: | Size: 536 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="77" height="45" viewBox="0 0 77 45"><defs><style>.a{fill:url(#a);}</style><pattern id="a" preserveAspectRatio="none" width="100%" height="100%" viewBox="0 0 340 45"><image width="340" height="45" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAAAtCAYAAADxyJMIAAAABHNCSVQICAgIfAhkiAAAIABJREFUeF7tnd2O5MZ1x5vdPTO7WkmGhMiQDQS5NODbvEBeIgbygcRwjOQur+D1K+QiQC4CBMld8hJ+CgO+DpAIcixblvZjZnqG+f/PqcM6Vawii+zuda+0XLSaXawvFos//s85xVHX9/3mXFvXdeeq+htSb/9mB4iX+vlmfZu/PKLs1BX7/ET1fndznsn8w5X1Pkc5jvfPV5ZfPcu784zD6v683QWXMLJbknnpsHy7gXpmWP5sIYRaYHgqsC2dKG97/haQL4Xy2SH8Drqt024JI98BtXVUi/nOBM0pWLaAkX09JRx/sBDe+Vj99sjyR10jV/ijI5Xir44s78+jBcLMPwXis0H3HWz9pXoH1FPdgFLPCaF5DCjXAvLrALM/rQzKuWH36QnH7xTX9bMzw2IO2muhPAfgNwbeM4/fKa7xiet4B9RVAzq4ndb7GL3nquSrnFKXrcBcqhbngHlO4P3+Qp3oH54xcDAH7Dng5nO3FcBTwC3Blv5d29bPeNfbby5o3wF1EVBH/vtl0+tn0ti4TA2ex4JzDpD5uc8B81TQe3FhSnTRHEDmZycCwhys54Cb97sG4GNBW1O0R7sRTjSOS6/fGfO/A2pxcJsDnykcFZjlLYdmGZZj2JZUZisof4iufJHBaykUW+D38QJ1+fIth6ld3fcWwOCLTOUSyPm4zkHa4MvrVwNxK4BL4F0L3bO4DxaM7RnhuKbqd0BdEzuo+TdLSnNOZY6B2W3mgFlSki2grMFxCoinAOBtBbg3ATS14zajP3FT+/WJgPzE3bS/XnPruDJ2HsdUUwL0/6DC78tDsfyEb4Vw3q858K4B7tiN0CNI5rd4Dj+fHajC+S4zBmdbOFOGbxlQm5VnHO4SPH85HNar/Pno6kwrzTZgah05KKlO8rQSKEuQXArHGugIuBawEVot+fzw3U5E+W/w9Js67utZkrd0c7H8kq31XJmvBvClYC5BuATfHLylOWSq92P0L87v8gh44I6V7XjcctiWVG0K2caxvzzIfguA2nht8qkzDVLNXVef3eYHSYVUnbaNZ0GuOBWY5dmSw/M18lLF+C0Hp4GxdMPWoPnBCZRgK/xmwPXRswUuhSUQDHl/+2JF4KkE7KUQLvX1q4q5O3Xt8mM5aKl0nxTcDrWxyl0KU4o2wlVvtCnXQTtYV9y0lwHXbyhQF16PHJ7+Ca3qs361vMk+pTw9NKPCTOtNYanHcqU5pTJPBccZELYC7vFEQF3ByDdSZBsAaudpv+canwX4UjAvgbB1Lodui7K1sh64Ebbjm25ayVptWu67btRyBbs4+PWHg+s3AKiL4ZnOd+/3HJvuqao01VkDZ6o0O5jmaXn75cGpwNSMY1imM6MEzDklWYNaTfUh/3fQFcLh5EC8v5BF+3PEaz1+tdAt0Fjvl1NAranpOQiXoDvnYvDQ9cBNXQjpDViGLc885jPQ/koGpH4De0Wb+mM3y1/RfTOQfQuBugCgpah7C0BT1elvA70qn2brUBWcZbX5x6H4i2C2KjTHV/e22yb3WwRleSaUQFmA5HeOUYmNAOyfnsA90Aibty7bl7jY141R6yMAXYRwCb5LwVuDrsH2Wf8o1+S/8RkHyfRGmXch9JuP3JWtuQ2mAEswzwe7XCPnAexbBNRGkFq25xi7sXO9KwSQNhP+TsJzPPI+KGRqk+A0aD5DJ14EyHrV6RXmJw6qMXAT24og1LQMlgZKb2bOKsoaIClJC1t/dxpQ9nfjB0h3rcqkdEyeTuH4VJ5TwbWlran++vLH9KkKXkC5uM0AuDQ3RuDNoVsCbm1FxE2AKTsXAYslYWEaP4PflqDV+Rtv4AjYmOb9tPkqA1WyMhWGPe8isES6Cp6HH828bM7YdGkvHKiNEOWp5mrUYDq1bGnKhDcVOl6O1GENoQ1uBx+n7kdwlsx0TUvN81Z4Sr4mpTmjKE+pJGsgbJp1LlN/OG/AaWl/avm7/YrAVaGyU8GXVXevZpRvg+IdAZaK9Ius4zVV+1Wn6pRbVLLpTWugVZeBHist9zLIlgJg0UUw5R7Qfoz9rwumwPFwvVCgNoLUQ3QcSJI5N4xmhOd4gE2FlnyeCk8LEOV+Tk3PfZs1c11VZ644c2DmVzX+rgDzGFC2gHE19J4UFO5XGIEPFszxS83K87DNzud1o2mfnVMLrI8BcRW8a4DrFe3NJgJVz0lv3NRf2zvY2pn3ULS2vnYtZLW9qF7jqNYCXM0ugfVgvSCgNtw5BtDclC8Fk8wPGpcraQPe/xkBqsfSYBFTOihP65jBU9O5jddjhjwO5GqqT0EzB+bwO4By8dWdguQiOJaA2HCZzpWlb/TptrbfNQClta6j8xHQV21AngPwWviOwDs9Pn2ibhW0erNERRuVUVx/G/Ikil8By/JfqCdI6nkW0mxwP3THPstuizTQlV6O8XItPX4GwF42UOtm/Hj++nWfPgofAcpF8ikczXS3pUlT8PzAKVWrxfyc0b85D84IBZ0tGtCpq1J3rAbKWUieAYwnhdvNhUf/b08XzT8LxGeUcQ3AS8BbgG1ZnWIyB9BGmBpsU9fBWM3mboMcsgrYuNVWFKQBLl9C2zQFO145MOZKkjKvbS4XqK0wTU35eMbRB5oO0liFjpcrmQk/XpLU4U0dbonZnvk3/ah3m1RVdc48T/OlvewyeEbV2uJzPAFAVwHz0sE4c7uc/PAKEJ8EuA2uh2MhC8CmQL1KzP/EZwfAat7oLoAbYPSQ6gdXQe1FhXTpluiR4Zqpet1sch+swTVforUaqvH2L82XywNqbtaXzXk9F2/Opwvn47nWVaiOzG1gVWk9p19yFFRogOdYUdbBmV8BVaYa+U6g6pRmWbEeCcpmSP4BwDirsk9Ou7YK58zrtloW5KKZ/XVb/qPhu0LZOlWbBzrUhNNAWTxWAe2gYvX+rLsKzB9bh6yW9+o1Va5xMCNcx0GaHLAr3QGXA9Tn4bxjdD6dVbWgEpXo+N12vmGk5cevYarvkzB77ca1Dk/rh1a4AJwllRnAYcCM4FRYjtO19aqtMQvJM8BxNfyusyCV+Qzvj1ue1T9Muwy63elM9mRS3rX5PHM8ngXSM2p4NXwr0MU5jEz+AmxjACIFbb9J/bOSb/DJpko2AteWb/FvIUwBtuR7bfW5rlKu8fa8HKD+WT7t8JsQrQeVIkjjMiYFafSFxgi8+kB1K8NzDC7n74Spnh8f4Adw+mOqQKNpHiEZFWbN3E+A6mA5BuqJQNkExxyEhUuVJ81BrqGKtzrLIog3gPlkEJ4A70Lo4g/fDA+UCM4UtHrT6Jpirwptv098swrZJF8Bsj7oFVcU3AzFbAVBBLGpV3ML8IgCNrZF9Tq1YsD7WyfU65LFdef9f0oZUPn9v+FeSk16TfSRefpDoxKNNyDNeKrQX0O5GEjp+/yYMO0677MeFsN75akL3eHHTCE6Y6ZzOVAEYqq6cuU5AmqAZ0x/H3VlAaylhKnC8pmrqUEdrobjIVOOT9HuHpM4T6+dWK48qTRn1OjG1OhcvrzNNSr2VVYJz23F1gRfvwLgRbmRo6FbcDdMQLYESK5UMOUKn+jQz971LcLUvbxBuA0vNnyZuAwkv3tJoRcs2HrZG2mD/le757lMKw6QD2ylbgHNk75QoGnfw+cX2RinS7H0YAGslwPUf3AnYCAtReipRhWiCh9To+YLZZpF5DWApBsGs7A4ntCSrRIsGvk6R8ozNdVjvzL/qLRxv/Gvl6aQVcU5p1yzq5wo4dGxTYOyXA1L35oHJKGZb0vhFsr3rt4uwMqnFVratObLy1q5Up3FtDkAe9iuBK1vtwm6E0p3NWzrirZ3sC2qT7uM8q1qNsI0fVECMI3H3HlHBVtzEUTrlIEu3fw6WINr+ncJbEkWX4uVW1PKmVugtkqgAaqXA9QfuWFUv2g6jw2kClA9GANKMa9F4fk08kC1MgGgUoea8VLfhxzV7BXJzN/JP4FWU5oJCAumuh5PoVmC51i5qutgbPLPwPJoUJYgOQHGOdClF3PBr+s39CbV3ZJbob3/k6A2KJ9I6cpEngN9BborgMu/TTsAMoyI3pyp6V6HbR2yg6vg91qx1uHfDIuAjfVz5YAB1q8ioHqV+89dY32xIILV2iBgvb81XSWg9UwEsJbMovOa/P84AVGeRFSi0Yy3eU1wKkBT8JThKdec//nA+T4BzyHdgTOmlRWnh11s+2ZCiWaBp2qQ6rovqVmdXUsV35yJfT0G9ipAtsDv0BiAemIX9w1/v25sb98QkFoB6SKA72ZcCQsV8CR024FbB6WCdgTbgqItAtmrWe8q+OrawVUvUw/I6je3q+w4FSsDXKZcrQwBG5WrpipcU5eNh2tJtRYCWP3zxvlDCC2JYLVXqzm7H4cScZlTHlyK78Kb8jSfiFei5nd06pM1B3hKUwGesg94WleL5nbm2/RKU8uH7le+hzxoMwWkgqXbvKen78arC8Csmf/joa0B81hQ1gC5EIr9Q6PKfFgIW6t3h5uG+/y2jWC8Cmk+H4+XoLnDzZS3z7SGrbN2j4XxAgAvAu8pgPsyDER8kKiKVNO9DMZxOouYsk3KzKpap2a9mgZk07YNsApX3Uyt5urVg5X54uuwXrmqWyBLine truncated
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -1,24 +1,322 @@
|
||||
.sidebar-contents{
|
||||
width:98px;
|
||||
height:986px;
|
||||
background:rgba(3, 38, 80, 0.8);
|
||||
border:1px solid;
|
||||
border-color:rgba(43, 143, 254, 0.6);
|
||||
border-radius:4px;
|
||||
backdrop-filter:blur(2px);
|
||||
.sidebar-contnet {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 4rem;
|
||||
z-index: 40;
|
||||
width: 98px;
|
||||
height: calc(100vh - 4rem);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-nav{
|
||||
width:78px;
|
||||
height:70px;
|
||||
background:rgba(0, 12, 28, 0.15);
|
||||
border:1px solid;
|
||||
border-color:rgba(85, 166, 254, 0.2);
|
||||
line-height:8px;
|
||||
font-family:Noto Sans S Chinese;
|
||||
font-weight:500;
|
||||
color:rgba(255, 255, 255, 0.8);
|
||||
font-size:20px;
|
||||
padding-bottom:18px;
|
||||
text-align:center;
|
||||
.sidebar-contents {
|
||||
width: 98px;
|
||||
min-height: calc(100% - 20px);
|
||||
background: rgba(3, 38, 80, 0.8);
|
||||
border: 1px solid;
|
||||
border-color: rgba(43, 143, 254, 0.6);
|
||||
border-radius: 4px;
|
||||
backdrop-filter: blur(2px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 12px 10px;
|
||||
position: relative;
|
||||
height: calc(100% - 20px);
|
||||
box-sizing: border-box;
|
||||
transform: translate(10px, 10px);
|
||||
}
|
||||
|
||||
.item-nav-group {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.item-nav-wrap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.item-nav-group:first-child .item-nav {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.item-nav {
|
||||
width: 100%;
|
||||
height: 75px;
|
||||
margin-top: 13px;
|
||||
font-family: Noto Sans S Chinese;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
background: #000c1c26;
|
||||
border: 1px solid;
|
||||
border-color: #55a6fe33;
|
||||
box-shadow: 0 0 20px #00b9ff26 inset;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.item-nav:hover,
|
||||
.item-nav-active,
|
||||
.item-nav-hovered {
|
||||
color: #ffffff;
|
||||
background: linear-gradient(134.25deg,
|
||||
rgba(0, 98, 217, 0.59) 2.28%,
|
||||
rgba(0, 98, 217, 0.3) 99.59%) !important;
|
||||
background-size: cover;
|
||||
border: 1px solid;
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.item-nav:hover::before,
|
||||
.item-nav-active::before,
|
||||
.item-nav-hovered::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: -10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-left: 10px solid rgba(0, 98, 217, 0.45);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.item-nav:hover::after,
|
||||
.item-nav-active::after,
|
||||
.item-nav-hovered::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 29px;
|
||||
width: 77px;
|
||||
height: 45px;
|
||||
background: url('../assets/icon/nav-line-logo.svg') no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.item-nav__label {
|
||||
display: block;
|
||||
width: 3em;
|
||||
margin: 0 auto;
|
||||
padding-left: 6px;
|
||||
box-sizing: border-box;
|
||||
letter-spacing: 6px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.item-nav-content {
|
||||
width: 155px;
|
||||
height: calc(100vh - 4rem - 20px);
|
||||
min-height: calc(100vh - 4rem - 20px);
|
||||
background: rgba(3, 38, 80, 0.8);
|
||||
border: 1px solid;
|
||||
border-color: rgba(43, 143, 254, 0.6);
|
||||
border-radius: 4px;
|
||||
backdrop-filter: blur(2px);
|
||||
position: absolute;
|
||||
left: 108px;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
padding: 14px 13px 18px 16px;
|
||||
overflow-y: auto;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.2s ease, visibility 0.2s ease;
|
||||
}
|
||||
|
||||
.item-nav-content::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -30px;
|
||||
top: 0;
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.item-nav-hover-bridge {
|
||||
position: absolute;
|
||||
right: -30px;
|
||||
top: 0;
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.item-nav-content--visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.sidebar-flyout-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sidebar-flyout-list--level-1,
|
||||
.sidebar-flyout-list--level-2,
|
||||
.sidebar-flyout-list--level-3 {
|
||||
margin-left: 19px;
|
||||
padding-left: 14px;
|
||||
}
|
||||
|
||||
.sidebar-flyout-node {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sidebar-flyout-node--has-children.sidebar-flyout-node--expanded>.sidebar-flyout-list::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 1px;
|
||||
height: 100%;
|
||||
background: rgba(43, 143, 254, 0.22);
|
||||
}
|
||||
|
||||
.sidebar-flyout-item {
|
||||
width: 100%;
|
||||
min-height: 34px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 3px 0;
|
||||
font-family: Noto Sans S Chinese;
|
||||
font-size: 18px;
|
||||
line-height: 16px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s ease, text-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-flyout-item:hover,
|
||||
.sidebar-flyout-item--active {
|
||||
color: #48ddff;
|
||||
text-shadow: 0 0 8px rgba(72, 221, 255, 0.25);
|
||||
}
|
||||
|
||||
.sidebar-flyout-item--leaf {
|
||||
justify-content: center;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.sidebar-flyout-list--level-1>.sidebar-flyout-node>.sidebar-flyout-item--leaf,
|
||||
.sidebar-flyout-list--level-2>.sidebar-flyout-node>.sidebar-flyout-item--leaf,
|
||||
.sidebar-flyout-list--level-3>.sidebar-flyout-node>.sidebar-flyout-item--leaf {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.sidebar-flyout-arrow {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
flex: 0 0 9px;
|
||||
background: url('../assets/icon/down-logo.svg') center / contain no-repeat;
|
||||
transform: rotate(-90deg);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-flyout-node--expanded>.sidebar-flyout-item>.sidebar-flyout-arrow {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
.sidebar-flyout-label {
|
||||
flex: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn__icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: 0 0 16px;
|
||||
color: #80e9ff;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn__label {
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--inline {
|
||||
width: calc(100% - 6px);
|
||||
min-height: 58px;
|
||||
margin-top: auto;
|
||||
margin-bottom: 2px;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
border: 1px solid #55a6fe33;
|
||||
background: #000c1c26;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
box-shadow: inset 0 0 16px #00b9ff1f;
|
||||
transition: background-color 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--inline .sidebar-collapse-btn__label {
|
||||
font-size: 16px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--inline:hover {
|
||||
background: rgba(0, 98, 217, 0.3);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--floating {
|
||||
position: fixed;
|
||||
left: 10px;
|
||||
bottom: 10px;
|
||||
z-index: 60;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
min-height: 36px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid rgba(128, 233, 255, 0.35);
|
||||
background: rgba(3, 38, 80, 0.82);
|
||||
color: rgba(205, 245, 255, 0.95);
|
||||
backdrop-filter: blur(2px);
|
||||
transition: width 0.22s ease, opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--floating:hover {
|
||||
width: 104px;
|
||||
background: rgba(7, 52, 110, 0.9);
|
||||
border-color: rgba(128, 233, 255, 0.65);
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--floating .sidebar-collapse-btn__label {
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
transform: translateX(-4px);
|
||||
transition: max-width 0.22s ease, opacity 0.16s ease, transform 0.22s ease;
|
||||
}
|
||||
|
||||
.sidebar-collapse-btn--floating:hover .sidebar-collapse-btn__label {
|
||||
max-width: 64px;
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
@@ -1,280 +1,91 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import type { ElementType } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import {
|
||||
Bell,
|
||||
Bot,
|
||||
Brain,
|
||||
CalendarClock,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronsUpDown,
|
||||
CircleHelp,
|
||||
Database,
|
||||
FileBox,
|
||||
FileText,
|
||||
Folder,
|
||||
FolderOpen,
|
||||
Gauge,
|
||||
Grid3X3,
|
||||
HelpCircle,
|
||||
History,
|
||||
Layout,
|
||||
Library,
|
||||
List,
|
||||
ListChecks,
|
||||
ListTodo,
|
||||
MessageSquareCode,
|
||||
MessageSquarePlus,
|
||||
Network,
|
||||
NotebookPen,
|
||||
Plus,
|
||||
Settings,
|
||||
Sparkles,
|
||||
Target,
|
||||
User,
|
||||
Users,
|
||||
Wrench,
|
||||
} from "lucide-react";
|
||||
import { PanelLeftOpen, PanelLeftClose } from "lucide-react";
|
||||
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { NotificationDialog } from "@/components/workspace/notification-dialog";
|
||||
import { SettingsDialog } from "@/components/workspace/settings";
|
||||
import { useTheme } from "@/contexts/ThemeContext";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
import { useI18n } from "@/core/i18n/hooks";
|
||||
import { useUnreadCount } from "@/core/notifications";
|
||||
import {
|
||||
defaultExpandedIds,
|
||||
filterMenuItemsByRole,
|
||||
sidebarMenuItems,
|
||||
type MenuItem,
|
||||
} from "@/core/page-layout/sidebar-menu";
|
||||
import './page-sdebar.css'
|
||||
|
||||
type MenuItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: ElementType;
|
||||
path?: string;
|
||||
adminOnly?: boolean;
|
||||
children?: MenuItem[];
|
||||
};
|
||||
|
||||
type PageSidebarDarkProps = {
|
||||
/** 是否收起(true 时只渲染左下角浮动入口,sidebar 主体隐藏) */
|
||||
collapsed: boolean;
|
||||
onToggleCollapsed: () => void;
|
||||
};
|
||||
|
||||
type SettingsSection = "account" | "appearance" | "memory" | "tools" | "about";
|
||||
|
||||
const menuItems: MenuItem[] = [
|
||||
{
|
||||
id: "qa-center",
|
||||
label: "问答中心",
|
||||
icon: HelpCircle,
|
||||
children: [
|
||||
{ id: "general-qa", label: "通用问答", icon: CircleHelp, path: "/page/workspace/chats/new" },
|
||||
{ id: "qa-zzjc", label: "zzjc支持", icon: Bot },
|
||||
{ id: "qa-zzxd", label: "zzXD应用", icon: Layout },
|
||||
{ id: "qa-research", label: "课题研究", icon: FileText, path: "/page/canvas/ai-writing" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "light-app-center",
|
||||
label: "轻应用",
|
||||
icon: Grid3X3,
|
||||
children: [
|
||||
{
|
||||
id: "light-app-note-management",
|
||||
label: "笔记管理",
|
||||
icon: NotebookPen,
|
||||
children: [
|
||||
{
|
||||
id: "light-app-new-note",
|
||||
label: "新建笔记",
|
||||
icon: Plus,
|
||||
path: "/page/strategy/light-app/new-note",
|
||||
},
|
||||
{
|
||||
id: "light-app-note-list",
|
||||
label: "笔记列表",
|
||||
icon: List,
|
||||
path: "/page/strategy/light-app/notes",
|
||||
},
|
||||
{
|
||||
id: "light-app-note-qa",
|
||||
label: "笔记问答",
|
||||
icon: MessageSquareCode,
|
||||
path: "/page/strategy/light-app/note-qa",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ id: "light-app-square", label: "应用广场", icon: Layout },
|
||||
{ id: "light-app-records", label: "运行记录", icon: History },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "task-management",
|
||||
label: "任务管理",
|
||||
icon: Target,
|
||||
children: [
|
||||
{
|
||||
id: "xk-center-task",
|
||||
label: "XK中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "xk-task-jc", label: "任务JC", icon: ListTodo, path: "/page/strategy/task-management/xk-task-jc" },
|
||||
{ id: "xk-task-dispatch", label: "任务调度", icon: ListTodo, path: "/page/strategy/task-management/xk-task-dispatch" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "coh-center-task",
|
||||
label: "COH中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "coh-task-3qfx", label: "3QFX", icon: ListTodo },
|
||||
{ id: "coh-task-fx", label: "任务FX", icon: ListTodo },
|
||||
{ id: "coh-task-xdfx", label: "XDFX", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "pg-center-task",
|
||||
label: "PG中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "pg-task-pg", label: "任务PG", icon: ListTodo },
|
||||
{ id: "pg-task-xdpg", label: "XDPG", icon: ListTodo },
|
||||
{ id: "pg-task-info-pg", label: "信息PG", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ty-center-task",
|
||||
label: "TY中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "ty-task-xdty", label: "XDTY任务", icon: ListTodo },
|
||||
{ id: "ty-task-plan", label: "方案TY任务", icon: ListTodo },
|
||||
{ id: "ty-task-xxty", label: "XXTY任务", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "comprehensive-management",
|
||||
label: "综合管理",
|
||||
icon: Settings,
|
||||
children: [
|
||||
{ id: "mgmt-agents", label: "智能体管理", icon: Bot, path: "/page/strategy/agents" },
|
||||
{ id: "mgmt-skills", label: "技能管理", icon: Sparkles, path: "/page/strategy/skills" },
|
||||
{ id: "mgmt-memory", label: "记忆管理", icon: Brain, path: "/page/strategy/memory" },
|
||||
{
|
||||
id: "mgmt-tasks",
|
||||
label: "任务管理",
|
||||
icon: ListChecks,
|
||||
path: "/page/strategy/scheduled/tasks",
|
||||
},
|
||||
{
|
||||
id: "mgmt-recommended-questions",
|
||||
label: "推荐问题配置",
|
||||
icon: MessageSquarePlus,
|
||||
path: "/page/strategy/settings/recommended-questions",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-prompt-prefix",
|
||||
label: "问答前缀配置",
|
||||
icon: MessageSquareCode,
|
||||
path: "/page/strategy/settings/prompt-prefix",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-llm-metrics",
|
||||
label: "大模型调用统计",
|
||||
icon: Gauge,
|
||||
path: "/page/strategy/settings/llm-metrics",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-users",
|
||||
label: "用户管理",
|
||||
icon: Users,
|
||||
path: "/page/strategy/admin/users",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-admin-scheduled-tasks",
|
||||
label: "定时任务管理",
|
||||
icon: CalendarClock,
|
||||
path: "/page/strategy/admin/scheduled-tasks",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-user-activity",
|
||||
label: "用户活动审计",
|
||||
icon: History,
|
||||
path: "/page/strategy/admin/user-activity",
|
||||
adminOnly: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "resource-management",
|
||||
label: "资源管理",
|
||||
icon: Database,
|
||||
children: [
|
||||
{ id: "resource-network-xwt", label: "网络xwt资源管理", icon: Network },
|
||||
{ id: "resource-knowledge-base", label: "知识库资源管理", icon: Library },
|
||||
{ id: "resource-zz", label: "ZZ资源管理", icon: FileBox },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const defaultExpandedIds = new Set([
|
||||
"qa-center",
|
||||
"light-app-center",
|
||||
"light-app-note-management",
|
||||
"task-management",
|
||||
"xk-center-task",
|
||||
]);
|
||||
|
||||
function filterMenuItemsByRole(items: MenuItem[], isAdmin: boolean): MenuItem[] {
|
||||
return items
|
||||
.filter((item) => !item.adminOnly || isAdmin)
|
||||
.map((item) =>
|
||||
item.children
|
||||
? { ...item, children: filterMenuItemsByRole(item.children, isAdmin) }
|
||||
: item,
|
||||
);
|
||||
}
|
||||
|
||||
export function PageSidebarDark({
|
||||
collapsed,
|
||||
onToggleCollapsed,
|
||||
}: PageSidebarDarkProps) {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === "dark";
|
||||
export function PageSidebarDark({ collapsed, onToggleCollapsed }: PageSidebarDarkProps) {
|
||||
const isAdmin = getStoredAuth()?.system_role === "admin";
|
||||
const visibleMenuItems = filterMenuItemsByRole(menuItems, !!isAdmin);
|
||||
const { t } = useI18n();
|
||||
const { data: unreadCount = 0 } = useUnreadCount();
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(defaultExpandedIds);
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [settingsDefaultSection, setSettingsDefaultSection] =
|
||||
useState<SettingsSection>("appearance");
|
||||
const [notificationOpen, setNotificationOpen] = useState(false);
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const visibleMenuItems = useMemo(
|
||||
() => filterMenuItemsByRole(sidebarMenuItems, !!isAdmin),
|
||||
[isAdmin],
|
||||
);
|
||||
// defaultExpandedIds 是共享的 ReadonlySet,复制一份给 useState(避免外部突变)
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(() => new Set(defaultExpandedIds));
|
||||
const navigate = useNavigate();
|
||||
const { pathname } = useLocation();
|
||||
|
||||
// pathname 变化时取消任何未触发的 hover 关闭计时(cleanup 在卸载时也跑)
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
return () => {
|
||||
if (hoverCloseTimerRef.current !== null) {
|
||||
window.clearTimeout(hoverCloseTimerRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openSettings = (section: SettingsSection) => {
|
||||
setSettingsDefaultSection(section);
|
||||
setSettingsOpen(true);
|
||||
const handleNavHoverEnter = (id: string) => {
|
||||
if (hoverCloseTimerRef.current !== null) {
|
||||
window.clearTimeout(hoverCloseTimerRef.current);
|
||||
hoverCloseTimerRef.current = null;
|
||||
}
|
||||
setHoveredTopId(id);
|
||||
};
|
||||
|
||||
const scheduleNavPanelClose = () => {
|
||||
if (hoverCloseTimerRef.current !== null) {
|
||||
window.clearTimeout(hoverCloseTimerRef.current);
|
||||
}
|
||||
hoverCloseTimerRef.current = window.setTimeout(() => {
|
||||
setHoveredTopId(null);
|
||||
hoverCloseTimerRef.current = null;
|
||||
}, 180);
|
||||
};
|
||||
|
||||
const closeNavPanel = () => {
|
||||
if (hoverCloseTimerRef.current !== null) {
|
||||
window.clearTimeout(hoverCloseTimerRef.current);
|
||||
hoverCloseTimerRef.current = null;
|
||||
}
|
||||
setHoveredTopId(null);
|
||||
};
|
||||
|
||||
const hasActiveChild = (item: MenuItem): boolean => {
|
||||
if (item.path && pathname === item.path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return item.children?.some(hasActiveChild) ?? false;
|
||||
};
|
||||
|
||||
// lazy init:仅在首次 render 计算一次 active id;之后由下面的 useEffect 跟随 pathname 同步
|
||||
const [activeTopId, setActiveTopId] = useState<string>(
|
||||
() => visibleMenuItems.find(hasActiveChild)?.id ?? visibleMenuItems[0]?.id ?? "qa-center",
|
||||
);
|
||||
const [hoveredTopId, setHoveredTopId] = useState<string | null>(null);
|
||||
const hoverCloseTimerRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const matchedTopItem = visibleMenuItems.find(hasActiveChild);
|
||||
if (matchedTopItem) {
|
||||
setActiveTopId(matchedTopItem.id);
|
||||
}
|
||||
closeNavPanel();
|
||||
}, [pathname, visibleMenuItems]);
|
||||
|
||||
const toggleExpanded = (id: string) => {
|
||||
setExpandedIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
@@ -287,25 +98,140 @@ export function PageSidebarDark({
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsDialog
|
||||
open={settingsOpen}
|
||||
onOpenChange={setSettingsOpen}
|
||||
defaultSection={settingsDefaultSection}
|
||||
/>
|
||||
<NotificationDialog
|
||||
open={notificationOpen}
|
||||
onOpenChange={setNotificationOpen}
|
||||
/>
|
||||
{/* TODO: 在这里编写深色主题的侧边栏 HTML 结构 */}
|
||||
<div className="sidebar-contnet">
|
||||
<div className="sidebar-contents">
|
||||
<div className="item-nav">
|
||||
问答管理
|
||||
const findFirstRoutePath = (items?: MenuItem[]): string | null => {
|
||||
if (!items?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const child of items) {
|
||||
if (child.path) {
|
||||
return child.path;
|
||||
}
|
||||
const nestedPath = findFirstRoutePath(child.children);
|
||||
if (nestedPath) {
|
||||
return nestedPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleTopItemClick = (item: MenuItem) => {
|
||||
setActiveTopId(item.id);
|
||||
|
||||
if (item.children?.length) {
|
||||
const firstPath = findFirstRoutePath(item.children);
|
||||
if (firstPath) {
|
||||
closeNavPanel();
|
||||
navigate(firstPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.path) {
|
||||
closeNavPanel();
|
||||
navigate(item.path);
|
||||
}
|
||||
};
|
||||
|
||||
const handleMenuItemClick = (item: MenuItem) => {
|
||||
if (item.children?.length) {
|
||||
toggleExpanded(item.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.path) {
|
||||
closeNavPanel();
|
||||
navigate(item.path);
|
||||
}
|
||||
};
|
||||
|
||||
const renderFlyoutMenu = (items: MenuItem[], level = 0) => (
|
||||
<div className={`sidebar-flyout-list sidebar-flyout-list--level-${level}`}>
|
||||
{items.map((item) => {
|
||||
const hasChildren = !!item.children?.length;
|
||||
const isExpanded = expandedIds.has(item.id);
|
||||
const isSelected = item.path ? pathname === item.path : hasActiveChild(item);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
className={`sidebar-flyout-node sidebar-flyout-node--level-${level} ${hasChildren ? "sidebar-flyout-node--has-children" : ""} ${isExpanded ? "sidebar-flyout-node--expanded" : ""}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className={`sidebar-flyout-item ${isSelected ? "sidebar-flyout-item--active" : ""} ${hasChildren ? "sidebar-flyout-item--parent" : "sidebar-flyout-item--leaf"}`}
|
||||
onClick={() => handleMenuItemClick(item)}
|
||||
>
|
||||
{hasChildren ? <span className="sidebar-flyout-arrow" aria-hidden="true" /> : null}
|
||||
<span className="sidebar-flyout-label">{item.label}</span>
|
||||
</button>
|
||||
{hasChildren && isExpanded ? renderFlyoutMenu(item.children ?? [], level + 1) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
// collapsed 状态:sidebar 主体完全消失(包括占据的宽度),只渲染左下角浮动入口
|
||||
if (collapsed) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
title="展开侧边栏"
|
||||
aria-label="展开侧边栏"
|
||||
className="sidebar-collapse-btn sidebar-collapse-btn--floating"
|
||||
onClick={onToggleCollapsed}
|
||||
>
|
||||
<PanelLeftOpen className="sidebar-collapse-btn__icon" aria-hidden="true" />
|
||||
<span className="sidebar-collapse-btn__label">收起面板</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<aside className="sidebar-contnet">
|
||||
<div className="sidebar-contents">
|
||||
{visibleMenuItems.map((item) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className="item-nav-group"
|
||||
onMouseEnter={() => handleNavHoverEnter(item.id)}
|
||||
onMouseLeave={scheduleNavPanelClose}
|
||||
>
|
||||
{item.children?.length ? (
|
||||
<div
|
||||
className={`item-nav-content ${hoveredTopId === item.id ? "item-nav-content--visible" : ""}`}
|
||||
>
|
||||
{renderFlyoutMenu(item.children)}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="item-nav-wrap">
|
||||
<button
|
||||
type="button"
|
||||
className={`item-nav ${item.id === activeTopId ? "item-nav-active" : ""} ${hoveredTopId === item.id ? "item-nav-hovered" : ""}`}
|
||||
onClick={() => handleTopItemClick(item)}
|
||||
>
|
||||
<span className="item-nav__label">{item.label}</span>
|
||||
</button>
|
||||
{item.children?.length && hoveredTopId === item.id ? (
|
||||
<span className="item-nav-hover-bridge" aria-hidden="true" />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* 底部"收起面板"按钮:独立样式,mt-auto 推到底 */}
|
||||
<button
|
||||
type="button"
|
||||
title="收起侧边栏"
|
||||
aria-label="收起侧边栏"
|
||||
className="sidebar-collapse-btn sidebar-collapse-btn--inline"
|
||||
onClick={onToggleCollapsed}
|
||||
>
|
||||
<PanelLeftClose className="sidebar-collapse-btn__icon" aria-hidden="true" />
|
||||
<span className="sidebar-collapse-btn__label">收起面板</span>
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -1,40 +1,14 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import type { ElementType } from "react";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import {
|
||||
Bell,
|
||||
Bot,
|
||||
Brain,
|
||||
CalendarClock,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronsUpDown,
|
||||
CircleHelp,
|
||||
Database,
|
||||
FileBox,
|
||||
FileText,
|
||||
Folder,
|
||||
FolderOpen,
|
||||
Gauge,
|
||||
Grid3X3,
|
||||
HelpCircle,
|
||||
History,
|
||||
Layout,
|
||||
Library,
|
||||
List,
|
||||
ListChecks,
|
||||
ListTodo,
|
||||
MessageSquareCode,
|
||||
MessageSquarePlus,
|
||||
ShieldCheck,
|
||||
Network,
|
||||
NotebookPen,
|
||||
Plus,
|
||||
Settings,
|
||||
Sparkles,
|
||||
Target,
|
||||
User,
|
||||
Users,
|
||||
Wrench,
|
||||
} from "lucide-react";
|
||||
|
||||
@@ -50,14 +24,12 @@ import { useTheme } from "@/contexts/ThemeContext";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
import { useI18n } from "@/core/i18n/hooks";
|
||||
import { useUnreadCount } from "@/core/notifications";
|
||||
type MenuItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: ElementType;
|
||||
path?: string;
|
||||
adminOnly?: boolean;
|
||||
children?: MenuItem[];
|
||||
};
|
||||
import {
|
||||
defaultExpandedIds,
|
||||
filterMenuItemsByRole,
|
||||
sidebarMenuItems,
|
||||
type MenuItem,
|
||||
} from "@/core/page-layout/sidebar-menu";
|
||||
|
||||
type PageSidebarProps = {
|
||||
collapsed: boolean;
|
||||
@@ -66,201 +38,6 @@ type PageSidebarProps = {
|
||||
|
||||
type SettingsSection = "account" | "appearance" | "memory" | "tools" | "about";
|
||||
|
||||
const menuItems: MenuItem[] = [
|
||||
{
|
||||
id: "qa-center",
|
||||
label: "问答中心",
|
||||
icon: HelpCircle,
|
||||
children: [
|
||||
{ id: "general-qa", label: "通用问答", icon: CircleHelp, path: "/page/workspace/chats/new" },
|
||||
// 「圆桌规划」入口暂时隐藏 —— 功能仍在 /page/roundtable/planning,只是不在侧边栏出现。
|
||||
// 需要重新开放时取消注释即可。
|
||||
// {
|
||||
// id: "qa-roundtable",
|
||||
// label: "圆桌规划",
|
||||
// icon: Bot,
|
||||
// path: "/page/roundtable/planning",
|
||||
// },
|
||||
{ id: "qa-zzjc", label: "zzjc支持", icon: Bot },
|
||||
{ id: "qa-zzxd", label: "zzXD应用", icon: Layout },
|
||||
{ id: "qa-research", label: "课题研究", icon: FileText, path: "/page/canvas/ai-writing" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "light-app-center",
|
||||
label: "轻应用",
|
||||
icon: Grid3X3,
|
||||
children: [
|
||||
{
|
||||
id: "light-app-note-management",
|
||||
label: "笔记管理",
|
||||
icon: NotebookPen,
|
||||
children: [
|
||||
{
|
||||
id: "light-app-new-note",
|
||||
label: "新建笔记",
|
||||
icon: Plus,
|
||||
path: "/page/strategy/light-app/new-note",
|
||||
},
|
||||
{
|
||||
id: "light-app-note-list",
|
||||
label: "笔记列表",
|
||||
icon: List,
|
||||
path: "/page/strategy/light-app/notes",
|
||||
},
|
||||
{
|
||||
id: "light-app-note-qa",
|
||||
label: "笔记问答",
|
||||
icon: MessageSquareCode,
|
||||
path: "/page/strategy/light-app/note-qa",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ id: "light-app-square", label: "应用广场", icon: Layout },
|
||||
{ id: "light-app-records", label: "运行记录", icon: History },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "task-management",
|
||||
label: "任务管理",
|
||||
icon: Target,
|
||||
children: [
|
||||
{
|
||||
id: "xk-center-task",
|
||||
label: "XK中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "xk-task-jc", label: "任务JC", icon: ListTodo },
|
||||
{ id: "xk-task-dispatch", label: "任务调度", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "coh-center-task",
|
||||
label: "COH中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "coh-task-3qfx", label: "3QFX", icon: ListTodo },
|
||||
{ id: "coh-task-fx", label: "任务FX", icon: ListTodo },
|
||||
{ id: "coh-task-xdfx", label: "XDFX", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "pg-center-task",
|
||||
label: "PG中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "pg-task-pg", label: "任务PG", icon: ListTodo },
|
||||
{ id: "pg-task-xdpg", label: "XDPG", icon: ListTodo },
|
||||
{ id: "pg-task-info-pg", label: "信息PG", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ty-center-task",
|
||||
label: "TY中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{ id: "ty-task-xdty", label: "XDTY任务", icon: ListTodo },
|
||||
{ id: "ty-task-plan", label: "方案TY任务", icon: ListTodo },
|
||||
{ id: "ty-task-xxty", label: "XXTY任务", icon: ListTodo },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "comprehensive-management",
|
||||
label: "综合管理",
|
||||
icon: Settings,
|
||||
children: [
|
||||
{ id: "mgmt-agents", label: "智能体管理", icon: Bot, path: "/page/strategy/agents" },
|
||||
{ id: "mgmt-skills", label: "技能管理", icon: Sparkles, path: "/page/strategy/skills" },
|
||||
{ id: "mgmt-memory", label: "记忆管理", icon: Brain, path: "/page/strategy/memory" },
|
||||
{
|
||||
id: "mgmt-tasks",
|
||||
label: "定时任务",
|
||||
icon: ListChecks,
|
||||
path: "/page/strategy/scheduled/tasks",
|
||||
},
|
||||
{
|
||||
id: "mgmt-recommended-questions",
|
||||
label: "推荐问题配置",
|
||||
icon: MessageSquarePlus,
|
||||
path: "/page/strategy/settings/recommended-questions",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-prompt-prefix",
|
||||
label: "问答前缀配置",
|
||||
icon: MessageSquareCode,
|
||||
path: "/page/strategy/settings/prompt-prefix",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-private-square",
|
||||
label: "私密广场配置",
|
||||
icon: ShieldCheck,
|
||||
path: "/page/strategy/settings/private-square",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-llm-metrics",
|
||||
label: "大模型调用统计",
|
||||
icon: Gauge,
|
||||
path: "/page/strategy/settings/llm-metrics",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-users",
|
||||
label: "用户管理",
|
||||
icon: Users,
|
||||
path: "/page/strategy/admin/users",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-admin-scheduled-tasks",
|
||||
label: "定时任务管理",
|
||||
icon: CalendarClock,
|
||||
path: "/page/strategy/admin/scheduled-tasks",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-user-activity",
|
||||
label: "用户活动审计",
|
||||
icon: History,
|
||||
path: "/page/strategy/admin/user-activity",
|
||||
adminOnly: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "resource-management",
|
||||
label: "资源管理",
|
||||
icon: Database,
|
||||
children: [
|
||||
{ id: "resource-network-xwt", label: "网络xwt资源管理", icon: Network },
|
||||
{ id: "resource-knowledge-base", label: "知识库资源管理", icon: Library },
|
||||
{ id: "resource-zz", label: "ZZ资源管理", icon: FileBox },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const defaultExpandedIds = new Set([
|
||||
"qa-center",
|
||||
"light-app-center",
|
||||
"light-app-note-management",
|
||||
"task-management",
|
||||
"xk-center-task",
|
||||
]);
|
||||
|
||||
function filterMenuItemsByRole(items: MenuItem[], isAdmin: boolean): MenuItem[] {
|
||||
return items
|
||||
.filter((item) => !item.adminOnly || isAdmin)
|
||||
.map((item) =>
|
||||
item.children
|
||||
? { ...item, children: filterMenuItemsByRole(item.children, isAdmin) }
|
||||
: item,
|
||||
);
|
||||
}
|
||||
|
||||
export function PageSidebar({
|
||||
collapsed,
|
||||
onToggleCollapsed,
|
||||
@@ -268,10 +45,11 @@ export function PageSidebar({
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === "dark";
|
||||
const isAdmin = getStoredAuth()?.system_role === "admin";
|
||||
const visibleMenuItems = filterMenuItemsByRole(menuItems, !!isAdmin);
|
||||
const visibleMenuItems = filterMenuItemsByRole(sidebarMenuItems, !!isAdmin);
|
||||
const { t } = useI18n();
|
||||
const { data: unreadCount = 0 } = useUnreadCount();
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(defaultExpandedIds);
|
||||
// defaultExpandedIds 是共享的 ReadonlySet,复制一份给 useState(避免外部突变)
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(() => new Set(defaultExpandedIds));
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [settingsDefaultSection, setSettingsDefaultSection] =
|
||||
useState<SettingsSection>("appearance");
|
||||
|
||||
@@ -7,7 +7,7 @@ function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||
<div
|
||||
data-slot="card"
|
||||
className={cn(
|
||||
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
||||
"bg-card text-card-foreground flex flex-col gap-6 rounded-[4px] border py-6 shadow-sm dark:border-[#0049A5] dark:bg-[#02244C]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
@@ -42,7 +42,7 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-muted-foreground text-sm", className)}
|
||||
className={cn("text-muted-foreground text-sm dark:text-[#F2F3F5]", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
@@ -65,7 +65,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-6", className)}
|
||||
className={cn("px-6 ", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
data-slot="input-group"
|
||||
role="group"
|
||||
className={cn(
|
||||
"group/input-group border-input/50 dark:bg-background/80 relative flex w-full items-center rounded-md border bg-white/80 shadow-xs transition-[color,box-shadow] outline-none",
|
||||
"group/input-group relative flex w-full items-center rounded-md border border-input/50 bg-white/80 shadow-xs transition-[color,box-shadow] outline-none dark:border-[#1B477E] dark:bg-[#022248]",
|
||||
"h-9 min-w-0 has-[>textarea]:h-auto",
|
||||
|
||||
// Variants based on alignment.
|
||||
|
||||
@@ -8,9 +8,12 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
||||
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
"h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base outline-none transition-[color,box-shadow] md:text-sm",
|
||||
"border-input placeholder:text-muted-foreground",
|
||||
"dark:border-[#1B477E] dark:bg-[#022248] dark:text-[#AACEFF] dark:placeholder:text-[#566B7F] rounded-[4px] text-[16px]",
|
||||
"file:text-foreground selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] dark:focus-visible:border-[#3b82f6] dark:focus-visible:ring-[#3b82f6]/30",
|
||||
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -30,7 +30,8 @@ const tabsListVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-muted",
|
||||
default:
|
||||
"bg-muted dark:group-data-[orientation=horizontal]/tabs:h-8! dark:items-stretch dark:gap-0 dark:overflow-hidden dark:rounded-[2px] dark:border dark:border-[#55A6FE] dark:bg-[#022248] dark:p-0",
|
||||
line: "gap-1 bg-transparent",
|
||||
},
|
||||
},
|
||||
@@ -40,60 +41,65 @@ const tabsListVariants = cva(
|
||||
},
|
||||
);
|
||||
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> &
|
||||
VariantProps<typeof tabsListVariants>
|
||||
>(({ className, variant = "default", ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
data-slot="tabs-list"
|
||||
data-variant={variant}
|
||||
className={cn(tabsListVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> &
|
||||
VariantProps<typeof tabsListVariants>
|
||||
>(({ className, variant = "default", ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
data-slot="tabs-list"
|
||||
data-variant={variant}
|
||||
className={cn(tabsListVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
data-slot="tabs-trigger"
|
||||
className={cn(
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
|
||||
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground",
|
||||
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
data-slot="tabs-content"
|
||||
className={cn("flex-1 outline-none", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
data-slot="tabs-trigger"
|
||||
className={cn(
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"dark:text-muted-foreground dark:hover:text-foreground",
|
||||
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
|
||||
"data-[state=active]:bg-background data-[state=active]:text-foreground",
|
||||
"dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-input dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-input/30 dark:group-data-[variant=line]/tabs-list:data-[state=active]:text-foreground",
|
||||
"dark:group-data-[variant=default]/tabs-list:relative dark:group-data-[variant=default]/tabs-list:!h-full dark:group-data-[variant=default]/tabs-list:self-stretch dark:group-data-[variant=default]/tabs-list:flex-none dark:group-data-[variant=default]/tabs-list:rounded-none dark:group-data-[variant=default]/tabs-list:border-0 dark:group-data-[variant=default]/tabs-list:bg-transparent dark:group-data-[variant=default]/tabs-list:px-4 dark:group-data-[variant=default]/tabs-list:!py-0 dark:group-data-[variant=default]/tabs-list:!leading-none dark:group-data-[variant=default]/tabs-list:shadow-none dark:group-data-[variant=default]/tabs-list:focus-visible:ring-0 dark:group-data-[variant=default]/tabs-list:[&_svg]:text-[#CCD2DA]",
|
||||
"dark:group-data-[variant=default]/tabs-list:not(:first-child):border-l dark:group-data-[variant=default]/tabs-list:not(:first-child):border-[#1d3961] dark:group-data-[variant=default]/tabs-list:data-[state=active]:border-l-0",
|
||||
"dark:group-data-[variant=default]/tabs-list:data-[state=active]:rounded-none dark:group-data-[variant=default]/tabs-list:data-[state=active]:border-0 dark:group-data-[variant=default]/tabs-list:data-[state=active]:bg-[#0062D9] dark:group-data-[variant=default]/tabs-list:data-[state=active]:text-[#FFFFFF] dark:group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none dark:group-data-[variant=default]/tabs-list:data-[state=active]:[&_svg]:text-[#FFFFFF] dark:group-data-[variant=default]/tabs-list:hover:text-[#CCD2DA]",
|
||||
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
data-slot="tabs-content"
|
||||
className={cn("flex-1 outline-none", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
||||
@@ -7,7 +7,9 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"border-input placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"border-input placeholder:text-muted-foreground/60 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"dark:border-[#1B477E] dark:bg-[#022248] dark:text-[#AACEFF] ",
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -267,15 +267,18 @@ export function AgentCard({ agent }: AgentCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card className="group flex flex-col transition-shadow hover:shadow-md">
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
||||
<Card className="group flex min-w-0 flex-col transition-shadow hover:shadow-md">
|
||||
<CardHeader className="min-w-0 pb-3">
|
||||
<div className="flex min-w-0 items-start justify-between gap-2">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
|
||||
<div className="bg-primary/10 text-primary flex h-9 w-9 shrink-0 items-center justify-center rounded-lg">
|
||||
<BotIcon className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<CardTitle className="truncate text-base" title={desensitize(agent.name)}>
|
||||
<div className="min-w-0 flex-1 overflow-hidden">
|
||||
<CardTitle
|
||||
className="block w-full min-w-0 overflow-hidden text-base text-ellipsis whitespace-nowrap"
|
||||
title={desensitize(agent.name)}
|
||||
>
|
||||
{desensitize(agent.name)}
|
||||
</CardTitle>
|
||||
{agent.model && (
|
||||
|
||||
@@ -146,15 +146,21 @@ export function AgentGallery() {
|
||||
|
||||
const renderEmpty = (description: string, showNewButton = false) => (
|
||||
<div className="flex h-64 flex-col items-center justify-center gap-3 text-center">
|
||||
<div className="bg-muted flex h-14 w-14 items-center justify-center rounded-full">
|
||||
<BotIcon className="text-muted-foreground h-7 w-7" />
|
||||
<div className="bg-muted flex h-14 w-14 items-center justify-center rounded-full dark:bg-[#022248]">
|
||||
<BotIcon className="text-muted-foreground h-7 w-7 dark:text-[#AACEFF]" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">{t.agents.emptyTitle}</p>
|
||||
<p className="text-muted-foreground mt-1 text-sm">{description}</p>
|
||||
<p className="font-medium dark:text-[#AACEFF]">{t.agents.emptyTitle}</p>
|
||||
<p className="text-muted-foreground mt-1 text-sm dark:text-[#55A6FE]">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
{showNewButton && (
|
||||
<Button variant="outline" className="mt-2" onClick={handleNewAgent}>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-2 dark:border-[#2580FF] dark:bg-[#2580FF] dark:text-white dark:hover:border-[#2580FF] dark:hover:bg-[#2580FF]/90 dark:hover:text-white"
|
||||
onClick={handleNewAgent}
|
||||
>
|
||||
<PlusIcon className="mr-1.5 h-4 w-4" />
|
||||
{t.agents.newAgent}
|
||||
</Button>
|
||||
|
||||
@@ -68,7 +68,7 @@ export function TagSearchBar({
|
||||
return (
|
||||
<div className={cn("flex flex-col gap-2.5", className)}>
|
||||
<div className="relative">
|
||||
<SearchIcon className="text-muted-foreground absolute left-2.5 top-1/2 size-4 -translate-y-1/2" />
|
||||
<SearchIcon className="text-muted-foreground dark:text-[#60a5fa]/90 absolute left-2.5 top-1/2 size-4 -translate-y-1/2" />
|
||||
<Input
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
|
||||
@@ -9,11 +9,26 @@ export interface ChatMessage {
|
||||
agentName?: string;
|
||||
}
|
||||
|
||||
export interface toolsUser {
|
||||
email: string;
|
||||
id: string;
|
||||
is_active: boolean;
|
||||
is_superuser: boolean;
|
||||
is_verified: boolean;
|
||||
pages_limit: number;
|
||||
pages_used: string;
|
||||
yUserId: string;
|
||||
}
|
||||
|
||||
interface ChatContextType {
|
||||
messages: ChatMessage[];
|
||||
addMessage: (role: 'user' | 'assistant', content: string, type?: 'general' | 'agent' | 'compare', agentName?: string) => void;
|
||||
clearMessages: () => void;
|
||||
deleteMessage: (id: string) => void;
|
||||
startConfig: unknown;
|
||||
setStartConfig: (val: unknown) => void;
|
||||
toolsUser: toolsUser | null;
|
||||
setToolsUser: (val: toolsUser) => void;
|
||||
}
|
||||
|
||||
const ChatContext = createContext<ChatContextType | undefined>(undefined);
|
||||
@@ -28,6 +43,9 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
});
|
||||
|
||||
const [startConfig, setStartConfig] = useState<unknown>(null);
|
||||
const [toolsUser, setToolsUser] = useState<toolsUser | null>(null);
|
||||
|
||||
const saveToStorage = useCallback((newMessages: ChatMessage[]) => {
|
||||
try {
|
||||
localStorage.setItem('qa-chat-history', JSON.stringify(newMessages));
|
||||
@@ -66,7 +84,18 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
||||
}, [saveToStorage]);
|
||||
|
||||
return (
|
||||
<ChatContext.Provider value={{ messages, addMessage, clearMessages, deleteMessage }}>
|
||||
<ChatContext.Provider
|
||||
value={{
|
||||
messages,
|
||||
addMessage,
|
||||
clearMessages,
|
||||
deleteMessage,
|
||||
startConfig,
|
||||
setStartConfig,
|
||||
toolsUser,
|
||||
setToolsUser,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</ChatContext.Provider>
|
||||
);
|
||||
|
||||
@@ -48,16 +48,16 @@ const themes: Record<ThemeType, ThemeConfig> = {
|
||||
textSecondary: 'slate-400',
|
||||
primary: 'blue-500',
|
||||
primaryHover: 'blue-400',
|
||||
border: 'slate-700',
|
||||
accent: 'blue-600',
|
||||
border: 'blue-800',
|
||||
accent: 'cyan-400',
|
||||
success: 'emerald-500',
|
||||
warning: 'amber-500',
|
||||
error: 'rose-500',
|
||||
card: 'slate-800',
|
||||
cardHover: 'slate-700',
|
||||
input: 'slate-800',
|
||||
inputBorder: 'slate-600',
|
||||
overlay: 'slate-900/80',
|
||||
inputBorder: 'blue-800',
|
||||
overlay: 'slate-900/50',
|
||||
},
|
||||
},
|
||||
light: {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 外部系统跳转登录时透传的参数:
|
||||
* theme —— 主题色,"dark-blue" => 深色,其他 => 浅色(在 LoginPage 调 setTheme 直接生效)
|
||||
* ticket —— 第三方 ticket,持久化到 localStorage 供后续请求使用
|
||||
* userId —— 外部用户 id,同上
|
||||
* env —— 环境标识,同上
|
||||
*
|
||||
* 这里只暴露 ``ticket / userId / env`` 三个 storage key 和读写工具;
|
||||
* theme 不存(直接走 ThemeContext,避免双源)。
|
||||
*/
|
||||
|
||||
export const EXTERNAL_LOGIN_STORAGE_KEYS = {
|
||||
ticket: "login.ticket",
|
||||
userId: "login.userId",
|
||||
env: "login.env",
|
||||
} as const;
|
||||
|
||||
export type ExternalLoginParams = {
|
||||
ticket?: string;
|
||||
userId?: string;
|
||||
env?: string;
|
||||
};
|
||||
|
||||
/** 把外部跳转带来的三个参数写到 localStorage;隐私模式 / quota 异常时静默失败 */
|
||||
export function persistExternalLoginParams(params: ExternalLoginParams): void {
|
||||
try {
|
||||
if (params.ticket) {
|
||||
localStorage.setItem(EXTERNAL_LOGIN_STORAGE_KEYS.ticket, params.ticket);
|
||||
}
|
||||
if (params.userId) {
|
||||
localStorage.setItem(EXTERNAL_LOGIN_STORAGE_KEYS.userId, params.userId);
|
||||
}
|
||||
if (params.env) {
|
||||
localStorage.setItem(EXTERNAL_LOGIN_STORAGE_KEYS.env, params.env);
|
||||
}
|
||||
} catch {
|
||||
// localStorage 不可用时不阻断登录流程
|
||||
}
|
||||
}
|
||||
|
||||
/** 读取持久化的外部登录参数;不可用时返回空字符串 */
|
||||
export function readExternalLoginParams(): Required<ExternalLoginParams> {
|
||||
try {
|
||||
return {
|
||||
ticket: localStorage.getItem(EXTERNAL_LOGIN_STORAGE_KEYS.ticket) ?? "",
|
||||
userId: localStorage.getItem(EXTERNAL_LOGIN_STORAGE_KEYS.userId) ?? "",
|
||||
env: localStorage.getItem(EXTERNAL_LOGIN_STORAGE_KEYS.env) ?? "",
|
||||
};
|
||||
} catch {
|
||||
return { ticket: "", userId: "", env: "" };
|
||||
}
|
||||
}
|
||||
|
||||
/** 把 ``theme`` query 值映射成 ThemeContext 的 ``'dark' | 'light'`` */
|
||||
export function resolveThemeFromQuery(themeParam: string | null | undefined): "dark" | "light" {
|
||||
return themeParam === "dark-blue" ? "dark" : "light";
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { requestCrudService } from "@/service/request-axios-service";
|
||||
|
||||
const CONSUMER_URL = import.meta.env.VITE_AIPI_CONSUMER_URL || "";
|
||||
|
||||
export const TOOLS_TOKEN_STORAGE_KEY = "tools_token";
|
||||
export const EXTERNAL_USER_ID_STORAGE_KEY = "userId";
|
||||
export const EXTERNAL_USER_INFO_STORAGE_KEY = "userInfo";
|
||||
export const GENERAL_QA_ROUTE = "/page/strategy/qa/general";
|
||||
|
||||
type UserDetailResponse = {
|
||||
data?: {
|
||||
id?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* External login via yUserId + optional token (same flow as web-code Login.tsx):
|
||||
* persist tools_token, resolve user via consumer API, store userId/userInfo.
|
||||
*/
|
||||
export async function loginByYUserId(
|
||||
yUserId: string,
|
||||
token?: string | null,
|
||||
): Promise<void> {
|
||||
if (token) {
|
||||
localStorage.setItem(TOOLS_TOKEN_STORAGE_KEY, token);
|
||||
}
|
||||
|
||||
const res = (await requestCrudService.get(
|
||||
`${CONSUMER_URL}/cop/userDetailByYuserId`,
|
||||
{ yuserId: yUserId },
|
||||
)) as UserDetailResponse;
|
||||
|
||||
const result = res.data;
|
||||
if (!result?.id) {
|
||||
throw new Error("无法根据 yUserId 获取用户信息。");
|
||||
}
|
||||
|
||||
localStorage.setItem(EXTERNAL_USER_ID_STORAGE_KEY, result.id);
|
||||
localStorage.setItem(EXTERNAL_USER_INFO_STORAGE_KEY, JSON.stringify(result));
|
||||
}
|
||||
|
||||
export function persistToolsToken(token: string): void {
|
||||
localStorage.setItem(TOOLS_TOKEN_STORAGE_KEY, token);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export function getLangGraphBaseURL(isMock?: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 笔记本外部系统(Studio)API 基础地址,通过 VITE_NOTEBOOK_API_BASE_URL 配置。 */
|
||||
/** 笔记本外部系统后端 API 地址,通过 VITE_AIPI_BACKENP_URL 配置。 */
|
||||
export function getNotebookApiBaseURL(): string {
|
||||
if (env.NEXT_PUBLIC_NOTEBOOK_API_BASE_URL) {
|
||||
return env.NEXT_PUBLIC_NOTEBOOK_API_BASE_URL.replace(/\/+$/, "");
|
||||
|
||||
@@ -6,7 +6,14 @@ export function isSidebarEnabledFromSearch(search: string): boolean {
|
||||
const params = new URLSearchParams(
|
||||
search.startsWith("?") ? search : `?${search}`,
|
||||
);
|
||||
return params.get(PAGE_SIDEBAR_QUERY_PARAM) === "1";
|
||||
if (params.get(PAGE_SIDEBAR_QUERY_PARAM) === "1") {
|
||||
return true;
|
||||
}
|
||||
// External yUserId login enables the page sidebar (see LoginPage + yuser-login).
|
||||
if (params.get("yUserId")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function persistSidebarEnabled(enabled: boolean): void {
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
/**
|
||||
* 全局侧边栏菜单数据与权限过滤逻辑。
|
||||
*
|
||||
* 浅色 ``PageSidebar`` 和深色 ``PageSidebarDark`` 共用这份数据 —— 菜单结构与
|
||||
* adminOnly 权限策略对两种皮肤完全一致;UI 渲染(icon 显示/折叠样式/hover flyout)
|
||||
* 在各自组件里实现。
|
||||
*
|
||||
* 修改菜单只需改这一处,两个 sidebar 自动同步。
|
||||
*/
|
||||
import type { ElementType } from "react";
|
||||
import {
|
||||
Bot,
|
||||
Brain,
|
||||
CalendarClock,
|
||||
CircleHelp,
|
||||
Database,
|
||||
FileBox,
|
||||
FileText,
|
||||
Folder,
|
||||
Gauge,
|
||||
Grid3X3,
|
||||
HelpCircle,
|
||||
History,
|
||||
Layout,
|
||||
Library,
|
||||
List,
|
||||
ListChecks,
|
||||
ListTodo,
|
||||
MessageSquareCode,
|
||||
MessageSquarePlus,
|
||||
Network,
|
||||
NotebookPen,
|
||||
Plus,
|
||||
Settings,
|
||||
ShieldCheck,
|
||||
Sparkles,
|
||||
Target,
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
|
||||
export type MenuItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: ElementType;
|
||||
path?: string;
|
||||
adminOnly?: boolean;
|
||||
children?: MenuItem[];
|
||||
};
|
||||
|
||||
export const sidebarMenuItems: MenuItem[] = [
|
||||
{
|
||||
id: "qa-center",
|
||||
label: "问答中心",
|
||||
icon: HelpCircle,
|
||||
children: [
|
||||
{ id: "general-qa", label: "通用问答", icon: CircleHelp, path: "/page/workspace/chats/new" },
|
||||
{ id: "expert-qa", label: "专家问答", icon: Brain, path: "/page/strategy/qa/expert-qa" },
|
||||
// 「圆桌规划」入口暂时隐藏 —— 功能仍在 /page/roundtable/planning,只是不在侧边栏出现。
|
||||
// 需要重新开放时取消注释即可。
|
||||
// {
|
||||
// id: "qa-roundtable",
|
||||
// label: "圆桌规划",
|
||||
// icon: Bot,
|
||||
// path: "/page/roundtable/planning",
|
||||
// },
|
||||
{ id: "qa-zzjc", label: "zzjc支持", icon: Bot },
|
||||
{ id: "qa-zzxd", label: "zzXD应用", icon: Layout },
|
||||
{ id: "qa-research", label: "课题研究", icon: FileText, path: "/page/canvas/ai-writing" },
|
||||
],
|
||||
},
|
||||
// {
|
||||
// id: "light-app-center",
|
||||
// label: "轻应用",
|
||||
// icon: Grid3X3,
|
||||
// children: [
|
||||
// {
|
||||
// id: "light-app-note-management",
|
||||
// label: "笔记管理",
|
||||
// icon: NotebookPen,
|
||||
// children: [
|
||||
// {
|
||||
// id: "light-app-new-note",
|
||||
// label: "新建笔记",
|
||||
// icon: Plus,
|
||||
// path: "/page/strategy/light-app/new-note",
|
||||
// },
|
||||
// {
|
||||
// id: "light-app-note-list",
|
||||
// label: "笔记列表",
|
||||
// icon: List,
|
||||
// path: "/page/strategy/light-app/notes",
|
||||
// },
|
||||
// {
|
||||
// id: "light-app-note-qa",
|
||||
// label: "笔记问答",
|
||||
// icon: MessageSquareCode,
|
||||
// path: "/page/strategy/light-app/note-qa",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// { id: "light-app-square", label: "应用广场", icon: Layout },
|
||||
// { id: "light-app-records", label: "运行记录", icon: History },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
id: "task-management",
|
||||
label: "任务管理",
|
||||
icon: Target,
|
||||
children: [
|
||||
{
|
||||
id: "xk-center-task",
|
||||
label: "XK中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{
|
||||
id: "xk-task-jc",
|
||||
label: "任务JC",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/xk-task-jc",
|
||||
},
|
||||
{
|
||||
id: "xk-task-dispatch",
|
||||
label: "任务调度",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/xk-task-dispatch",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "coh-center-task",
|
||||
label: "COH中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{
|
||||
id: "coh-task-3qfx",
|
||||
label: "3QFX",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/plan-task-sentiment",
|
||||
},
|
||||
{
|
||||
id: "coh-task-fx",
|
||||
label: "任务FX",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/plan-task/plan-task-fx",
|
||||
},
|
||||
{
|
||||
id: "coh-task-xdfx",
|
||||
label: "XDFX",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/plan-task/plan-task-action",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "pg-center-task",
|
||||
label: "PG中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{
|
||||
id: "pg-task-pg",
|
||||
label: "任务PG",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/effect-task-pg",
|
||||
},
|
||||
{
|
||||
id: "pg-task-xdpg",
|
||||
label: "XDPG",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/effect-action-pg",
|
||||
},
|
||||
{
|
||||
id: "pg-task-info-pg",
|
||||
label: "信息PG",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/effect-info-pg",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ty-center-task",
|
||||
label: "TY中任务",
|
||||
icon: Folder,
|
||||
children: [
|
||||
{
|
||||
id: "ty-task-xdty",
|
||||
label: "XDTY任务",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/mnty-task-mechanism",
|
||||
},
|
||||
{
|
||||
id: "ty-task-plan",
|
||||
label: "方案TY任务",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/mnty-task-plan",
|
||||
},
|
||||
{
|
||||
id: "ty-task-xxty",
|
||||
label: "XXTY任务",
|
||||
icon: ListTodo,
|
||||
path: "/page/strategy/task-management/mnty-task-zsty",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "comprehensive-management",
|
||||
label: "综合管理",
|
||||
icon: Settings,
|
||||
children: [
|
||||
{ id: "mgmt-agents", label: "智能体管理", icon: Bot, path: "/page/strategy/agents" },
|
||||
{ id: "mgmt-skills", label: "技能管理", icon: Sparkles, path: "/page/strategy/skills" },
|
||||
{ id: "mgmt-memory", label: "记忆管理", icon: Brain, path: "/page/strategy/memory" },
|
||||
{
|
||||
id: "mgmt-tasks",
|
||||
label: "定时任务",
|
||||
icon: ListChecks,
|
||||
path: "/page/strategy/scheduled/tasks",
|
||||
},
|
||||
{
|
||||
id: "mgmt-recommended-questions",
|
||||
label: "推荐问题配置",
|
||||
icon: MessageSquarePlus,
|
||||
path: "/page/strategy/settings/recommended-questions",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-prompt-prefix",
|
||||
label: "问答前缀配置",
|
||||
icon: MessageSquareCode,
|
||||
path: "/page/strategy/settings/prompt-prefix",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-private-square",
|
||||
label: "私密广场配置",
|
||||
icon: ShieldCheck,
|
||||
path: "/page/strategy/settings/private-square",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-llm-metrics",
|
||||
label: "大模型调用统计",
|
||||
icon: Gauge,
|
||||
path: "/page/strategy/settings/llm-metrics",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-users",
|
||||
label: "用户管理",
|
||||
icon: Users,
|
||||
path: "/page/strategy/admin/users",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-admin-scheduled-tasks",
|
||||
label: "定时任务管理",
|
||||
icon: CalendarClock,
|
||||
path: "/page/strategy/admin/scheduled-tasks",
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
id: "mgmt-user-activity",
|
||||
label: "用户活动审计",
|
||||
icon: History,
|
||||
path: "/page/strategy/admin/user-activity",
|
||||
adminOnly: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "resource-management",
|
||||
label: "资源管理",
|
||||
icon: Database,
|
||||
children: [
|
||||
{
|
||||
id: "resource-network-xwt",
|
||||
label: "网络xwt资源管理",
|
||||
icon: Network,
|
||||
path: "/page/strategy/resource-management/resource-network-actor",
|
||||
},
|
||||
{
|
||||
id: "resource-knowledge-base",
|
||||
label: "知识库资源管理",
|
||||
icon: Library,
|
||||
path: "/page/strategy/resource-management/resource-knowledge-base",
|
||||
},
|
||||
{
|
||||
id: "resource-evaluation-index",
|
||||
label: "作战资源管理",
|
||||
icon: FileBox,
|
||||
path: "/page/strategy/resource-management/resource-evaluation-index",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
/** 默认展开的菜单 id 集合(浅色版可折叠交互的初始状态) */
|
||||
export const defaultExpandedIds: ReadonlySet<string> = new Set([
|
||||
"qa-center",
|
||||
"light-app-center",
|
||||
"light-app-note-management",
|
||||
"task-management",
|
||||
"xk-center-task",
|
||||
]);
|
||||
|
||||
/** 按 admin 角色过滤菜单:非 admin 不展示 ``adminOnly: true`` 的项及其子项 */
|
||||
export function filterMenuItemsByRole(items: MenuItem[], isAdmin: boolean): MenuItem[] {
|
||||
return items
|
||||
.filter((item) => !item.adminOnly || isAdmin)
|
||||
.map((item) =>
|
||||
item.children
|
||||
? { ...item, children: filterMenuItemsByRole(item.children, isAdmin) }
|
||||
: item,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/** Strategy 模块外部 iframe / 嵌入页链接(来自 Vite 环境变量) */
|
||||
|
||||
function trimTrailingSlash(url: string): string {
|
||||
return url.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
function readEnv(key: string): string {
|
||||
const value = import.meta.env[key];
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
/** B2 网络 xwt 资源管理 iframe 基础地址 */
|
||||
export function getB2ActorBaseUrl(): string {
|
||||
return trimTrailingSlash(readEnv("VITE_AIPI_B2ACTOR_URL"));
|
||||
}
|
||||
|
||||
/** B2 网络 xwt 资源管理 iframe 路径 */
|
||||
export function getNetworkActorIframePath(): string {
|
||||
return readEnv("VITE_AIPI_B2ACTOR_XWT_PATH") || "/fromB/toXWT?isFrame=1";
|
||||
}
|
||||
|
||||
/** 网络 xwt 资源管理完整 iframe URL */
|
||||
export function getNetworkActorIframeUrl(): string {
|
||||
const base = getB2ActorBaseUrl();
|
||||
const path = getNetworkActorIframePath();
|
||||
if (!base) return "";
|
||||
return `${base}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
/** 知识库 iframe 地址换取 API */
|
||||
export function getKnowledgeIframeApiUrl(): string {
|
||||
return readEnv("VITE_AIPI_KNOWLEDGE_IFRAME_API_URL");
|
||||
}
|
||||
|
||||
/** 知识库 iframe 皮肤参数 */
|
||||
export function getKnowledgeIframeSkin(): string {
|
||||
return readEnv("VITE_AIPI_KNOWLEDGE_IFRAME_SKIN") || "red";
|
||||
}
|
||||
@@ -7,7 +7,7 @@ function base(): string {
|
||||
|
||||
export async function fetchStudioToken(email: string): Promise<string> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const res = await fetch(
|
||||
`${apiBase}/api/getTokenByEmail?email=${encodeURIComponent(email)}`,
|
||||
@@ -22,7 +22,7 @@ export async function fetchStudioToken(email: string): Promise<string> {
|
||||
|
||||
export async function fetchStudioNotebooks(token: string): Promise<StudioNotebook[]> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const res = await fetch(`${apiBase}/api/v1/searchspaces`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
@@ -36,7 +36,7 @@ export async function createSearchSpace(
|
||||
token: string,
|
||||
): Promise<void> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const res = await fetch(`${apiBase}/api/v1/searchspaces`, {
|
||||
method: "POST",
|
||||
@@ -49,6 +49,43 @@ export async function createSearchSpace(
|
||||
if (!res.ok) throw new Error(`创建失败:${res.status}`);
|
||||
}
|
||||
|
||||
export async function uploadSourceText(
|
||||
notebookId: number,
|
||||
content: string,
|
||||
title: string,
|
||||
token: string,
|
||||
): Promise<void> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
const res = await fetch(`${apiBase}/api/v1/documents/textupload`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
||||
body: JSON.stringify({ search_space_id: notebookId, content, title: title || "粘贴的文字" }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`上传失败:${res.status}`);
|
||||
}
|
||||
|
||||
export async function deleteSearchSpace(id: number, token: string): Promise<void> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
const res = await fetch(`${apiBase}/api/v1/searchspaces/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!res.ok) throw new Error(`删除失败:${res.status}`);
|
||||
}
|
||||
|
||||
export async function renameSearchSpace(id: number, name: string, token: string): Promise<void> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
const res = await fetch(`${apiBase}/api/v1/searchspaces/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`重命名失败:${res.status}`);
|
||||
}
|
||||
|
||||
export interface ChunkRead {
|
||||
id: number;
|
||||
content: string;
|
||||
@@ -69,7 +106,7 @@ export async function fetchDocumentByChunk(
|
||||
token: string,
|
||||
): Promise<DocumentWithChunks> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const res = await fetch(`${apiBase}/api/v1/documents/by-chunk/${chunkId}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
@@ -84,7 +121,7 @@ export async function uploadSourceFiles(
|
||||
token: string,
|
||||
): Promise<void> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("search_space_id", String(notebookId));
|
||||
@@ -105,7 +142,7 @@ export async function fetchNotebookSources(
|
||||
token: string,
|
||||
): Promise<SourceItem[]> {
|
||||
const apiBase = base();
|
||||
if (!apiBase) throw new Error("VITE_NOTEBOOK_API_BASE_URL 未配置");
|
||||
if (!apiBase) throw new Error("VITE_AIPI_FRONTEND_URL 未配置");
|
||||
|
||||
const res = await fetch(
|
||||
`${apiBase}/api/v1/source/search-space/${notebookId}?limit=100`,
|
||||
|
||||
@@ -12,6 +12,7 @@ export function useStudioNotebooks(): {
|
||||
notebooks: StudioNotebook[];
|
||||
isLoading: boolean;
|
||||
isError: boolean;
|
||||
token: string | undefined;
|
||||
} {
|
||||
const email = getStoredAuth()?.email ?? "";
|
||||
|
||||
@@ -35,6 +36,7 @@ export function useStudioNotebooks(): {
|
||||
notebooks: (notebooksQuery.data ?? []).filter((nb) => nb.is_owner),
|
||||
isLoading: tokenQuery.isLoading || notebooksQuery.isLoading,
|
||||
isError: tokenQuery.isError || notebooksQuery.isError,
|
||||
token: tokenQuery.data,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ function readEnv(
|
||||
| "VITE_LANGGRAPH_BASE_URL"
|
||||
| "VITE_CANVAS_LANGGRAPH_BASE_URL"
|
||||
| "VITE_NOTE_API_BASE_URL"
|
||||
| "VITE_NOTEBOOK_API_BASE_URL"
|
||||
| "VITE_AIPI_BACKENP_URL"
|
||||
| "VITE_AIPI_FRONTEND_URL"
|
||||
| "VITE_STATIC_WEBSITE_ONLY"
|
||||
| "VITE_GITHUB_OAUTH_TOKEN"
|
||||
| "VITE_STUDIO_ENABLED",
|
||||
@@ -22,7 +23,7 @@ export const env = {
|
||||
// routed (e.g. a separate canvas-agent server). Falls back to the main URL.
|
||||
NEXT_PUBLIC_CANVAS_LANGGRAPH_BASE_URL: readEnv("VITE_CANVAS_LANGGRAPH_BASE_URL"),
|
||||
NEXT_PUBLIC_NOTE_API_BASE_URL: readEnv("VITE_NOTE_API_BASE_URL"),
|
||||
NEXT_PUBLIC_NOTEBOOK_API_BASE_URL: readEnv("VITE_NOTEBOOK_API_BASE_URL"),
|
||||
NEXT_PUBLIC_NOTEBOOK_API_BASE_URL: readEnv("VITE_AIPI_BACKENP_URL"),
|
||||
NEXT_PUBLIC_STATIC_WEBSITE_ONLY: readEnv("VITE_STATIC_WEBSITE_ONLY"),
|
||||
GITHUB_OAUTH_TOKEN: readEnv("VITE_GITHUB_OAUTH_TOKEN"),
|
||||
STUDIO_ENABLED: readEnv("VITE_STUDIO_ENABLED"),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import "./styles/globals.css";
|
||||
import "tdesign-react/es/style/index.css";
|
||||
import "katex/dist/katex.min.css";
|
||||
|
||||
import React from "react";
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { useModels } from '@/core/models/hooks';
|
||||
import { useStudioNotebooks, useNotebookSources } from '@/core/studio/hooks';
|
||||
|
||||
import type { AIWritingRequest } from '../../types/ai-writing';
|
||||
import { useArticleTypes } from '../../hooks/useArticleTypes';
|
||||
@@ -29,8 +30,16 @@ const INPUT_CLASS =
|
||||
|
||||
const DEFAULT_KEYWORD_COUNT = 1;
|
||||
const DEFAULT_AUDIENCE = '普通读者';
|
||||
type MaterialSource = 'knowledge_base' | 'skill' | 'notebook';
|
||||
const DEFAULT_MATERIAL_SOURCE: MaterialSource = 'knowledge_base';
|
||||
const MAX_INTENT_LENGTH = 500;
|
||||
|
||||
const MATERIAL_SOURCE_OPTIONS: Array<{ value: MaterialSource; label: string; desc: string }> = [
|
||||
{ value: 'knowledge_base', label: '知识库', desc: '默认 web/intranet 检索' },
|
||||
{ value: 'skill', label: '技能检索', desc: '用已启用的技能编排检索' },
|
||||
{ value: 'notebook', label: '我的笔记', desc: '从笔记本中检索素材' },
|
||||
];
|
||||
|
||||
const FIELD_LABEL_CLASS = 'text-[16px] font-semibold leading-none text-[#222]';
|
||||
const FIELD_TRIGGER_CLASS =
|
||||
'h-12 w-full rounded-xl border-[#e8dedd] bg-white text-sm shadow-sm';
|
||||
@@ -45,8 +54,15 @@ export function AIWritingForm({
|
||||
const [audience, setAudience] = useState('普通读者');
|
||||
const [wordCountInput, setWordCountInput] = useState('800');
|
||||
const [strictMode, setStrictMode] = useState(false);
|
||||
const [materialSource, setMaterialSource] = useState<MaterialSource>(DEFAULT_MATERIAL_SOURCE);
|
||||
const [modelName, setModelName] = useState('');
|
||||
// 笔记来源:选中的 search_space_id 和多个 document_id
|
||||
const [selectedNotebookId, setSelectedNotebookId] = useState<number | null>(null);
|
||||
const [selectedDocumentIds, setSelectedDocumentIds] = useState<number[]>([]);
|
||||
|
||||
const { models, isLoading: modelsLoading } = useModels();
|
||||
const { notebooks, isLoading: notebooksLoading } = useStudioNotebooks();
|
||||
const { sources, isLoading: sourcesLoading } = useNotebookSources(selectedNotebookId);
|
||||
|
||||
const { articleTypes, loading: typesLoading, refresh: refreshTypes } = useArticleTypes();
|
||||
|
||||
@@ -98,6 +114,25 @@ export function AIWritingForm({
|
||||
}
|
||||
}
|
||||
|
||||
function handleNotebookChange(val: string) {
|
||||
setSelectedNotebookId(val ? Number(val) : null);
|
||||
setSelectedDocumentIds([]);
|
||||
}
|
||||
|
||||
function handleMaterialSourceChange(val: MaterialSource) {
|
||||
setMaterialSource(val);
|
||||
if (val !== 'notebook') {
|
||||
setSelectedNotebookId(null);
|
||||
setSelectedDocumentIds([]);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDocument(docId: number) {
|
||||
setSelectedDocumentIds((prev) =>
|
||||
prev.includes(docId) ? prev.filter((id) => id !== docId) : [...prev, docId],
|
||||
);
|
||||
}
|
||||
|
||||
function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!intent.trim()) return;
|
||||
@@ -111,7 +146,11 @@ export function AIWritingForm({
|
||||
wordCountTarget: wordCount,
|
||||
keywordCount: DEFAULT_KEYWORD_COUNT,
|
||||
writingMode: hideAdvancedFields ? 'loose' : strictMode ? 'strict' : 'loose',
|
||||
materialSource,
|
||||
modelName: selectedModel?.name || modelName || undefined,
|
||||
// 只有选了"我的笔记"才传笔记参数
|
||||
noteSearchSpaceId: materialSource === 'notebook' ? (selectedNotebookId ?? undefined) : undefined,
|
||||
noteSourceIds: materialSource === 'notebook' && selectedNotebookId != null ? selectedDocumentIds : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,6 +217,80 @@ export function AIWritingForm({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 space-y-2">
|
||||
<label className={FIELD_LABEL_CLASS}>素材来源</label>
|
||||
<Select
|
||||
value={materialSource}
|
||||
onValueChange={(v) => handleMaterialSourceChange(v as MaterialSource)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SelectTrigger className={FIELD_TRIGGER_CLASS}>
|
||||
<SelectValue placeholder="选择素材来源" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{MATERIAL_SOURCE_OPTIONS.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value} className="text-sm">
|
||||
{opt.label}
|
||||
<span className="ml-1 text-xs text-muted-foreground">— {opt.desc}</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{/* 选了"我的笔记"才展示笔记本 / 文档选择器 */}
|
||||
{materialSource === 'notebook' && (
|
||||
<div className="mt-2 space-y-2">
|
||||
<Select
|
||||
value={selectedNotebookId !== null ? String(selectedNotebookId) : ''}
|
||||
onValueChange={handleNotebookChange}
|
||||
disabled={disabled || notebooksLoading}
|
||||
>
|
||||
<SelectTrigger className={FIELD_TRIGGER_CLASS}>
|
||||
<SelectValue placeholder={notebooksLoading ? '加载中…' : '选择笔记本'} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{notebooks.map((nb) => (
|
||||
<SelectItem key={nb.id} value={String(nb.id)} className="text-sm">
|
||||
{nb.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{selectedNotebookId !== null && (
|
||||
<div className="space-y-1">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{sourcesLoading
|
||||
? '文档加载中…'
|
||||
: `选择文档(可多选;不选则搜整个笔记本${selectedDocumentIds.length > 0 ? `,已选 ${selectedDocumentIds.length} 篇` : ''})`}
|
||||
</p>
|
||||
{!sourcesLoading && (
|
||||
<div className="max-h-36 overflow-y-auto rounded-lg border border-[#e8dedd] bg-white divide-y divide-[#f0e8e7]">
|
||||
{sources.filter((s) => s.document?.id != null).map((s) => {
|
||||
const docId = s.document!.id;
|
||||
return (
|
||||
<label key={s.id} className="flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-[#f9f5f5] select-none">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedDocumentIds.includes(docId)}
|
||||
onChange={() => toggleDocument(docId)}
|
||||
disabled={disabled}
|
||||
className="size-3.5 shrink-0 accent-primary"
|
||||
/>
|
||||
<span className="text-xs text-foreground truncate">
|
||||
{s.document?.title ?? `文档 ${docId}`}
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 space-y-2">
|
||||
<label className={FIELD_LABEL_CLASS}>写作模型</label>
|
||||
<Select
|
||||
|
||||
@@ -38,6 +38,8 @@ const ENABLE_PAUSE_RESUME_UI = false;
|
||||
import { AIWritingForm } from './AIWritingForm';
|
||||
import { AIWritingTimeline } from './AIWritingTimeline';
|
||||
import { InterventionCard } from './InterventionCard';
|
||||
import { SkillStepsCard } from './SkillStepsCard';
|
||||
import { SkillSelectStreamingView } from './SkillSelectStreamingView';
|
||||
import { WritingSkeletonCard } from './WritingSkeletonCard';
|
||||
import { DraftStreamingView } from './DraftStreamingView';
|
||||
import { IntentResultCard } from './IntentResultCard';
|
||||
@@ -411,6 +413,8 @@ export function AIWritingPanel({
|
||||
reviewResult={state.reviewResult}
|
||||
draftTitle={state.currentDraftTitle}
|
||||
revisionCount={state.revisionCount}
|
||||
skillSearchSteps={state.skillSearchSteps}
|
||||
skillSearchInProgress={state.status === 'researching' && state.skillSearchSteps.length > 0}
|
||||
onSubmit={submitIntervention}
|
||||
disabled={false}
|
||||
/>
|
||||
@@ -444,10 +448,36 @@ export function AIWritingPanel({
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 技能选择 LLM 流式打字(含 <think> 思考分离),select_skills 完成后自动清空。
|
||||
挂载条件包含"过渡态":已经走到 match_skills 但还没出 select_skills 时也保持挂载,
|
||||
让首个空 chunk 一到就能立刻显示等待提示 + 闪烁光标,避免模型 buffer 期间静默。 */}
|
||||
{state.status === 'researching' && (
|
||||
state.skillSelectStreamingText
|
||||
|| state.skillSelectThinkingText
|
||||
|| (state.skillSearchSteps.some((s) => s.type === 'match_skills')
|
||||
&& !state.skillSearchSteps.some((s) => s.type === 'select_skills'))
|
||||
) && (
|
||||
<SkillSelectStreamingView
|
||||
text={state.skillSelectStreamingText}
|
||||
thinkingText={state.skillSelectThinkingText}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 技能检索 pending:用户点击瞬间到 awaiting 之间,始终显示 SkillStepsCard 占位
|
||||
steps.length === 0 时 SkillStepsCard 内部会渲染骨架行,不让用户干等空白 */}
|
||||
{state.skillSearchPending && (
|
||||
<div className="px-4 pb-2">
|
||||
<SkillStepsCard steps={state.skillSearchSteps} inProgress />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showSkeleton &&
|
||||
state.status !== 'writing_draft' &&
|
||||
!(state.status === 'writing_outline' && (state.outlineStreamingText || state.outlineThinkingText)) &&
|
||||
!(state.status === 'reviewing' && state.streamingReviewItems.length > 0) &&
|
||||
/* 技能检索占位卡 / 选择打字机 已经在流式展示,不再叠加 skeleton */
|
||||
!state.skillSearchPending &&
|
||||
!(state.status === 'researching' && (state.skillSelectStreamingText || state.skillSelectThinkingText)) &&
|
||||
/* 意图解析流式过程中(LLM 还在吐 JSON)不要显示 skeleton */
|
||||
!state.intentStreamingText && !state.intentThinkingText && (
|
||||
<div className="px-4 pb-4">
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useRef, useState } from 'react';
|
||||
import {
|
||||
PauseCircle, CheckCircle2, RotateCcw, Search,
|
||||
RefreshCw, PenLine, ArrowRight, ShieldAlert, ClipboardEdit, SendHorizonal,
|
||||
Trash2, BookOpen,
|
||||
Trash2, BookOpen, Sparkles,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -10,11 +10,13 @@ import type {
|
||||
AIMaterial, AIOutline, ReviewResult, ReviewIssue,
|
||||
ProgressEvent, UserInterventionPayload,
|
||||
BlockedSection, SectionDecisionKind,
|
||||
SkillSearchStep,
|
||||
} from '../../types/ai-writing';
|
||||
import { MaterialsCard } from './MaterialsCard';
|
||||
import { MaterialsToolbar } from './MaterialsToolbar';
|
||||
import { OutlineCard } from './OutlineCard';
|
||||
import { ReviewCard } from './ReviewCard';
|
||||
import { SkillStepsCard } from './SkillStepsCard';
|
||||
|
||||
interface InterventionCardProps {
|
||||
pauseEvent: ProgressEvent;
|
||||
@@ -23,18 +25,29 @@ interface InterventionCardProps {
|
||||
reviewResult: ReviewResult | null;
|
||||
draftTitle: string;
|
||||
revisionCount: number;
|
||||
skillSearchSteps?: SkillSearchStep[];
|
||||
/** 是否正在检索中(researching/awaiting 切换之间,前端用于流式展示步骤进行中) */
|
||||
skillSearchInProgress?: boolean;
|
||||
onSubmit: (payload: UserInterventionPayload) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function InterventionCard({
|
||||
pauseEvent, materials, outline, reviewResult,
|
||||
draftTitle, revisionCount, onSubmit, disabled,
|
||||
draftTitle, revisionCount, skillSearchSteps, skillSearchInProgress, onSubmit, disabled,
|
||||
}: InterventionCardProps) {
|
||||
const pausePoint = pauseEvent.pausePoint;
|
||||
|
||||
if (pausePoint === 'material_confirm') {
|
||||
return <MaterialConfirmCard materials={materials} onSubmit={onSubmit} disabled={disabled} />;
|
||||
return (
|
||||
<MaterialConfirmCard
|
||||
materials={materials}
|
||||
skillSearchSteps={skillSearchSteps ?? []}
|
||||
skillSearchInProgress={skillSearchInProgress}
|
||||
onSubmit={onSubmit}
|
||||
disabled={disabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (pausePoint === 'outline_confirm') {
|
||||
@@ -106,30 +119,40 @@ function formatSelectedIssues(issues: ReviewIssue[], selectedIndices: Set<number
|
||||
|
||||
interface MaterialConfirmCardProps {
|
||||
materials: AIMaterial[];
|
||||
skillSearchSteps: SkillSearchStep[];
|
||||
skillSearchInProgress?: boolean;
|
||||
onSubmit: (payload: UserInterventionPayload) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
function MaterialConfirmCard({ materials, onSubmit, disabled }: MaterialConfirmCardProps) {
|
||||
function MaterialConfirmCard({ materials, skillSearchSteps, skillSearchInProgress, onSubmit, disabled }: MaterialConfirmCardProps) {
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(
|
||||
() => new Set(materials.map((m) => m.id)),
|
||||
);
|
||||
const [extraKeywords, setExtraKeywords] = useState<string[]>([]);
|
||||
const [userQuery, setUserQuery] = useState('');
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
async function handleConfirm() {
|
||||
setSubmitting(true);
|
||||
await onSubmit({ action: 'confirm', approvedMaterialIds: [...selectedIds], extraKeywords });
|
||||
await onSubmit({ action: 'confirm', approvedMaterialIds: [...selectedIds], userQuery: userQuery.trim() || undefined });
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
async function handleReSearch() {
|
||||
setSubmitting(true);
|
||||
await onSubmit({ action: 're_search', approvedMaterialIds: [], extraKeywords });
|
||||
await onSubmit({ action: 're_search', approvedMaterialIds: [], userQuery: userQuery.trim() || undefined });
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
const hasExtra = extraKeywords.length > 0;
|
||||
async function handleEnableSkillSearch() {
|
||||
setSubmitting(true);
|
||||
await onSubmit({ action: 'enable_skill_search', userQuery: userQuery.trim() || undefined });
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
const hasQuery = userQuery.trim().length > 0;
|
||||
// 当前素材是否来自技能检索:根据素材 sourceType 推断(覆盖式替换后全是 skill)
|
||||
const isSkillResult = materials.length > 0 && materials.every((m) => m.sourceType === 'skill');
|
||||
|
||||
// 空数据态:未检索到任何素材,提示用户重新搜索或在无素材情况下继续
|
||||
if (materials.length === 0) {
|
||||
@@ -140,33 +163,45 @@ function MaterialConfirmCard({ materials, onSubmit, disabled }: MaterialConfirmC
|
||||
<div>
|
||||
<p className="text-xs font-medium">未检索到任何素材</p>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
素材收集专家本次没有检索到相关数据。你可以补充关键词重新搜索,或在无素材的情况下直接继续写作(文章将仅依据写作意图生成)。
|
||||
素材收集专家本次没有检索到相关数据。你可以补充关键词重新搜索、启用技能检索,或在无素材的情况下直接继续写作。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{(skillSearchSteps.length > 0 || skillSearchInProgress) && (
|
||||
<SkillStepsCard steps={skillSearchSteps} inProgress={skillSearchInProgress} />
|
||||
)}
|
||||
|
||||
<MaterialsToolbar
|
||||
materials={materials}
|
||||
selectedIds={selectedIds}
|
||||
onSelectAll={() => setSelectedIds(new Set())}
|
||||
onDeselectAll={() => setSelectedIds(new Set())}
|
||||
extraKeywords={extraKeywords}
|
||||
onAddKeyword={(kw) => setExtraKeywords((prev) => [...prev, kw])}
|
||||
onRemoveKeyword={(kw) => setExtraKeywords((prev) => prev.filter((k) => k !== kw))}
|
||||
userQuery={userQuery}
|
||||
onUserQueryChange={setUserQuery}
|
||||
onSubmitQuery={handleReSearch}
|
||||
disabled={disabled || submitting}
|
||||
/>
|
||||
|
||||
<div className="flex gap-2 pt-1">
|
||||
<div className="flex flex-wrap gap-2 pt-1">
|
||||
<Button
|
||||
type="button" size="sm" className="flex-1 h-8 text-xs gap-1.5"
|
||||
type="button" size="sm" className="flex-1 min-w-[140px] h-8 text-xs gap-1.5"
|
||||
onClick={handleReSearch} disabled={disabled || submitting}
|
||||
>
|
||||
{hasExtra
|
||||
? <><Search className="size-3.5" />追加搜索</>
|
||||
{hasQuery
|
||||
? <><Search className="size-3.5" />按输入重新搜索</>
|
||||
: <><RotateCcw className="size-3.5" />重新搜索</>}
|
||||
</Button>
|
||||
<Button
|
||||
type="button" variant="outline" size="sm"
|
||||
className="h-8 text-xs gap-1.5 shrink-0 border-violet-200 text-violet-700 hover:bg-violet-50 dark:border-violet-800 dark:text-violet-300 dark:hover:bg-violet-950/30"
|
||||
onClick={handleEnableSkillSearch} disabled={disabled || submitting}
|
||||
>
|
||||
<Sparkles className="size-3.5" />技能检索
|
||||
</Button>
|
||||
<Button
|
||||
type="button" variant="outline" size="sm" className="h-8 text-xs gap-1.5 shrink-0"
|
||||
onClick={handleConfirm} disabled={disabled || submitting}
|
||||
onClick={() => onSubmit({ action: 'confirm', approvedMaterialIds: [] })} disabled={disabled || submitting}
|
||||
>
|
||||
<ArrowRight className="size-3.5" />无数据继续写作
|
||||
</Button>
|
||||
@@ -182,11 +217,14 @@ function MaterialConfirmCard({ materials, onSubmit, disabled }: MaterialConfirmC
|
||||
<div>
|
||||
<p className="text-xs font-medium">需要您确认素材,才能继续</p>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
已搜集到 {materials.length} 条素材(默认全选)。您可以取消勾选不相关的素材,或补充关键词追加搜索。
|
||||
已搜集到 {materials.length} 条{isSkillResult ? '技能素材' : '素材'}(默认全选)。
|
||||
您可以取消勾选不相关的素材,或补充关键词追加搜索{isSkillResult ? '' : ',也可以启用技能检索从已启用的技能中获取素材'}。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{skillSearchSteps.length > 0 && <SkillStepsCard steps={skillSearchSteps} />}
|
||||
|
||||
<MaterialsCard materials={materials} selectedIds={selectedIds} onToggle={(id) => {
|
||||
setSelectedIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
@@ -200,24 +238,34 @@ function MaterialConfirmCard({ materials, onSubmit, disabled }: MaterialConfirmC
|
||||
selectedIds={selectedIds}
|
||||
onSelectAll={() => setSelectedIds(new Set(materials.map((m) => m.id)))}
|
||||
onDeselectAll={() => setSelectedIds(new Set())}
|
||||
extraKeywords={extraKeywords}
|
||||
onAddKeyword={(kw) => setExtraKeywords((prev) => [...prev, kw])}
|
||||
onRemoveKeyword={(kw) => setExtraKeywords((prev) => prev.filter((k) => k !== kw))}
|
||||
userQuery={userQuery}
|
||||
onUserQueryChange={setUserQuery}
|
||||
onSubmitQuery={handleReSearch}
|
||||
disabled={disabled || submitting}
|
||||
/>
|
||||
|
||||
<div className="flex gap-2 pt-1">
|
||||
<div className="flex flex-wrap gap-2 pt-1">
|
||||
<Button
|
||||
type="button" size="sm" className="flex-1 h-8 text-xs gap-1.5"
|
||||
type="button" size="sm" className="flex-1 min-w-[180px] h-8 text-xs gap-1.5"
|
||||
onClick={handleConfirm} disabled={disabled || submitting || selectedIds.size === 0}
|
||||
>
|
||||
<CheckCircle2 className="size-3.5" />确认素材,开始规划大纲
|
||||
</Button>
|
||||
{!isSkillResult && (
|
||||
<Button
|
||||
type="button" variant="outline" size="sm"
|
||||
className="h-8 text-xs gap-1.5 shrink-0 border-violet-200 text-violet-700 hover:bg-violet-50 dark:border-violet-800 dark:text-violet-300 dark:hover:bg-violet-950/30"
|
||||
onClick={handleEnableSkillSearch} disabled={disabled || submitting}
|
||||
>
|
||||
<Sparkles className="size-3.5" />技能检索
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type="button" variant="outline" size="sm" className="h-8 text-xs gap-1.5 shrink-0"
|
||||
onClick={handleReSearch} disabled={disabled || submitting}
|
||||
>
|
||||
{hasExtra
|
||||
? <><Search className="size-3.5" />追加搜索</>
|
||||
{hasQuery
|
||||
? <><Search className="size-3.5" />按输入重新搜索</>
|
||||
: <><RotateCcw className="size-3.5" />重新搜索</>}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { ChevronRight, ExternalLink } from 'lucide-react';
|
||||
import { ChevronRight, ExternalLink, Sparkles } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { buildIntranetSourceUrl } from '@/core/config';
|
||||
import type { AIMaterial } from '../../types/ai-writing';
|
||||
@@ -26,12 +26,14 @@ function relevanceLabel(score: number): string {
|
||||
export function MaterialItem({ material, checked, onToggle }: MaterialItemProps) {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const pct = Math.round(material.relevanceScore * 100);
|
||||
const isSkill = material.sourceType === 'skill';
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'rounded-md border text-xs transition-colors',
|
||||
checked ? 'border-border bg-background' : 'border-border/50 bg-muted/30',
|
||||
isSkill && checked && 'border-violet-300/70 dark:border-violet-800/60',
|
||||
)}
|
||||
>
|
||||
{/* 头部行 */}
|
||||
@@ -50,6 +52,12 @@ export function MaterialItem({ material, checked, onToggle }: MaterialItemProps)
|
||||
onClick={() => setExpanded((v) => !v)}
|
||||
className="flex flex-1 items-start gap-1.5 text-left"
|
||||
>
|
||||
{isSkill && (
|
||||
<span className="mt-0.5 inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] font-medium bg-violet-100 text-violet-700 dark:bg-violet-900/60 dark:text-violet-200 shrink-0">
|
||||
<Sparkles className="size-2.5" />
|
||||
技能
|
||||
</span>
|
||||
)}
|
||||
<span className={cn('flex-1 font-medium leading-snug line-clamp-2', !checked && 'text-muted-foreground')}>
|
||||
{material.title}
|
||||
</span>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useRef } from 'react';
|
||||
import type { AIMaterial } from '../../types/ai-writing';
|
||||
|
||||
interface MaterialsToolbarProps {
|
||||
@@ -8,9 +6,13 @@ interface MaterialsToolbarProps {
|
||||
selectedIds: Set<string>;
|
||||
onSelectAll: () => void;
|
||||
onDeselectAll: () => void;
|
||||
extraKeywords: string[];
|
||||
onAddKeyword: (kw: string) => void;
|
||||
onRemoveKeyword: (kw: string) => void;
|
||||
/** 单输入框文本:可以是技能名、检索来源、补充检索意图 */
|
||||
userQuery: string;
|
||||
onUserQueryChange: (text: string) => void;
|
||||
/** 回车键提交(默认重新搜索;详细按钮交给父组件渲染) */
|
||||
onSubmitQuery?: () => void;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function MaterialsToolbar({
|
||||
@@ -18,18 +20,27 @@ export function MaterialsToolbar({
|
||||
selectedIds,
|
||||
onSelectAll,
|
||||
onDeselectAll,
|
||||
extraKeywords,
|
||||
onAddKeyword,
|
||||
onRemoveKeyword,
|
||||
userQuery,
|
||||
onUserQueryChange,
|
||||
onSubmitQuery,
|
||||
placeholder,
|
||||
disabled,
|
||||
}: MaterialsToolbarProps) {
|
||||
const [kwInput, setKwInput] = useState('');
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const allSelected = materials.length > 0 && selectedIds.size === materials.length;
|
||||
|
||||
function handleAddKeyword() {
|
||||
const kw = kwInput.trim();
|
||||
if (!kw || extraKeywords.includes(kw)) return;
|
||||
onAddKeyword(kw);
|
||||
setKwInput('');
|
||||
function handleInput(e: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
onUserQueryChange(e.target.value);
|
||||
const el = e.target;
|
||||
el.style.height = 'auto';
|
||||
el.style.height = `${Math.min(el.scrollHeight, 96)}px`;
|
||||
}
|
||||
|
||||
function handleKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {
|
||||
if (e.key === 'Enter' && !e.shiftKey && onSubmitQuery) {
|
||||
e.preventDefault();
|
||||
onSubmitQuery();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -51,50 +62,21 @@ export function MaterialsToolbar({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 补充关键词 */}
|
||||
{/* 单输入框 */}
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs text-muted-foreground">补充搜索关键词(可选)</label>
|
||||
<div className="flex gap-1.5">
|
||||
<input
|
||||
type="text"
|
||||
value={kwInput}
|
||||
onChange={(e) => setKwInput(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleAddKeyword()}
|
||||
placeholder="输入关键词后按 Enter 或点击 +"
|
||||
className="flex-1 h-7 rounded-md border border-input bg-background px-2.5 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-7 px-2"
|
||||
onClick={handleAddKeyword}
|
||||
disabled={!kwInput.trim()}
|
||||
>
|
||||
<Plus className="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 已添加关键词 Tag 列表 */}
|
||||
{extraKeywords.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{extraKeywords.map((kw) => (
|
||||
<span
|
||||
key={kw}
|
||||
className="inline-flex items-center gap-1 rounded-full bg-primary/10 text-primary px-2 py-0.5 text-xs"
|
||||
>
|
||||
{kw}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onRemoveKeyword(kw)}
|
||||
className="hover:text-destructive leading-none"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<label className="text-xs text-muted-foreground">
|
||||
补充检索(可选)— 写下你想检索的内容,然后点"重新搜索"或"技能检索"
|
||||
</label>
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
rows={1}
|
||||
value={userQuery}
|
||||
onChange={handleInput}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder={placeholder ?? '输入文字后点击“重新搜索”或“技能检索”按钮…'}
|
||||
disabled={disabled}
|
||||
className="w-full resize-none rounded-md border border-input bg-background px-2.5 py-1.5 text-xs leading-5 placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50 min-h-[28px] max-h-24"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Sparkles, ChevronDown, ChevronRight, Brain, Zap } from 'lucide-react';
|
||||
|
||||
interface SkillSelectStreamingViewProps {
|
||||
text: string;
|
||||
thinkingText?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流式 JSON 文本里增量提取已识别的技能名(仅取**已闭合**的字符串项)。
|
||||
*
|
||||
* LLM 输出形如 `{"selected_skills": ["skill-a", "skill-b", "skill-c"], "reason": "..."}`。
|
||||
* 不等整段 JSON 解析完,逐字符扫描:
|
||||
* - 定位 `"selected_skills":\s*[`
|
||||
* - 在该位置后到 `]`(或文本末尾)之间逐个匹配 `"..."`
|
||||
* - 只取已闭合的字符串(结尾必须是 `"`),保证不显示正在打字的半截名字
|
||||
*/
|
||||
function extractStreamingSkillNames(text: string): string[] {
|
||||
if (!text) return [];
|
||||
const keyMatch = text.match(/["']?selected_skills["']?\s*:\s*\[/);
|
||||
if (!keyMatch) return [];
|
||||
const start = keyMatch.index! + keyMatch[0].length;
|
||||
const rest = text.slice(start);
|
||||
const endIdx = rest.indexOf(']');
|
||||
const arrBody = endIdx >= 0 ? rest.slice(0, endIdx) : rest;
|
||||
const names: string[] = [];
|
||||
const re = /"((?:[^"\\]|\\.)*)"/g;
|
||||
let m: RegExpExecArray | null;
|
||||
while ((m = re.exec(arrBody)) !== null) {
|
||||
const name = m[1].trim();
|
||||
if (name) names.push(name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流式 JSON 文本里提取 `reason` 字段当前已输出的内容。
|
||||
*
|
||||
* 和 skill name 不同,reason 是流式叙述文本,**未闭合也要展示**(带闪烁光标),
|
||||
* 让用户看到 LLM 正在解释选择理由。
|
||||
*/
|
||||
function extractStreamingReason(text: string): { value: string; closed: boolean } {
|
||||
if (!text) return { value: '', closed: false };
|
||||
// 匹配 "reason": "..." 直到下一个未转义的 " 或文本末尾
|
||||
const m = text.match(/["']?reason["']?\s*:\s*"((?:[^"\\]|\\.)*?)("|$)/);
|
||||
if (!m) return { value: '', closed: false };
|
||||
const raw = m[1];
|
||||
const closed = m[2] === '"';
|
||||
// 反转义常见序列
|
||||
const value = raw
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\t/g, '\t')
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/\\\\/g, '\\');
|
||||
return { value, closed };
|
||||
}
|
||||
|
||||
export function SkillSelectStreamingView({ text, thinkingText }: SkillSelectStreamingViewProps) {
|
||||
const thinkRef = useRef<HTMLPreElement>(null);
|
||||
const [thinkOpen, setThinkOpen] = useState(true);
|
||||
|
||||
// 增量解析:候选技能 + 选择原因
|
||||
const streamingSkills = useMemo(() => extractStreamingSkillNames(text), [text]);
|
||||
const reason = useMemo(() => extractStreamingReason(text), [text]);
|
||||
|
||||
useEffect(() => {
|
||||
if (thinkOpen && thinkRef.current) thinkRef.current.scrollTop = thinkRef.current.scrollHeight;
|
||||
}, [thinkingText, thinkOpen]);
|
||||
|
||||
// 步骤预览始终渲染(挂载即显示),让父组件控制挂载时机;
|
||||
// 这样首个空 chunk 到达时用户就能看到"等待模型输出"占位 + 跳动光标
|
||||
const showStepPreview = true;
|
||||
|
||||
return (
|
||||
<div className="px-4 pb-2 space-y-2">
|
||||
{/* 思考过程(amber,可折叠) */}
|
||||
{thinkingText && (
|
||||
<div className="rounded-xl border border-amber-200 dark:border-amber-900 bg-amber-50/50 dark:bg-amber-950/20 overflow-hidden shadow-sm">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setThinkOpen((v) => !v)}
|
||||
className="w-full flex items-center gap-2 px-3 py-2 border-b border-amber-200/60 dark:border-amber-900/60 bg-amber-100/40 dark:bg-amber-900/30 hover:bg-amber-100/70 dark:hover:bg-amber-900/50 transition-colors"
|
||||
>
|
||||
<Brain className="size-3.5 text-amber-500 shrink-0" />
|
||||
<span className="text-xs font-medium text-amber-600 dark:text-amber-400">
|
||||
思考过程
|
||||
</span>
|
||||
<span className="ml-auto text-amber-400">
|
||||
{thinkOpen
|
||||
? <ChevronDown className="size-3.5" />
|
||||
: <ChevronRight className="size-3.5" />}
|
||||
</span>
|
||||
</button>
|
||||
{thinkOpen && (
|
||||
<pre
|
||||
ref={thinkRef}
|
||||
className="text-[11px] font-mono leading-relaxed p-3 text-amber-700/70 dark:text-amber-300/60 whitespace-pre-wrap max-h-40 overflow-y-auto italic"
|
||||
>
|
||||
{thinkingText}
|
||||
{!text && (
|
||||
<span className="inline-block w-0.5 h-3.5 bg-amber-400 ml-0.5 align-text-bottom animate-[blink_1s_step-end_infinite]" />
|
||||
)}
|
||||
</pre>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 步骤预览(violet,与 SkillStepsCard 的"筛选相关技能"步骤同构) */}
|
||||
{showStepPreview && (
|
||||
<div className="rounded-xl border border-violet-200 dark:border-violet-900 bg-violet-50/50 dark:bg-violet-950/20 overflow-hidden shadow-sm">
|
||||
<div className="flex items-center gap-2 px-3 py-2 border-b border-violet-200/60 dark:border-violet-900/60 bg-violet-100/40 dark:bg-violet-900/30">
|
||||
<Sparkles className="size-3.5 text-violet-500 shrink-0" />
|
||||
<span className="text-xs font-medium text-violet-600 dark:text-violet-400">
|
||||
筛选相关技能
|
||||
{streamingSkills.length > 0 && (
|
||||
<span className="ml-1 text-violet-500/80 font-normal">
|
||||
· 候选 {streamingSkills.length} 个(将按顺序使用)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="ml-auto inline-flex gap-1">
|
||||
{[0, 1, 2].map((i) => (
|
||||
<span
|
||||
key={i}
|
||||
className="size-1 rounded-full bg-violet-400 animate-bounce"
|
||||
style={{ animationDelay: `${i * 150}ms` }}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="px-3 py-2.5 space-y-2">
|
||||
{/* 已识别的候选技能 badges */}
|
||||
{streamingSkills.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{streamingSkills.map((name, idx) => (
|
||||
<span
|
||||
key={`${name}-${idx}`}
|
||||
className="inline-flex items-center gap-1 px-2 py-0.5 rounded text-[11px] font-mono bg-violet-100 dark:bg-violet-900/60 text-violet-700 dark:text-violet-200 animate-[skill-fade-in_0.25s_ease-out]"
|
||||
style={{ animationFillMode: 'both' }}
|
||||
>
|
||||
<Zap className="size-2.5 shrink-0" />
|
||||
{name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* reason 实时文本:未闭合也展示(带光标),闭合后光标消失 */}
|
||||
{reason.value && (
|
||||
<div className="text-[11px] text-violet-700/85 dark:text-violet-300/85 italic leading-relaxed whitespace-pre-wrap">
|
||||
<span className="not-italic font-medium text-violet-600 dark:text-violet-400 mr-1">原因:</span>
|
||||
{reason.value}
|
||||
{!reason.closed && (
|
||||
<span className="inline-block w-0.5 h-3 bg-violet-400 ml-0.5 align-text-bottom animate-[blink_1s_step-end_infinite]" />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 还没出现任何 skill / reason 时给一个占位提示 */}
|
||||
{!streamingSkills.length && !reason.value && (
|
||||
<div className="text-[11px] text-muted-foreground italic flex items-center gap-1">
|
||||
等待模型输出
|
||||
<span className="inline-block w-0.5 h-3 bg-violet-400 align-text-bottom animate-[blink_1s_step-end_infinite]" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<style>{`
|
||||
@keyframes blink {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0; }
|
||||
}
|
||||
@keyframes skill-fade-in {
|
||||
from { opacity: 0; transform: translateY(-2px) scale(0.95); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
import { useState } from 'react';
|
||||
import { ChevronRight, Sparkles, ListChecks, Zap, Loader2, CheckCircle2, CircleStop, Search } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { SkillSearchStep } from '../../types/ai-writing';
|
||||
import { CollapseTransition } from './CollapseTransition';
|
||||
|
||||
interface SkillStepsCardProps {
|
||||
steps: SkillSearchStep[];
|
||||
/** 是否仍在进行中(researching 状态下显示 spinner,让用户看到流式进展) */
|
||||
inProgress?: boolean;
|
||||
}
|
||||
|
||||
const STEP_ICON: Record<SkillSearchStep['type'], typeof Sparkles> = {
|
||||
list_skills: ListChecks,
|
||||
match_skills: Search,
|
||||
select_skills: Sparkles,
|
||||
invoke_skill: Zap,
|
||||
skill_result: CheckCircle2,
|
||||
stop_early: CircleStop,
|
||||
};
|
||||
|
||||
const STEP_LABEL: Record<SkillSearchStep['type'], string> = {
|
||||
list_skills: '列出可用技能',
|
||||
match_skills: '分析中',
|
||||
select_skills: '筛选相关技能',
|
||||
invoke_skill: '调用技能',
|
||||
skill_result: '检索结果',
|
||||
stop_early: '提前停止',
|
||||
};
|
||||
|
||||
export function SkillStepsCard({ steps, inProgress }: SkillStepsCardProps) {
|
||||
const [expanded, setExpanded] = useState(true);
|
||||
if (steps.length === 0 && !inProgress) return null;
|
||||
|
||||
// 进行中的步骤:最后一条是 invoke_skill 且还没出对应的 skill_result,
|
||||
// 说明该技能的 web 检索正在 await 中——把它的序号徽标换成 spinner,
|
||||
// 让每次(可能数秒~数十秒的)检索等待都有"正在调用技能X检索中"的实时反馈。
|
||||
const activeIdx =
|
||||
inProgress && steps.length > 0 && steps[steps.length - 1].type === 'invoke_skill'
|
||||
? steps.length - 1
|
||||
: -1;
|
||||
|
||||
return (
|
||||
<div className="rounded-md border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/20 overflow-hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setExpanded((v) => !v)}
|
||||
className="w-full flex items-center gap-2 px-3 py-2 text-xs font-medium hover:bg-violet-100/50 dark:hover:bg-violet-900/30 transition-colors text-left"
|
||||
>
|
||||
{inProgress
|
||||
? <Loader2 className="size-3.5 text-violet-500 shrink-0 animate-spin" />
|
||||
: <Sparkles className="size-3.5 text-violet-500 shrink-0" />}
|
||||
<span className="flex-1">
|
||||
技能检索过程
|
||||
<span className="ml-1 text-muted-foreground font-normal">
|
||||
(共 {steps.length} 步{inProgress ? ',进行中…' : ''})
|
||||
</span>
|
||||
</span>
|
||||
<ChevronRight
|
||||
className={cn(
|
||||
'size-3 text-muted-foreground transition-transform duration-200',
|
||||
expanded && 'rotate-90',
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
|
||||
<CollapseTransition open={expanded}>
|
||||
<ol className="px-3 pb-2.5 pt-1 space-y-1.5 border-t border-violet-200/60 dark:border-violet-900/30">
|
||||
{steps.map((step, idx) => {
|
||||
const Icon = STEP_ICON[step.type] ?? Sparkles;
|
||||
const label = STEP_LABEL[step.type] ?? step.type;
|
||||
const isStopEarly = step.type === 'stop_early';
|
||||
const isResult = step.type === 'skill_result';
|
||||
const isActive = idx === activeIdx;
|
||||
return (
|
||||
<li key={idx} className="flex items-start gap-2 text-[11px]">
|
||||
<span
|
||||
className={cn(
|
||||
'shrink-0 mt-0.5 inline-flex items-center justify-center size-4 rounded-full text-[10px] font-medium',
|
||||
isActive
|
||||
? 'bg-violet-500 text-white'
|
||||
: isStopEarly
|
||||
? 'bg-amber-100 dark:bg-amber-900/60 text-amber-600 dark:text-amber-300'
|
||||
: isResult
|
||||
? 'bg-emerald-100 dark:bg-emerald-900/60 text-emerald-600 dark:text-emerald-300'
|
||||
: 'bg-violet-100 dark:bg-violet-900/60 text-violet-600 dark:text-violet-300',
|
||||
)}
|
||||
>
|
||||
{isActive ? <Loader2 className="size-2.5 animate-spin" /> : idx + 1}
|
||||
</span>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center gap-1 font-medium',
|
||||
isStopEarly
|
||||
? 'text-amber-700 dark:text-amber-300'
|
||||
: isResult
|
||||
? 'text-emerald-700 dark:text-emerald-300'
|
||||
: 'text-violet-700 dark:text-violet-300',
|
||||
)}
|
||||
>
|
||||
<Icon className="size-3 shrink-0" />
|
||||
<span>{label}</span>
|
||||
{step.skillName && (
|
||||
<span className="font-mono text-violet-900 dark:text-violet-100">
|
||||
· {step.skillName}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-muted-foreground mt-0.5">{step.message}</div>
|
||||
{step.skillNames && step.skillNames.length > 0 && (
|
||||
<div className="mt-1 flex flex-wrap gap-1">
|
||||
{step.skillNames.map((name) => (
|
||||
<span
|
||||
key={name}
|
||||
className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-mono bg-violet-100 dark:bg-violet-900/60 text-violet-700 dark:text-violet-200"
|
||||
>
|
||||
{name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{step.reason && (
|
||||
<div className="mt-0.5 text-[10px] text-violet-600/80 dark:text-violet-400/80 italic">
|
||||
原因:{step.reason}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
{inProgress && steps.length === 0 && (
|
||||
// 用户刚点击"技能检索",还没收到任何步骤事件:用骨架行 + spinner 占位,
|
||||
// 避免用户在等待后端 emit 时干等空白
|
||||
<>
|
||||
<li className="flex items-center gap-2 text-[11px] text-violet-700/80 dark:text-violet-300/70 italic">
|
||||
<Loader2 className="size-3 animate-spin shrink-0" />
|
||||
正在准备技能检索…
|
||||
</li>
|
||||
{[0, 1, 2].map((i) => (
|
||||
<li key={`skel-${i}`} className="flex items-start gap-2 animate-pulse" style={{ animationDelay: `${i * 120}ms` }}>
|
||||
<span className="shrink-0 mt-0.5 size-4 rounded-full bg-violet-100 dark:bg-violet-900/60" />
|
||||
<div className="flex-1 min-w-0 space-y-1">
|
||||
<div className="h-2.5 w-24 rounded bg-violet-100 dark:bg-violet-900/60" />
|
||||
<div className="h-2 w-40 rounded bg-violet-50 dark:bg-violet-900/30" />
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
{inProgress && steps.length > 0 && activeIdx < 0 && (
|
||||
// 当前不在某个技能的检索等待中(最后一条是 result / select 等),
|
||||
// 提示还有后续步骤;正在检索时由该步自身的 spinner 体现进行中,不重复。
|
||||
<li className="flex items-center gap-2 text-[11px] text-muted-foreground italic">
|
||||
<Loader2 className="size-3 animate-spin shrink-0" />
|
||||
更多步骤生成中…
|
||||
</li>
|
||||
)}
|
||||
</ol>
|
||||
</CollapseTransition>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';
|
||||
import { useStream } from '@langchain/langgraph-sdk/react';
|
||||
|
||||
import { getAPIClient } from '@/core/api';
|
||||
import { getStoredAuth } from '@/core/auth';
|
||||
import { fetchStudioToken } from '@/core/studio/api';
|
||||
|
||||
import { useCanvasGraphContext } from '../contexts/CanvasGraphContext';
|
||||
import { saveAIWritingTranscript } from '../api/ai-writing-sessions';
|
||||
@@ -41,6 +43,7 @@ import type {
|
||||
ProgressEventType,
|
||||
ReviewIssue,
|
||||
ReviewResult,
|
||||
SkillSearchStep,
|
||||
StreamingReviewItem,
|
||||
UserInterventionPayload,
|
||||
WritingStatus,
|
||||
@@ -71,6 +74,10 @@ const INITIAL_STATE: AIWritingState = {
|
||||
intentThinkingText: '',
|
||||
parsedIntent: null,
|
||||
researchProgress: '',
|
||||
skillSearchSteps: [],
|
||||
skillSelectStreamingText: '',
|
||||
skillSelectThinkingText: '',
|
||||
skillSearchPending: false,
|
||||
streamingReviewItems: [],
|
||||
revisionSummary: null,
|
||||
pendingRevisionContext: null,
|
||||
@@ -101,11 +108,14 @@ function reducer(prev: AIWritingState, action: Action): AIWritingState {
|
||||
|
||||
case 'intervention_submitted': {
|
||||
const ns = action.nextStatus;
|
||||
// 点击瞬间标记技能检索 pending(动机 = 用户的 action 类型),让 SkillStepsCard 占位卡立即挂载
|
||||
const enablingSkillSearch = action.record.action === 'enable_skill_search';
|
||||
return {
|
||||
...prev,
|
||||
currentPause: null,
|
||||
status: ns,
|
||||
...(ns === 'researching' ? { researchProgress: '' } : {}),
|
||||
skillSearchPending: enablingSkillSearch ? true : prev.skillSearchPending,
|
||||
...(ns === 'researching' ? { researchProgress: '', skillSearchSteps: [], skillSelectStreamingText: '', skillSelectThinkingText: '' } : {}),
|
||||
...(ns === 'writing_outline' ? { outlineStreamingText: '', outlineThinkingText: '' } : {}),
|
||||
...(ns === 'writing_draft' ? { streamingDraftSections: [], streamingDraftTitle: '' } : {}),
|
||||
...(ns === 'reviewing' ? { streamingReviewItems: [] } : {}),
|
||||
@@ -191,12 +201,36 @@ function handleEvent(prev: AIWritingState, event: ProgressEvent): AIWritingState
|
||||
case 'resumed':
|
||||
return { ...base, currentPause: null };
|
||||
|
||||
case 'materials_ready':
|
||||
case 'skill_search_step': {
|
||||
const step = event.skillStep;
|
||||
if (!step) return base;
|
||||
// select_skills 步骤到达 = LLM 选择完成,清空流式打字缓冲
|
||||
const clearStreaming = step.type === 'select_skills'
|
||||
? { skillSelectStreamingText: '', skillSelectThinkingText: '' }
|
||||
: {};
|
||||
return { ...base, skillSearchSteps: [...prev.skillSearchSteps, step], ...clearStreaming };
|
||||
}
|
||||
|
||||
case 'skill_select_chunk': {
|
||||
const text = (event as unknown as { text: string }).text ?? '';
|
||||
const isThinking = (event as unknown as { is_thinking: boolean }).is_thinking ?? false;
|
||||
return {
|
||||
...prev,
|
||||
skillSelectStreamingText: isThinking ? prev.skillSelectStreamingText : prev.skillSelectStreamingText + text,
|
||||
skillSelectThinkingText: isThinking ? prev.skillSelectThinkingText + text : prev.skillSelectThinkingText,
|
||||
};
|
||||
}
|
||||
|
||||
case 'materials_ready': {
|
||||
// 后端把 pkg.skill_search_steps 一并塞回来时,覆盖前端累积(保证刷新页面回放也对)
|
||||
const incomingSteps = (event as unknown as { skillSearchSteps?: SkillSearchStep[] }).skillSearchSteps;
|
||||
return {
|
||||
...base,
|
||||
materials: (event.materials ?? []) as AIMaterial[],
|
||||
researchProgress: '',
|
||||
...(incomingSteps ? { skillSearchSteps: incomingSteps } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
case 'outline_chunk': {
|
||||
const text = (event as unknown as { text: string }).text ?? '';
|
||||
@@ -313,7 +347,9 @@ function handleEvent(prev: AIWritingState, event: ProgressEvent): AIWritingState
|
||||
const extra: Partial<AIWritingState> = {};
|
||||
if (pp === 'material_confirm' && event.materials?.length) extra.materials = event.materials;
|
||||
if (pp === 'outline_confirm' && event.outline) extra.outline = event.outline;
|
||||
return { ...base, ...extra, status: pauseStatus, currentPause: event };
|
||||
// 进入素材确认(material_confirm)= 技能检索(如果在进行)已经完成,清掉 pending 占位
|
||||
const clearPending = pp === 'material_confirm' ? { skillSearchPending: false } : {};
|
||||
return { ...base, ...extra, ...clearPending, status: pauseStatus, currentPause: event };
|
||||
}
|
||||
|
||||
case 'done':
|
||||
@@ -337,6 +373,7 @@ function handleEvent(prev: AIWritingState, event: ProgressEvent): AIWritingState
|
||||
// ── snake_case ↔ camelCase 归一化(custom 通道事件 + interrupt payload) ──────
|
||||
|
||||
function normalizeMaterial(m: Record<string, unknown>): AIMaterial {
|
||||
const extra = (m.extra_metadata ?? m.extraMetadata) as Record<string, unknown> | undefined;
|
||||
return {
|
||||
id: String(m.id ?? ''),
|
||||
title: String(m.title ?? ''),
|
||||
@@ -344,9 +381,21 @@ function normalizeMaterial(m: Record<string, unknown>): AIMaterial {
|
||||
source: String(m.source ?? ''),
|
||||
publishedAt: String(m.published_at ?? m.publishedAt ?? ''),
|
||||
relevanceScore: Number(m.relevance_score ?? m.relevanceScore ?? 0),
|
||||
sourceType: (m.source_type ?? m.sourceType ?? 'internet') as 'internet' | 'intranet',
|
||||
sourceType: (m.source_type ?? m.sourceType ?? 'internet') as AIMaterial['sourceType'],
|
||||
url: m.url as string | undefined,
|
||||
recUuid: (m.recUuid ?? m.rec_uuid) as string | undefined,
|
||||
extraMetadata: extra,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeSkillStep(s: Record<string, unknown>): SkillSearchStep {
|
||||
return {
|
||||
type: (s.type as SkillSearchStep['type']) ?? 'invoke_skill',
|
||||
message: String(s.message ?? ''),
|
||||
skillNames: (s.skill_names ?? s.skillNames) as string[] | undefined,
|
||||
skillName: (s.skill_name ?? s.skillName) as string | undefined,
|
||||
reason: s.reason as string | undefined,
|
||||
matchedCount: (s.matched_count ?? s.matchedCount) as number | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -445,6 +494,7 @@ function customToProgressEvent(raw: unknown, sessionId: string): ProgressEvent |
|
||||
'intent_chunk', 'intent_ready',
|
||||
'research_progress', 'outline_chunk', 'draft_chunk',
|
||||
'review_chunk', 'review_item_done',
|
||||
'skill_search_step', 'skill_select_chunk',
|
||||
];
|
||||
if (!allowed.includes(type as ProgressEventType)) return null;
|
||||
|
||||
@@ -459,6 +509,10 @@ function customToProgressEvent(raw: unknown, sessionId: string): ProgressEvent |
|
||||
if (Array.isArray(merged.issues)) {
|
||||
merged.reviewItemIssues = (merged.issues as Record<string, unknown>[]).map(normalizeReviewIssue);
|
||||
}
|
||||
// skill_search_step:把字段折成 skillStep 子对象,方便 reducer / UI 取用
|
||||
if (type === 'skill_search_step') {
|
||||
merged.skillStep = normalizeSkillStep(o);
|
||||
}
|
||||
return merged as unknown as ProgressEvent;
|
||||
}
|
||||
|
||||
@@ -478,6 +532,9 @@ function nodeUpdatesToEvents(nodeOutput: unknown, sessionId: string): ProgressEv
|
||||
// ``material_package`` 出现 → materials_ready(节点 progress_events 里不带)
|
||||
if (out.material_package && typeof out.material_package === 'object') {
|
||||
const pkg = out.material_package as Record<string, unknown>;
|
||||
const skillSteps = Array.isArray(pkg.skill_search_steps ?? pkg.skillSearchSteps)
|
||||
? ((pkg.skill_search_steps ?? pkg.skillSearchSteps) as Record<string, unknown>[]).map(normalizeSkillStep)
|
||||
: undefined;
|
||||
events.push({
|
||||
type: 'materials_ready',
|
||||
sessionId,
|
||||
@@ -485,7 +542,8 @@ function nodeUpdatesToEvents(nodeOutput: unknown, sessionId: string): ProgressEv
|
||||
materials: Array.isArray(pkg.materials) ? (pkg.materials as Record<string, unknown>[]).map(normalizeMaterial) : [],
|
||||
keywords: (pkg.keywords ?? []) as string[],
|
||||
materialSummary: (pkg.summary as string) ?? '',
|
||||
});
|
||||
...(skillSteps ? { skillSearchSteps: skillSteps } as unknown as Partial<ProgressEvent> : {}),
|
||||
} as ProgressEvent);
|
||||
}
|
||||
|
||||
// ``current_outline`` 出现且 progress_events 里没 outline_ready → 合成一条
|
||||
@@ -578,12 +636,25 @@ export function useAIWriting() {
|
||||
dispatch({ type: 'set_session', sessionId: meta.thread_id });
|
||||
},
|
||||
onCustomEvent(event: unknown) {
|
||||
// 技能检索时机 trace:开 window.__AI_WRITING_DEBUG__ = true 后,控制台按
|
||||
// performance.now() 打印每条 custom 事件到达时刻 + type,用来钉死
|
||||
// skill_search_step(技能检索过程卡)与 skill_select_chunk(筛选技能打字)
|
||||
// 的实际到达顺序,区分"后端未实时 emit" vs "前端渲染滞后"。
|
||||
if (typeof window !== 'undefined' && (window as { __AI_WRITING_DEBUG__?: boolean }).__AI_WRITING_DEBUG__) {
|
||||
const t = (event as { type?: string } | null)?.type;
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(`[ai-writing:custom] +${Math.round(performance.now())}ms type=${t ?? '?'}`, event);
|
||||
}
|
||||
const pe = customToProgressEvent(event, state.sessionId ?? '');
|
||||
if (pe) dispatch({ type: 'handle', event: pe });
|
||||
},
|
||||
onUpdateEvent(data: Record<string, unknown> | undefined) {
|
||||
// data 形如 { node_name: { ...node_output } },可能多个节点同一 step
|
||||
if (!data) return;
|
||||
if (typeof window !== 'undefined' && (window as { __AI_WRITING_DEBUG__?: boolean }).__AI_WRITING_DEBUG__) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(`[ai-writing:updates] +${Math.round(performance.now())}ms nodes=${Object.keys(data).join(',')}`);
|
||||
}
|
||||
// 兜底:updates 通道可能直接带 ``__interrupt__`` 数组(节点进 interrupt 时
|
||||
// LangGraph 推 ``{__interrupt__: [...]}``),SDK 主路径只在 values 通道
|
||||
// 暴露 stream.interrupt —— 万一后端 serialize 又把 __interrupt__ 滤掉,
|
||||
@@ -670,6 +741,19 @@ export function useAIWriting() {
|
||||
if (state.status !== 'idle' && state.status !== 'done' && state.status !== 'error') return;
|
||||
dispatch({ type: 'start', request });
|
||||
try {
|
||||
// 如果选择了笔记来源,获取 notebook token 用于后端检索
|
||||
let notebookToken = '';
|
||||
if (request.noteSearchSpaceId) {
|
||||
const email = getStoredAuth()?.email ?? '';
|
||||
if (email) {
|
||||
try {
|
||||
notebookToken = await fetchStudioToken(email);
|
||||
} catch {
|
||||
// 忽略 token 获取失败,后端会优雅降级
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await stream.submit(
|
||||
{
|
||||
user_intent: request.userIntent,
|
||||
@@ -678,6 +762,7 @@ export function useAIWriting() {
|
||||
word_count_target: request.wordCountTarget,
|
||||
keyword_count: Math.max(1, Math.min(10, request.keywordCount)),
|
||||
writing_mode: request.writingMode === 'strict' ? 'strict' : 'loose',
|
||||
material_source: request.materialSource === 'skill' ? 'skill' : 'knowledge_base',
|
||||
revision_count: 0,
|
||||
max_revisions: 3,
|
||||
status: 'researching',
|
||||
@@ -688,9 +773,16 @@ export function useAIWriting() {
|
||||
current_draft: null,
|
||||
review_result: null,
|
||||
last_user_intervention: null,
|
||||
notebook_search_space_id: request.noteSearchSpaceId ?? null,
|
||||
notebook_source_ids: request.noteSourceIds ?? [],
|
||||
} as Partial<AIWritingValues>,
|
||||
{
|
||||
config: { configurable: { model_name: request.modelName ?? '' } } as Record<string, unknown>,
|
||||
config: {
|
||||
configurable: {
|
||||
model_name: request.modelName ?? '',
|
||||
...(notebookToken ? { notebook_token: notebookToken } : {}),
|
||||
},
|
||||
} as Record<string, unknown>,
|
||||
streamMode: ['values', 'updates', 'custom', 'messages-tuple'],
|
||||
},
|
||||
);
|
||||
@@ -733,7 +825,9 @@ export function useAIWriting() {
|
||||
// 乐观更新到下一阶段,跟老 hook 行为对齐
|
||||
let nextStatus: WritingStatus = state.status;
|
||||
if (pausePoint === 'material_confirm') {
|
||||
nextStatus = payload.action === 're_search' ? 'researching' : 'writing_outline';
|
||||
// re_search / enable_skill_search 都回到 researching;confirm 才进大纲
|
||||
nextStatus = (payload.action === 're_search' || payload.action === 'enable_skill_search')
|
||||
? 'researching' : 'writing_outline';
|
||||
} else if (pausePoint === 'outline_confirm') {
|
||||
nextStatus = payload.action === 're_outline' ? 'writing_outline' : 'writing_draft';
|
||||
} else if (pausePoint === 'draft_confirm') {
|
||||
@@ -754,6 +848,7 @@ export function useAIWriting() {
|
||||
};
|
||||
if (payload.approvedMaterialIds !== undefined) resumePayload.approvedMaterialIds = payload.approvedMaterialIds;
|
||||
if (payload.extraKeywords !== undefined) resumePayload.extraKeywords = payload.extraKeywords;
|
||||
if (payload.userQuery !== undefined) resumePayload.userQuery = payload.userQuery;
|
||||
if (payload.editedOutline !== undefined) resumePayload.editedOutline = payload.editedOutline;
|
||||
if (payload.outlineFeedback !== undefined) resumePayload.outlineFeedback = payload.outlineFeedback;
|
||||
if (payload.userRevisionNotes !== undefined) resumePayload.userRevisionNotes = payload.userRevisionNotes;
|
||||
|
||||
@@ -7,9 +7,27 @@ export interface AIMaterial {
|
||||
source: string;
|
||||
publishedAt: string;
|
||||
relevanceScore: number;
|
||||
sourceType: 'internet' | 'intranet';
|
||||
sourceType: 'internet' | 'intranet' | 'skill' | 'notebook';
|
||||
url?: string;
|
||||
recUuid?: string;
|
||||
// skill 类素材的元信息(skill_name / container_path / category / skill_full_content 等)
|
||||
extraMetadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// 技能检索过程的单步记录(前端时间线展示"使用了 X 技能")
|
||||
// list_skills:列出全部 enabled 技能
|
||||
// match_skills:进入 LLM 流式选择前的过渡提示(让用户立刻看到反馈)
|
||||
// select_skills:LLM 按相关度排序的候选
|
||||
// invoke_skill:开始调用某个技能去检索
|
||||
// skill_result:某个技能检索返回了 N 条素材
|
||||
// stop_early:累计素材达到上限,停止后续技能
|
||||
export interface SkillSearchStep {
|
||||
type: 'list_skills' | 'match_skills' | 'select_skills' | 'invoke_skill' | 'skill_result' | 'stop_early';
|
||||
message: string;
|
||||
skillNames?: string[];
|
||||
skillName?: string;
|
||||
reason?: string;
|
||||
matchedCount?: number;
|
||||
}
|
||||
|
||||
// ── 大纲 ─────────────────────────────────────────────────────────────────────
|
||||
@@ -139,6 +157,8 @@ export type ProgressEventType =
|
||||
| 'await_user'
|
||||
| 'resumed'
|
||||
| 'notice'
|
||||
| 'skill_search_step'
|
||||
| 'skill_select_chunk'
|
||||
| 'done'
|
||||
| 'error';
|
||||
|
||||
@@ -173,6 +193,8 @@ export interface ProgressEvent {
|
||||
pauseContext?: Record<string, unknown>;
|
||||
// section_help:素材不足、待用户决策的章节
|
||||
blockedSections?: BlockedSection[];
|
||||
// skill_search_step:技能检索步骤事件(list_skills / select_skills / invoke_skill)
|
||||
skillStep?: SkillSearchStep;
|
||||
}
|
||||
|
||||
// ── 用户干预提交体 ────────────────────────────────────────────────────────────
|
||||
@@ -180,7 +202,10 @@ export interface ProgressEvent {
|
||||
export interface UserInterventionPayload {
|
||||
action: string;
|
||||
approvedMaterialIds?: string[];
|
||||
/** @deprecated 旧版多关键词追加。新版统一用 userQuery 单输入框 */
|
||||
extraKeywords?: string[];
|
||||
/** PAUSE-1 素材确认:用户单输入框写的自然语言(技能名/来源/检索意图都行)。re_search / enable_skill_search 共用。 */
|
||||
userQuery?: string;
|
||||
editedOutline?: AIOutline;
|
||||
outlineFeedback?: string;
|
||||
userRevisionNotes?: string;
|
||||
@@ -203,6 +228,12 @@ export interface AIWritingRequest {
|
||||
keywordCount: number;
|
||||
/** 写作模式:strict=严格依据素材 / loose=可结合通用知识(默认 loose) */
|
||||
writingMode: 'strict' | 'loose';
|
||||
/** 素材来源:knowledge_base=知识库 / skill=技能检索 / notebook=我的笔记 */
|
||||
materialSource: 'knowledge_base' | 'skill' | 'notebook';
|
||||
/** 笔记来源(可选):笔记本 search_space_id */
|
||||
noteSearchSpaceId?: number;
|
||||
/** 笔记来源(可选):笔记本内指定文档的 document_id 列表,空数组表示检索整个笔记本 */
|
||||
noteSourceIds?: number[];
|
||||
}
|
||||
|
||||
// ── 流式审核条目 ──────────────────────────────────────────────────────────────
|
||||
@@ -291,6 +322,14 @@ export interface AIWritingState {
|
||||
parsedIntent: ParsedIntent | null;
|
||||
// 素材收集实时进度(最新一条提示文案)
|
||||
researchProgress: string;
|
||||
// 技能检索步骤(按发生顺序累积,pause_material 卡片里渲染时间线)
|
||||
skillSearchSteps: SkillSearchStep[];
|
||||
// 技能选择 LLM 流式打字内容(正文 / 思考分开),select_skills 完成后清空
|
||||
skillSelectStreamingText: string;
|
||||
skillSelectThinkingText: string;
|
||||
/** 技能检索是否正在进行:用户点击"技能检索"瞬间 true,进入 awaiting 时清掉。
|
||||
* 用于在 LangGraph 还没推任何 skill_search_step 事件时给前端展示占位卡。 */
|
||||
skillSearchPending: boolean;
|
||||
// 流式审核(逐条到达)
|
||||
streamingReviewItems: StreamingReviewItem[];
|
||||
// 修改摘要
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
import { useParams, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { useTheme } from "@/contexts/ThemeContext";
|
||||
import { loginByUsername } from "@/core/auth/api";
|
||||
import { setStoredAuth } from "@/core/auth";
|
||||
import {
|
||||
persistExternalLoginParams,
|
||||
resolveThemeFromQuery,
|
||||
} from "@/core/auth/external-login";
|
||||
import {
|
||||
GENERAL_QA_ROUTE,
|
||||
loginByYUserId,
|
||||
persistToolsToken,
|
||||
} from "@/core/auth/yuser-login";
|
||||
import {
|
||||
isSidebarEnabledFromSearch,
|
||||
persistSidebarEnabled,
|
||||
@@ -18,6 +28,7 @@ export default function LoginPage() {
|
||||
const { username } = useParams<{ username?: string }>();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { setTheme } = useTheme();
|
||||
const sidebarEnabled = useMemo(
|
||||
() => isSidebarEnabledFromSearch(searchParams.toString()),
|
||||
[searchParams],
|
||||
@@ -26,9 +37,33 @@ export default function LoginPage() {
|
||||
const raw = username?.trim();
|
||||
return raw && raw.length > 0 ? raw : DEFAULT_USERNAME;
|
||||
}, [username]);
|
||||
// 外部跳转参数:theme 直接调 setTheme;ticket/userId/env 持久化到 localStorage
|
||||
const yUserId = searchParams.get("yUserId")?.trim() ?? "";
|
||||
const toolToken = searchParams.get("token")?.trim() ?? "";
|
||||
const externalParams = useMemo(() => ({
|
||||
theme: searchParams.get("theme") ?? "",
|
||||
ticket: searchParams.get("ticket") ?? "",
|
||||
userId: searchParams.get("userId") ?? "",
|
||||
env: searchParams.get("env") ?? "",
|
||||
}), [searchParams]);
|
||||
const [status, setStatus] = useState<LoginStatus>("loading");
|
||||
const [errorMessage, setErrorMessage] = useState<string>("");
|
||||
|
||||
// 主题切换:theme=dark-blue → 深色,其他值或缺省 → 浅色
|
||||
useEffect(() => {
|
||||
if (!externalParams.theme) return;
|
||||
setTheme(resolveThemeFromQuery(externalParams.theme));
|
||||
}, [externalParams.theme, setTheme]);
|
||||
|
||||
// ticket / userId / env 持久化(与 login 请求并行做,互不阻塞)
|
||||
useEffect(() => {
|
||||
persistExternalLoginParams({
|
||||
ticket: externalParams.ticket,
|
||||
userId: externalParams.userId,
|
||||
env: externalParams.env,
|
||||
});
|
||||
}, [externalParams.ticket, externalParams.userId, externalParams.env]);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
@@ -36,6 +71,12 @@ export default function LoginPage() {
|
||||
setStatus("loading");
|
||||
setErrorMessage("");
|
||||
try {
|
||||
if (yUserId) {
|
||||
await loginByYUserId(yUserId, toolToken || null);
|
||||
} else if (toolToken) {
|
||||
persistToolsToken(toolToken);
|
||||
}
|
||||
|
||||
const auth = await loginByUsername(resolvedUsername);
|
||||
if (cancelled) {
|
||||
return;
|
||||
@@ -43,7 +84,7 @@ export default function LoginPage() {
|
||||
setStoredAuth(auth);
|
||||
persistSidebarEnabled(sidebarEnabled);
|
||||
setStatus("success");
|
||||
router.replace("/page/workspace/chats/new");
|
||||
router.replace(yUserId ? GENERAL_QA_ROUTE : "/page/workspace/chats/new");
|
||||
} catch (error) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
@@ -59,7 +100,7 @@ export default function LoginPage() {
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [resolvedUsername, router, sidebarEnabled]);
|
||||
}, [resolvedUsername, router, sidebarEnabled, yUserId, toolToken]);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-background px-6">
|
||||
|
||||
@@ -19,6 +19,13 @@ import {
|
||||
} from "@/components/ai-elements/prompt-input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { ArtifactsProvider } from "@/components/workspace/artifacts";
|
||||
import {
|
||||
@@ -115,10 +122,34 @@ export default function NewAgentPage() {
|
||||
return;
|
||||
}
|
||||
const first = models[0]!.name;
|
||||
setModelInput((prev) => prev || first);
|
||||
setChatModelInput((prev) => prev || first);
|
||||
setModelInput((prev) =>
|
||||
prev && models.some((m) => m.name === prev) ? prev : first,
|
||||
);
|
||||
setChatModelInput((prev) =>
|
||||
prev && models.some((m) => m.name === prev) ? prev : first,
|
||||
);
|
||||
}, [models]);
|
||||
|
||||
const resolvedModelInput = useMemo(() => {
|
||||
if (models.length === 0) {
|
||||
return "";
|
||||
}
|
||||
if (modelInput && models.some((m) => m.name === modelInput)) {
|
||||
return modelInput;
|
||||
}
|
||||
return models[0]!.name;
|
||||
}, [modelInput, models]);
|
||||
|
||||
const resolvedChatModelInput = useMemo(() => {
|
||||
if (models.length === 0) {
|
||||
return "";
|
||||
}
|
||||
if (chatModelInput && models.some((m) => m.name === chatModelInput)) {
|
||||
return chatModelInput;
|
||||
}
|
||||
return models[0]!.name;
|
||||
}, [chatModelInput, models]);
|
||||
|
||||
const [thread, sendMessage] = useThreadStream({
|
||||
threadId,
|
||||
assistantId: agentId || undefined,
|
||||
@@ -347,23 +378,42 @@ export default function NewAgentPage() {
|
||||
<span className="text-muted-foreground text-xs">
|
||||
当前对话模型
|
||||
</span>
|
||||
<select
|
||||
value={chatModelInput}
|
||||
onChange={(event) =>
|
||||
setChatModelInput(event.currentTarget.value)
|
||||
}
|
||||
disabled={isModelsLoading || thread.isLoading}
|
||||
className="border-input bg-background h-7 min-w-[10rem] rounded-md border px-2 text-xs shadow-xs outline-none"
|
||||
>
|
||||
<option value="" disabled>
|
||||
选择模型
|
||||
</option>
|
||||
{models.map((model) => (
|
||||
<option key={model.name} value={model.name}>
|
||||
{model.display_name || model.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{isModelsLoading || models.length === 0 ? (
|
||||
<div className="border-input bg-background text-muted-foreground flex h-7 min-w-[10rem] items-center rounded-md border px-2 text-xs shadow-xs dark:border-[#1B477E] dark:bg-[#022248]">
|
||||
{isModelsLoading ? "加载中…" : "暂无模型"}
|
||||
</div>
|
||||
) : (
|
||||
<Select
|
||||
value={resolvedChatModelInput}
|
||||
onValueChange={setChatModelInput}
|
||||
disabled={thread.isLoading}
|
||||
>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
"border-input bg-background h-7 min-w-[10rem] px-2 text-xs shadow-xs outline-none",
|
||||
"dark:border-[#1B477E] dark:bg-[#022248] dark:text-[#AACEFF] dark:hover:bg-[#022248]",
|
||||
"data-[placeholder]:text-muted-foreground",
|
||||
"[&_svg]:dark:text-[#AACEE2]",
|
||||
)}
|
||||
>
|
||||
<SelectValue placeholder="选择模型" />
|
||||
</SelectTrigger>
|
||||
<SelectContent
|
||||
position="popper"
|
||||
className="w-[var(--radix-select-trigger-width)] dark:border-[#1B477E] dark:bg-[#022248]"
|
||||
>
|
||||
{models.map((model) => (
|
||||
<SelectItem
|
||||
key={model.name}
|
||||
value={model.name}
|
||||
className="dark:text-[#AACEFF] dark:data-[highlighted]:bg-[#0062D9] dark:data-[highlighted]:text-white"
|
||||
>
|
||||
{model.display_name || model.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
</div>
|
||||
<PromptInput
|
||||
onSubmit={({ text }) => void handleChatSubmit(text)}
|
||||
@@ -415,21 +465,41 @@ export default function NewAgentPage() {
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">模型</label>
|
||||
<select
|
||||
value={modelInput}
|
||||
onChange={(event) => setModelInput(event.currentTarget.value)}
|
||||
disabled={isModelsLoading}
|
||||
className="border-input bg-background h-9 w-full rounded-md border px-3 text-sm shadow-xs outline-none"
|
||||
>
|
||||
<option value="" disabled>
|
||||
选择模型
|
||||
</option>
|
||||
{models.map((model) => (
|
||||
<option key={model.name} value={model.name}>
|
||||
{model.display_name || model.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{isModelsLoading || models.length === 0 ? (
|
||||
<div className="border-input bg-background text-muted-foreground flex h-9 w-full items-center rounded-md border px-3 text-sm shadow-xs dark:border-[#1B477E] dark:bg-[#022248]">
|
||||
{isModelsLoading ? "加载模型…" : "暂无可用模型"}
|
||||
</div>
|
||||
) : (
|
||||
<Select
|
||||
value={resolvedModelInput}
|
||||
onValueChange={setModelInput}
|
||||
>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
"border-input bg-background h-9 w-full shadow-xs outline-none",
|
||||
"dark:border-[#1B477E] dark:bg-[#022248] dark:text-[#AACEFF] dark:hover:bg-[#022248]",
|
||||
"data-[placeholder]:text-muted-foreground",
|
||||
"[&_svg]:dark:text-[#AACEE2]",
|
||||
)}
|
||||
>
|
||||
<SelectValue placeholder="选择模型" />
|
||||
</SelectTrigger>
|
||||
<SelectContent
|
||||
position="popper"
|
||||
className="w-[var(--radix-select-trigger-width)] dark:border-[#1B477E] dark:bg-[#022248]"
|
||||
>
|
||||
{models.map((model) => (
|
||||
<SelectItem
|
||||
key={model.name}
|
||||
value={model.name}
|
||||
className="dark:text-[#AACEFF] dark:data-[highlighted]:bg-[#0062D9] dark:data-[highlighted]:text-white"
|
||||
>
|
||||
{model.display_name || model.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
<p className="text-muted-foreground text-xs">
|
||||
该智能体被使用时调用的模型。
|
||||
</p>
|
||||
@@ -463,7 +533,7 @@ export default function NewAgentPage() {
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="max-h-[240px] overflow-y-auto rounded-md border p-2">
|
||||
<div className="max-h-[240px] overflow-y-auto rounded-md border p-2 dark:border-[#1B477E] dark:bg-[#022248]">
|
||||
{isSkillsLoading ? (
|
||||
<p className="text-muted-foreground text-sm">技能加载中...</p>
|
||||
) : enabledSkills.length === 0 ? (
|
||||
|
||||
@@ -36,8 +36,16 @@ function PageLayout() {
|
||||
)
|
||||
)}
|
||||
<main
|
||||
className={`flex-1 overflow-hidden transition-[padding] duration-300 ${
|
||||
!sidebarEnabled ? "" : collapsed ? "pl-16" : "pl-64"
|
||||
className={`flex-1 overflow-hidden ${
|
||||
!sidebarEnabled
|
||||
? ""
|
||||
: isDark
|
||||
// 深色 sidebar:展开 118px(10 + 98 + 10 gap),收起 = 0 sidebar 完全消失,
|
||||
// 只剩左下角浮动按钮(fixed,叠在 main 上不影响布局)。
|
||||
// 不加 transition:transition + sidebar 立刻 unmount 不同步会抽搐
|
||||
? (collapsed ? "pl-0" : "pl-[118px]")
|
||||
// 浅色仍保留过渡动画(pl-16 ↔ pl-64 平滑收展)
|
||||
: `transition-[padding] duration-300 ${collapsed ? "pl-16" : "pl-64"}`
|
||||
}`}
|
||||
>
|
||||
<Routes>
|
||||
@@ -50,6 +58,7 @@ function PageLayout() {
|
||||
pageSidebarHidden={!sidebarEnabled}
|
||||
headerHidden={!sidebarEnabled}
|
||||
compactWorkspaceSidebar={sidebarEnabled}
|
||||
pageSidebarDark={isDark}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getStoredAuth } from "@/core/auth";
|
||||
import { RouteBaseProvider } from "@/core/route-base";
|
||||
import { SidebarProvider } from "@/components/ui/sidebar";
|
||||
|
||||
import GeneralQA from "@/strategy-components/components/qa/GeneralQA";
|
||||
import GeneralQA from "@/strategy-components/components/chat-qa/GeneralQA";
|
||||
import { ChatRuntime } from "./WorkspaceRoutes";
|
||||
import AgentsPage from "./AgentsPage";
|
||||
import ChatsPage from "./ChatsPage";
|
||||
@@ -30,6 +30,15 @@ import LightAppNoteListPage from "./LightAppNoteListPage";
|
||||
import LightAppNoteQAPage from "./LightAppNoteQAPage";
|
||||
import TaskXkFrom from "@/strategy-components/components/task-components/TaskXkFrom";
|
||||
import TaskManagement from "@/strategy-components/components/task-components/TaskManagement";
|
||||
import TaskPgFrom from "@/strategy-components/components/task-components/TaskPgFrom";
|
||||
import FanganTyPage from "@/strategy-components/components/task-components/FanganTy";
|
||||
import XingdongTyPage from "@/strategy-components/components/task-components/XingdongTy";
|
||||
import XXTyPage from "@/strategy-components/components/task-components/XXTy";
|
||||
import SentimentAnalyzes from "@/strategy-components/components/task-components/SentimentAnalyzes";
|
||||
import TaskAnalyzes from "@/strategy-components/components/task-components/TaskAnalyzes";
|
||||
import { ActionAnalyzes } from "@/strategy-components/components/task-components/ActionAnalyzes";
|
||||
import NetworkActorResourceManagement from "@/strategy-components/components/resource-management/NetworkActorResourceManagement";
|
||||
import KnowledgeBaseResourceManagement from "@/strategy-components/components/resource-management/KnowledgeBaseResourceManagement";
|
||||
|
||||
export default function StrategyRoutes() {
|
||||
return (
|
||||
@@ -41,26 +50,91 @@ export default function StrategyRoutes() {
|
||||
|
||||
{/* 问答中心 */}
|
||||
<Route path="qa/general" element={<GeneralQA />} />
|
||||
<Route
|
||||
path="qa/expert-qa"
|
||||
element={
|
||||
<GeneralQA
|
||||
chatHeadTitle="专家问答"
|
||||
chatDesign="支持单轮RAG、多轮RAG、深度检索及结果对比"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* 任务管理 */}
|
||||
<Route path="task-management" element={<TaskManagement />}>
|
||||
<Route index element={<Navigate to="xk-task-jc" replace />} />
|
||||
{/* XK任务 */}
|
||||
<Route
|
||||
path="xk-task-jc"
|
||||
element={<TaskXkFrom gopath="#/pageIndie/pageHome/pageSwrw" />}
|
||||
/>
|
||||
<Route
|
||||
path="xk-task-dispatch"
|
||||
element={<TaskXkFrom gopath="#/pageIndie/pageJczl" />}
|
||||
/>
|
||||
{/* pg中任务 */}
|
||||
<Route
|
||||
path="effect-task-pg"
|
||||
element={<TaskPgFrom gopath="task" />}
|
||||
/>
|
||||
<Route
|
||||
path="effect-action-pg"
|
||||
element={<TaskPgFrom gopath="xd" />}
|
||||
/>
|
||||
<Route
|
||||
path="effect-info-pg"
|
||||
element={<TaskPgFrom gopath="info" />}
|
||||
/>
|
||||
{/* COH中任务 */}
|
||||
<Route
|
||||
path="plan-task-sentiment"
|
||||
element={
|
||||
<TaskXkFrom
|
||||
gopath={'#/pageIndie/pageHome/pageSwrw'}
|
||||
<SentimentAnalyzes
|
||||
title="3QFX"
|
||||
category="规划任务"
|
||||
subCategory="规划任务"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="xk-task-dispatch"
|
||||
path="plan-task/plan-task-fx"
|
||||
element={
|
||||
<TaskXkFrom
|
||||
gopath={'#/pageIndie/pageJczl'}
|
||||
<TaskAnalyzes
|
||||
title="任务FX"
|
||||
category="规划任务"
|
||||
subCategory="规划任务"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="plan-task/plan-task-action"
|
||||
element={
|
||||
<ActionAnalyzes
|
||||
title="xdfx"
|
||||
category="规划任务"
|
||||
subCategory="规划任务"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* MNTY任务 */}
|
||||
<Route path="mnty-task-mechanism" element={<XingdongTyPage />} />
|
||||
<Route path="mnty-task-plan" element={<FanganTyPage />} />
|
||||
<Route path="mnty-task-zsty" element={<XXTyPage />} />
|
||||
</Route>
|
||||
{/* 资源管理 */}
|
||||
<Route
|
||||
path="resource-management/resource-network-actor"
|
||||
element={<NetworkActorResourceManagement />}
|
||||
/>
|
||||
<Route
|
||||
path="resource-management/resource-knowledge-base"
|
||||
element={<KnowledgeBaseResourceManagement />}
|
||||
/>
|
||||
<Route
|
||||
path="resource-management/resource-evaluation-index"
|
||||
element={
|
||||
<TaskXkFrom gopath="#/pageIndie/pageZyjc/pageZyzl" />
|
||||
}
|
||||
/>
|
||||
{/* 轻应用 */}
|
||||
<Route path="light-app/new-note" element={<LightAppNewNotePage />} />
|
||||
<Route path="light-app/notes" element={<LightAppNoteListPage />} />
|
||||
|
||||
@@ -5,12 +5,11 @@ import { useParams } from "react-router-dom";
|
||||
import {
|
||||
AlignLeft,
|
||||
ArrowLeft,
|
||||
CloudUpload,
|
||||
BookOpen,
|
||||
Files,
|
||||
Globe,
|
||||
Loader2,
|
||||
Plus,
|
||||
Send,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
|
||||
@@ -23,7 +22,7 @@ import {
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { useNotebookChat, useNotebookSources, useNotebookThreads, useStudioNotebooks } from "@/core/studio/hooks";
|
||||
import { fetchDocumentByChunk, uploadSourceFiles } from "@/core/studio/api";
|
||||
import { fetchDocumentByChunk, uploadSourceFiles, uploadSourceText } from "@/core/studio/api";
|
||||
import type { DocumentWithChunks } from "@/core/studio/api";
|
||||
import type { SourceItem } from "@/core/studio/types";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
@@ -132,6 +131,11 @@ function SourcesDialog({
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [uploadError, setUploadError] = useState("");
|
||||
const [panel, setPanel] = useState<"sources" | "text">("sources");
|
||||
const [textContent, setTextContent] = useState("");
|
||||
const [textTitle, setTextTitle] = useState("");
|
||||
const [submittingText, setSubmittingText] = useState(false);
|
||||
const [textError, setTextError] = useState("");
|
||||
|
||||
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(e.target.files ?? []);
|
||||
@@ -149,6 +153,23 @@ function SourcesDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleTextSubmit = async () => {
|
||||
if (!textContent.trim()) return;
|
||||
setSubmittingText(true);
|
||||
setTextError("");
|
||||
try {
|
||||
await uploadSourceText(notebookId, textContent.trim(), textTitle.trim(), token);
|
||||
setTextContent("");
|
||||
setTextTitle("");
|
||||
setPanel("sources");
|
||||
onUploadSuccess();
|
||||
} catch (err) {
|
||||
setTextError(err instanceof Error ? err.message : "上传失败");
|
||||
} finally {
|
||||
setSubmittingText(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(v) => !v && onClose()}>
|
||||
<DialogContent
|
||||
@@ -171,6 +192,7 @@ function SourcesDialog({
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex min-h-0 flex-1 overflow-hidden">
|
||||
{/* 左侧导航 */}
|
||||
<div className="flex w-44 shrink-0 flex-col gap-1 border-r border-border p-3">
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
@@ -182,47 +204,77 @@ function SourcesDialog({
|
||||
/>
|
||||
<button
|
||||
disabled={uploading}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onClick={() => { setPanel("sources"); fileInputRef.current?.click(); }}
|
||||
className="flex items-center gap-2.5 rounded-xl px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50"
|
||||
>
|
||||
{uploading ? <Loader2 className="size-4 shrink-0 animate-spin" /> : <Plus className="size-4 shrink-0" />}
|
||||
<span className="text-left leading-tight">上传文件</span>
|
||||
</button>
|
||||
{[
|
||||
{ icon: CloudUpload, label: "从云端硬盘添加" },
|
||||
{ icon: Globe, label: "添加网站" },
|
||||
{ icon: AlignLeft, label: "复制的文字" },
|
||||
].map(({ icon: Icon, label }) => (
|
||||
<button
|
||||
key={label}
|
||||
className="flex items-center gap-2.5 rounded-xl px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
||||
>
|
||||
<Icon className="size-4 shrink-0" />
|
||||
<span className="text-left leading-tight">{label}</span>
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
onClick={() => { setPanel("text"); setTextError(""); }}
|
||||
className={`flex items-center gap-2.5 rounded-xl px-3 py-2.5 text-sm transition-colors hover:bg-muted hover:text-foreground ${panel === "text" ? "bg-muted text-foreground" : "text-muted-foreground"}`}
|
||||
>
|
||||
<AlignLeft className="size-4 shrink-0" />
|
||||
<span className="text-left leading-tight">复制的文字</span>
|
||||
</button>
|
||||
{uploadError && (
|
||||
<p className="px-3 text-xs text-destructive">{uploadError}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-4">
|
||||
<div className="grid grid-cols-4 gap-3">
|
||||
{isLoadingSources
|
||||
? Array.from({ length: 8 }).map((_, i) => <SourceCardSkeleton key={i} />)
|
||||
: sources.map((src) => (
|
||||
<SourceCard
|
||||
key={src.id}
|
||||
item={src}
|
||||
selected={selectedSourceIds.includes(src.id)}
|
||||
onToggle={onToggle}
|
||||
/>
|
||||
))}
|
||||
{/* 右侧内容 */}
|
||||
{panel === "sources" ? (
|
||||
<div className="flex-1 overflow-y-auto p-4">
|
||||
<div className="grid grid-cols-4 gap-3">
|
||||
{isLoadingSources
|
||||
? Array.from({ length: 8 }).map((_, i) => <SourceCardSkeleton key={i} />)
|
||||
: sources.map((src) => (
|
||||
<SourceCard
|
||||
key={src.id}
|
||||
item={src}
|
||||
selected={selectedSourceIds.includes(src.id)}
|
||||
onToggle={onToggle}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{!isLoadingSources && sources.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground">暂无来源,请添加文件。</p>
|
||||
)}
|
||||
</div>
|
||||
{!isLoadingSources && sources.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground">暂无来源,请添加文件。</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-1 flex-col gap-3 p-5">
|
||||
<input
|
||||
autoFocus
|
||||
value={textTitle}
|
||||
onChange={(e) => setTextTitle(e.target.value)}
|
||||
placeholder="标题(可选)"
|
||||
className="w-full rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary"
|
||||
/>
|
||||
<textarea
|
||||
value={textContent}
|
||||
onChange={(e) => setTextContent(e.target.value)}
|
||||
placeholder="在此粘贴或输入文字内容…"
|
||||
className="flex-1 resize-none rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary"
|
||||
/>
|
||||
{textError && <p className="text-xs text-destructive">{textError}</p>}
|
||||
<div className="flex justify-end gap-2">
|
||||
<button
|
||||
onClick={() => setPanel("sources")}
|
||||
className="rounded-lg border border-border px-4 py-2 text-sm text-muted-foreground hover:bg-muted"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
disabled={!textContent.trim() || submittingText}
|
||||
onClick={() => void handleTextSubmit()}
|
||||
className="flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
|
||||
>
|
||||
{submittingText && <Loader2 className="size-3.5 animate-spin" />}
|
||||
添加来源
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
@@ -232,7 +284,7 @@ function SourcesDialog({
|
||||
// ── 主页面 ──────────────────────────────────────────────
|
||||
export default function StudioNotebookDetailPage() {
|
||||
const { notebookId } = useParams<{ notebookId: string }>();
|
||||
const { notebooks, isLoading } = useStudioNotebooks();
|
||||
const { notebooks, isLoading, token: studioToken } = useStudioNotebooks(); // token 用于跳转 callback
|
||||
const { models } = useModels();
|
||||
const queryClient = useQueryClient();
|
||||
const [sourcesOpen, setSourcesOpen] = useState(false);
|
||||
@@ -243,6 +295,8 @@ export default function StudioNotebookDetailPage() {
|
||||
// null = 显示历史线程列表;string = 显示该线程的聊天
|
||||
const [activeThreadId, setActiveThreadId] = useState<string | null>(null);
|
||||
const [citationChunkId, setCitationChunkId] = useState<number | null>(null);
|
||||
const [threadsExpanded, setThreadsExpanded] = useState(false);
|
||||
const THREADS_LIMIT = 5;
|
||||
const [citationDoc, setCitationDoc] = useState<DocumentWithChunks | null>(null);
|
||||
const [citationLoading, setCitationLoading] = useState(false);
|
||||
|
||||
@@ -333,7 +387,7 @@ export default function StudioNotebookDetailPage() {
|
||||
className="pointer-events-none absolute inset-0"
|
||||
style={{
|
||||
background:
|
||||
"radial-gradient(ellipse 60% 50% at 50% 60%, hsl(var(--primary) / 0.12) 0%, transparent 70%)",
|
||||
"linear-gradient(145deg, hsl(var(--primary) / 0.22) 0%, hsl(var(--primary) / 0.10) 45%, transparent 80%)",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@@ -357,75 +411,156 @@ export default function StudioNotebookDetailPage() {
|
||||
</div>
|
||||
<span className="text-sm font-medium text-foreground">{notebook.name}</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setSourcesOpen(true)}
|
||||
className="flex items-center gap-1.5 rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/70"
|
||||
>
|
||||
<Files className="size-3" />
|
||||
<span>{notebook.source_count} 个来源</span>
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
<a
|
||||
href={`${import.meta.env.VITE_AIPI_FRONTEND_URL}/auth/callback?token=${studioToken ?? ""}&redirect=/dashboard/${notebookId}/new-chat`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="flex items-center gap-1.5 rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/70"
|
||||
>
|
||||
<BookOpen className="size-3" />
|
||||
<span>我的笔记</span>
|
||||
</a>
|
||||
<button
|
||||
onClick={() => setSourcesOpen(true)}
|
||||
className="flex items-center gap-1.5 rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/70"
|
||||
>
|
||||
<Files className="size-3" />
|
||||
<span>{notebook.source_count} 个来源</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 列表视图:笔记本标题 + 历史线程列表 */}
|
||||
{!isChatView && (
|
||||
<div className="relative z-10 flex flex-1 flex-col items-center px-8 py-10 overflow-y-auto">
|
||||
<div className="flex size-16 items-center justify-center rounded-2xl bg-muted text-4xl">
|
||||
{notebook.avatar_url ? (
|
||||
<img src={notebook.avatar_url} alt="" className="size-10 rounded-xl object-contain" />
|
||||
) : (
|
||||
<Files className="size-8 text-muted-foreground" />
|
||||
<div className="relative z-10 flex flex-1 flex-col overflow-hidden">
|
||||
{/* 右上角跳转按钮 */}
|
||||
<a
|
||||
href={`${import.meta.env.VITE_AIPI_FRONTEND_URL}/auth/callback?token=${studioToken ?? ""}&redirect=/dashboard/${notebookId}/new-chat`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="absolute right-6 top-4 z-10 flex items-center gap-1.5 rounded-full bg-muted/70 px-3 py-1.5 text-xs text-muted-foreground backdrop-blur transition-colors hover:bg-muted"
|
||||
>
|
||||
<BookOpen className="size-3.5" />
|
||||
<span>我的笔记</span>
|
||||
</a>
|
||||
|
||||
{/* 垂直居中主区域:图标 → 标题 → 来源 → 输入框 → 空状态/历史 */}
|
||||
<div className="flex flex-1 flex-col items-center justify-center overflow-y-auto px-8 pb-12 pt-16">
|
||||
<div className="flex size-14 items-center justify-center leading-none select-none">
|
||||
{notebook.avatar_url ? (
|
||||
<img src={notebook.avatar_url} alt="" className="size-12 rounded-xl object-contain" />
|
||||
) : (
|
||||
<Files className="size-10 text-foreground/50" />
|
||||
)}
|
||||
</div>
|
||||
<h1 className="mt-5 max-w-xl text-center text-3xl font-normal leading-snug text-foreground">
|
||||
{notebook.name}
|
||||
</h1>
|
||||
<button
|
||||
onClick={() => setSourcesOpen(true)}
|
||||
className="mt-4 flex cursor-pointer items-center gap-2 rounded-full bg-muted/70 px-4 py-2 text-sm font-medium text-muted-foreground backdrop-blur transition-colors hover:bg-muted"
|
||||
>
|
||||
<Files className="size-3.5" />
|
||||
<span>{notebook.source_count} 个来源</span>
|
||||
</button>
|
||||
|
||||
{/* 输入框(列表视图内联) */}
|
||||
<form
|
||||
onSubmit={(e) => { void handleSend(e); }}
|
||||
className="relative z-10 mt-8 flex w-full max-w-[680px] items-center gap-3 rounded-full bg-card px-5 py-3.5 shadow-md ring-1 ring-border"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSourcesOpen(true)}
|
||||
className="shrink-0 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Plus className="size-5" />
|
||||
</button>
|
||||
<input
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="问问 AI..."
|
||||
disabled={isStreaming}
|
||||
className="flex-1 bg-transparent text-[15px] text-foreground placeholder:text-muted-foreground outline-none disabled:opacity-50"
|
||||
/>
|
||||
{isStreaming && <Loader2 className="size-4 shrink-0 animate-spin text-muted-foreground" />}
|
||||
{models.length > 0 && (
|
||||
<Select value={selectedModel} onValueChange={setSelectedModel}>
|
||||
<SelectTrigger className="h-7 w-auto shrink-0 gap-1 rounded-full border-0 bg-transparent px-2 text-sm text-muted-foreground shadow-none focus:ring-0 hover:bg-muted/60">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{models.map((m) => (
|
||||
<SelectItem key={m.name} value={m.name} className="text-xs">
|
||||
{m.display_name || m.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
</form>
|
||||
|
||||
{/* 空状态提示 */}
|
||||
{(!notebookThreads || notebookThreads.length === 0) && (
|
||||
<div className="mt-8 flex items-center gap-2 text-sm text-foreground/40">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
||||
</svg>
|
||||
笔记本对话会显示在这里
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 历史线程列表 */}
|
||||
{notebookThreads && notebookThreads.length > 0 && (
|
||||
<div className="mt-8 w-full max-w-[680px] flex flex-col gap-2">
|
||||
<p className="mb-1 text-xs font-medium text-foreground/40">历史对话</p>
|
||||
<div className="flex flex-col gap-2 overflow-y-auto" style={{ maxHeight: "260px" }}>
|
||||
{(threadsExpanded ? notebookThreads : notebookThreads.slice(0, THREADS_LIMIT)).map((t) => {
|
||||
const values = t.values as Record<string, unknown> | undefined;
|
||||
const msgs = values?.messages as Array<{ type: string; content: unknown }> | undefined;
|
||||
const firstHuman = msgs?.find((m) => m.type === "human");
|
||||
const rawContent = firstHuman?.content;
|
||||
const preview =
|
||||
typeof rawContent === "string"
|
||||
? rawContent.slice(0, 60)
|
||||
: Array.isArray(rawContent)
|
||||
? String((rawContent[0] as { text?: string })?.text ?? "").slice(0, 60)
|
||||
: "对话";
|
||||
const title = (values?.title as string | undefined) || preview || "对话";
|
||||
const time = new Date(t.updated_at ?? "").toLocaleString("zh-CN", {
|
||||
month: "numeric",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
return (
|
||||
<button
|
||||
key={t.thread_id}
|
||||
onClick={() => {
|
||||
setActiveThreadId(t.thread_id);
|
||||
setThreadId(t.thread_id);
|
||||
}}
|
||||
className="flex items-center justify-between rounded-xl bg-muted/50 px-4 py-3 text-left transition-colors hover:bg-muted"
|
||||
>
|
||||
<span className="truncate text-sm font-medium text-foreground">{title}</span>
|
||||
<span className="ml-4 shrink-0 text-xs text-foreground/50">{time}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{notebookThreads.length > THREADS_LIMIT && (
|
||||
<button
|
||||
onClick={() => setThreadsExpanded((v) => !v)}
|
||||
className="mt-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
{threadsExpanded ? "收起" : `查看全部 ${notebookThreads.length} 条对话`}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<h1 className="mt-4 max-w-xl text-2xl font-semibold leading-snug text-foreground text-center">
|
||||
{notebook.name}
|
||||
</h1>
|
||||
<button
|
||||
onClick={() => setSourcesOpen(true)}
|
||||
className="mt-3 flex cursor-pointer items-center gap-2 rounded-full bg-muted px-4 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-muted/70"
|
||||
>
|
||||
<Files className="size-3.5" />
|
||||
<span>{notebook.source_count} 个来源</span>
|
||||
</button>
|
||||
|
||||
{/* 历史线程列表 */}
|
||||
{notebookThreads && notebookThreads.length > 0 && (
|
||||
<div className="mt-8 w-full max-w-lg flex flex-col gap-2">
|
||||
<p className="mb-1 text-xs font-medium text-muted-foreground">历史对话</p>
|
||||
{notebookThreads.map((t) => {
|
||||
const values = t.values as Record<string, unknown> | undefined;
|
||||
const msgs = values?.messages as Array<{ type: string; content: unknown }> | undefined;
|
||||
const firstHuman = msgs?.find((m) => m.type === "human");
|
||||
const rawContent = firstHuman?.content;
|
||||
const preview =
|
||||
typeof rawContent === "string"
|
||||
? rawContent.slice(0, 60)
|
||||
: Array.isArray(rawContent)
|
||||
? String((rawContent[0] as { text?: string })?.text ?? "").slice(0, 60)
|
||||
: "对话";
|
||||
const title = (values?.title as string | undefined) || preview || "对话";
|
||||
const time = new Date(t.updated_at ?? "").toLocaleString("zh-CN", {
|
||||
month: "numeric",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
return (
|
||||
<button
|
||||
key={t.thread_id}
|
||||
onClick={() => {
|
||||
setActiveThreadId(t.thread_id);
|
||||
setThreadId(t.thread_id);
|
||||
}}
|
||||
className="flex items-center justify-between rounded-xl bg-muted px-4 py-3 text-left transition-colors hover:bg-muted/70"
|
||||
>
|
||||
<span className="truncate text-sm font-medium text-foreground">{title}</span>
|
||||
<span className="ml-4 shrink-0 text-xs text-muted-foreground">{time}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -457,11 +592,11 @@ export default function StudioNotebookDetailPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 输入框区域 */}
|
||||
<div className={`shrink-0 px-6 ${isChatView ? "border-t border-border py-4" : "pb-12"}`}>
|
||||
{/* 聊天视图的底部输入框 */}
|
||||
<div className={`relative z-10 shrink-0 px-6 ${isChatView ? "border-t border-border py-4" : "hidden"}`}>
|
||||
<form
|
||||
onSubmit={(e) => { void handleSend(e); }}
|
||||
className="mx-auto flex w-[560px] items-center gap-3 rounded-2xl bg-card px-5 py-4 shadow-sm ring-1 ring-border"
|
||||
className="mx-auto flex max-w-[720px] items-center gap-3 rounded-full bg-card px-5 py-3.5 shadow-md ring-1 ring-border"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@@ -470,9 +605,17 @@ export default function StudioNotebookDetailPage() {
|
||||
>
|
||||
<Plus className="size-5" />
|
||||
</button>
|
||||
<input
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="问问 AI..."
|
||||
disabled={isStreaming}
|
||||
className="flex-1 bg-transparent text-[15px] text-foreground placeholder:text-muted-foreground outline-none disabled:opacity-50"
|
||||
/>
|
||||
{isStreaming && <Loader2 className="size-4 shrink-0 animate-spin text-muted-foreground" />}
|
||||
{models.length > 0 && (
|
||||
<Select value={selectedModel} onValueChange={setSelectedModel}>
|
||||
<SelectTrigger className="h-7 w-auto shrink-0 gap-1 rounded-lg border-0 bg-muted px-2 text-xs text-muted-foreground shadow-none focus:ring-0">
|
||||
<SelectTrigger className="h-7 w-auto shrink-0 gap-1 rounded-full border-0 bg-transparent px-2 text-sm text-muted-foreground shadow-none focus:ring-0 hover:bg-muted/60">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
@@ -484,24 +627,6 @@ export default function StudioNotebookDetailPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
<input
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="问问 AI..."
|
||||
disabled={isStreaming}
|
||||
className="flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none disabled:opacity-50"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={!input.trim() || isStreaming}
|
||||
className="shrink-0 text-muted-foreground transition-colors hover:text-foreground disabled:opacity-30"
|
||||
>
|
||||
{isStreaming ? (
|
||||
<Loader2 className="size-5 animate-spin" />
|
||||
) : (
|
||||
<Send className="size-5" />
|
||||
)}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Files, Loader2, Plus } from "lucide-react";
|
||||
import { Files, Loader2, Plus, MoreVertical, Pencil, Trash2 } from "lucide-react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { useStudioNotebooks } from "@/core/studio/hooks";
|
||||
import { createSearchSpace } from "@/core/studio/api";
|
||||
import { createSearchSpace, deleteSearchSpace, renameSearchSpace } from "@/core/studio/api";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
import type { StudioNotebook } from "@/core/studio/types";
|
||||
import {
|
||||
@@ -15,81 +15,175 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
function NotebookCardSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-3 rounded-2xl bg-card p-4">
|
||||
<div className="size-10 animate-pulse rounded-xl bg-muted" />
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<div className="h-4 w-3/4 animate-pulse rounded bg-muted" />
|
||||
<div className="h-3 w-1/3 animate-pulse rounded bg-muted" />
|
||||
<div className="flex flex-col rounded-[20px] bg-[#f2f2f2] p-5" style={{ minHeight: 180 }}>
|
||||
<div className="size-10 animate-pulse rounded-xl bg-[#e0e0e0]" />
|
||||
<div className="mt-auto flex flex-col gap-1.5 pt-8">
|
||||
<div className="h-4 w-3/4 animate-pulse rounded bg-[#e0e0e0]" />
|
||||
<div className="h-3 w-1/3 animate-pulse rounded bg-[#e0e0e0]" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NotebookCard({ nb }: { nb: StudioNotebook }) {
|
||||
function NotebookCard({
|
||||
nb,
|
||||
onRename,
|
||||
onDelete,
|
||||
}: {
|
||||
nb: StudioNotebook;
|
||||
onRename: (nb: StudioNotebook) => void;
|
||||
onDelete: (nb: StudioNotebook) => void;
|
||||
}) {
|
||||
return (
|
||||
<Link
|
||||
to={`/page/workspace/studio/notebooks/${nb.id}`}
|
||||
className="group flex flex-col gap-3 rounded-2xl bg-card p-4 transition-colors hover:bg-muted ring-1 ring-border"
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex size-10 items-center justify-center rounded-xl bg-muted text-xl group-hover:bg-background">
|
||||
{nb.avatar_url ? (
|
||||
<img src={nb.avatar_url} alt="" className="size-6 rounded object-contain" />
|
||||
) : (
|
||||
<Files className="size-5 text-muted-foreground" />
|
||||
)}
|
||||
<div className="group relative flex flex-col rounded-[20px] bg-[#f2f2f2] transition-colors hover:bg-[#e8e8e8]" style={{ minHeight: 180 }}>
|
||||
<Link
|
||||
to={`/page/workspace/studio/notebooks/${nb.id}`}
|
||||
className="flex flex-1 flex-col p-5"
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex size-11 items-center justify-center text-3xl leading-none select-none">
|
||||
{nb.avatar_url ? (
|
||||
<img src={nb.avatar_url} alt="" className="size-8 rounded object-contain" />
|
||||
) : (
|
||||
<Files className="size-7 text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
{/* spacer so title stays below icon */}
|
||||
<div className="size-7" />
|
||||
</div>
|
||||
<div className="mt-auto flex flex-col gap-1 pt-8">
|
||||
<span className="line-clamp-2 text-[15px] font-medium leading-snug text-[#1f1f1f]">
|
||||
{nb.name}
|
||||
</span>
|
||||
<span className="text-[13px] text-[#666]">{nb.source_count} 个来源</span>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
{/* three-dot menu — absolute so it doesn't shift layout */}
|
||||
<div className="absolute right-4 top-4">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
className="flex size-7 items-center justify-center rounded-full text-[#888] opacity-0 transition-opacity group-hover:opacity-100 hover:bg-black/10"
|
||||
onClick={(e) => e.preventDefault()}
|
||||
>
|
||||
<MoreVertical className="size-4" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-36">
|
||||
<DropdownMenuItem onClick={() => onRename(nb)}>
|
||||
<Pencil className="mr-2 size-4" />
|
||||
重命名
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => onDelete(nb)}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
<Trash2 className="mr-2 size-4" />
|
||||
删除
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<span className="line-clamp-2 text-sm font-medium leading-snug text-foreground">
|
||||
{nb.name}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">{nb.source_count} 个来源</span>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function StudioNotebooksPage() {
|
||||
const { notebooks, isLoading, isError } = useStudioNotebooks();
|
||||
const queryClient = useQueryClient();
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [name, setName] = useState("");
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
const handleCreate = async () => {
|
||||
const trimmed = name.trim();
|
||||
// ── 新建 ──
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [createName, setCreateName] = useState("");
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [createError, setCreateError] = useState("");
|
||||
|
||||
// ── 重命名 ──
|
||||
const [renameTarget, setRenameTarget] = useState<StudioNotebook | null>(null);
|
||||
const [renameName, setRenameName] = useState("");
|
||||
const [renaming, setRenaming] = useState(false);
|
||||
const [renameError, setRenameError] = useState("");
|
||||
|
||||
// ── 删除 ──
|
||||
const [deleteTarget, setDeleteTarget] = useState<StudioNotebook | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [deleteError, setDeleteError] = useState("");
|
||||
|
||||
function getToken() {
|
||||
const email = getStoredAuth()?.email ?? "";
|
||||
const token = queryClient.getQueryData<string>(["studio", "token", email]);
|
||||
if (!token) throw new Error("未登录或 token 已过期,请刷新页面");
|
||||
return token;
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
const trimmed = createName.trim();
|
||||
if (!trimmed) return;
|
||||
setCreating(true);
|
||||
setError("");
|
||||
setCreateError("");
|
||||
try {
|
||||
const email = getStoredAuth()?.email ?? "";
|
||||
const token = queryClient.getQueryData<string>(["studio", "token", email]);
|
||||
if (!token) throw new Error("未登录或 token 已过期,请刷新页面");
|
||||
await createSearchSpace(trimmed, token);
|
||||
setDialogOpen(false);
|
||||
setName("");
|
||||
// 刷新笔记本列表
|
||||
await createSearchSpace(trimmed, getToken());
|
||||
setCreateOpen(false);
|
||||
setCreateName("");
|
||||
await queryClient.invalidateQueries({ queryKey: ["studio", "notebooks"] });
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "创建失败");
|
||||
setCreateError(e instanceof Error ? e.message : "创建失败");
|
||||
} finally {
|
||||
setCreating(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function handleRename() {
|
||||
if (!renameTarget) return;
|
||||
const trimmed = renameName.trim();
|
||||
if (!trimmed) return;
|
||||
setRenaming(true);
|
||||
setRenameError("");
|
||||
try {
|
||||
await renameSearchSpace(renameTarget.id, trimmed, getToken());
|
||||
setRenameTarget(null);
|
||||
await queryClient.invalidateQueries({ queryKey: ["studio", "notebooks"] });
|
||||
} catch (e) {
|
||||
setRenameError(e instanceof Error ? e.message : "重命名失败");
|
||||
} finally {
|
||||
setRenaming(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!deleteTarget) return;
|
||||
setDeleting(true);
|
||||
setDeleteError("");
|
||||
try {
|
||||
await deleteSearchSpace(deleteTarget.id, getToken());
|
||||
setDeleteTarget(null);
|
||||
await queryClient.invalidateQueries({ queryKey: ["studio", "notebooks"] });
|
||||
} catch (e) {
|
||||
setDeleteError(e instanceof Error ? e.message : "删除失败");
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-full bg-background p-8">
|
||||
{/* Header */}
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-foreground">笔记本</h1>
|
||||
<button
|
||||
onClick={() => { setDialogOpen(true); setError(""); setName(""); }}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
onClick={() => { setCreateOpen(true); setCreateError(""); setCreateName(""); }}
|
||||
className="flex items-center gap-1.5 rounded-full bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
新建笔记本
|
||||
@@ -100,13 +194,22 @@ export default function StudioNotebooksPage() {
|
||||
<p className="text-sm text-muted-foreground">加载笔记本失败,请稍后重试。</p>
|
||||
)}
|
||||
|
||||
{/* Grid */}
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4">
|
||||
{isLoading
|
||||
? Array.from({ length: 8 }).map((_, i) => <NotebookCardSkeleton key={i} />)
|
||||
: notebooks.map((nb) => <NotebookCard key={nb.id} nb={nb} />)}
|
||||
: notebooks.map((nb) => (
|
||||
<NotebookCard
|
||||
key={nb.id}
|
||||
nb={nb}
|
||||
onRename={(nb) => { setRenameTarget(nb); setRenameName(nb.name); setRenameError(""); }}
|
||||
onDelete={(nb) => { setDeleteTarget(nb); setDeleteError(""); }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<Dialog open={dialogOpen} onOpenChange={(v) => !creating && setDialogOpen(v)}>
|
||||
{/* ── 新建 Dialog ── */}
|
||||
<Dialog open={createOpen} onOpenChange={(v) => !creating && setCreateOpen(v)}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>新建笔记本</DialogTitle>
|
||||
@@ -114,25 +217,78 @@ export default function StudioNotebooksPage() {
|
||||
<div className="flex flex-col gap-4 pt-2">
|
||||
<input
|
||||
autoFocus
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
value={createName}
|
||||
onChange={(e) => setCreateName(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === "Enter") void handleCreate(); }}
|
||||
placeholder="笔记本名称"
|
||||
disabled={creating}
|
||||
className="w-full rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary disabled:opacity-50"
|
||||
/>
|
||||
{error && <p className="text-xs text-destructive">{error}</p>}
|
||||
{createError && <p className="text-xs text-destructive">{createError}</p>}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" size="sm" disabled={creating} onClick={() => setDialogOpen(false)}>
|
||||
取消
|
||||
</Button>
|
||||
<Button size="sm" disabled={!name.trim() || creating} onClick={() => void handleCreate()}>
|
||||
<Button variant="outline" size="sm" disabled={creating} onClick={() => setCreateOpen(false)}>取消</Button>
|
||||
<Button size="sm" disabled={!createName.trim() || creating} onClick={() => void handleCreate()}>
|
||||
{creating ? <Loader2 className="size-4 animate-spin" /> : "创建"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* ── 重命名 Dialog ── */}
|
||||
<Dialog open={!!renameTarget} onOpenChange={(v) => !renaming && !v && setRenameTarget(null)}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>重命名笔记本</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4 pt-2">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex size-12 flex-shrink-0 items-center justify-center text-3xl">
|
||||
{renameTarget?.avatar_url
|
||||
? <img src={renameTarget.avatar_url} alt="" className="size-10 rounded object-contain" />
|
||||
: <Files className="size-8 text-muted-foreground" />}
|
||||
</div>
|
||||
<input
|
||||
autoFocus
|
||||
value={renameName}
|
||||
onChange={(e) => setRenameName(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === "Enter") void handleRename(); }}
|
||||
disabled={renaming}
|
||||
className="flex-1 rounded-lg border-2 border-foreground bg-background px-3 py-2 text-sm outline-none disabled:opacity-50"
|
||||
/>
|
||||
</div>
|
||||
{renameError && <p className="text-xs text-destructive">{renameError}</p>}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" size="sm" disabled={renaming} onClick={() => setRenameTarget(null)}>取消</Button>
|
||||
<Button size="sm" disabled={!renameName.trim() || renaming} onClick={() => void handleRename()}>
|
||||
{renaming ? <Loader2 className="size-4 animate-spin" /> : "保存"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* ── 删除确认 Dialog ── */}
|
||||
<Dialog open={!!deleteTarget} onOpenChange={(v) => !deleting && !v && setDeleteTarget(null)}>
|
||||
<DialogContent className="sm:max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>删除笔记本</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4 pt-1">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
确定要删除{deleteTarget ? <span className="font-medium text-foreground">「{deleteTarget.name}」</span> : ""}吗?
|
||||
删除后笔记本内所有来源数据将一并移除,且无法恢复。
|
||||
</p>
|
||||
{deleteError && <p className="text-xs text-destructive">{deleteError}</p>}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" size="sm" disabled={deleting} onClick={() => setDeleteTarget(null)}>取消</Button>
|
||||
<Button variant="destructive" size="sm" disabled={deleting} onClick={() => void handleDelete()}>
|
||||
{deleting ? <Loader2 className="size-4 animate-spin" /> : "删除"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -47,18 +47,27 @@ export function WorkspaceLayout({
|
||||
pageSidebarHidden = false,
|
||||
headerHidden = false,
|
||||
compactWorkspaceSidebar = false,
|
||||
pageSidebarDark = false,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
pageSidebarCollapsed: boolean;
|
||||
pageSidebarHidden?: boolean;
|
||||
headerHidden?: boolean;
|
||||
compactWorkspaceSidebar?: boolean;
|
||||
pageSidebarDark?: boolean;
|
||||
}) {
|
||||
const pageSidebarWidth = pageSidebarHidden
|
||||
? "0rem"
|
||||
: pageSidebarCollapsed
|
||||
? "4rem"
|
||||
: "16rem";
|
||||
: pageSidebarDark
|
||||
// dark page sidebar:
|
||||
// 展开: 视觉右边界 108px(外框 98 + 内层 translateX 10)+ 10px gap = 118px
|
||||
// 收起: sidebar 主体完全消失(连同其占据的宽度),workspace 内容铺到屏幕左边;
|
||||
// 左下角浮动按钮是 fixed,叠在主内容上不影响 layout
|
||||
// 与 PageRoutes.tsx 的 main pl-[118px] / pl-0 保持一致
|
||||
? (pageSidebarCollapsed ? "0rem" : "118px")
|
||||
: pageSidebarCollapsed
|
||||
? "4rem"
|
||||
: "16rem";
|
||||
|
||||
return (
|
||||
<SidebarProvider
|
||||
@@ -97,17 +106,20 @@ export default function WorkspaceRoutes({
|
||||
pageSidebarHidden = false,
|
||||
headerHidden = false,
|
||||
compactWorkspaceSidebar = false,
|
||||
pageSidebarDark = false,
|
||||
}: {
|
||||
pageSidebarCollapsed?: boolean;
|
||||
pageSidebarHidden?: boolean;
|
||||
headerHidden?: boolean;
|
||||
compactWorkspaceSidebar?: boolean;
|
||||
pageSidebarDark?: boolean;
|
||||
}) {
|
||||
const layoutProps = {
|
||||
pageSidebarCollapsed,
|
||||
pageSidebarHidden,
|
||||
headerHidden,
|
||||
compactWorkspaceSidebar,
|
||||
pageSidebarDark,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* Backend-persisted draft storage for /page/roundtable/planning.
|
||||
*
|
||||
* One draft = one full roundtable session (Step 1 intent + Step 2 multi-agent
|
||||
* roundtable). Persisted server-side (MySQL) bound to the logged-in user, so it
|
||||
* follows the account across devices/sessions — replacing the old browser-only
|
||||
* `localStorage` storage (see git history of `utils/drafts.ts`).
|
||||
*
|
||||
* The list endpoint returns lightweight metadata only; the full step1/step2
|
||||
* snapshots are fetched on demand via {@link getDraft}. This keeps the history
|
||||
* dropdown cheap and guarantees a load always reads the freshest server copy
|
||||
* (the old localStorage path loaded from a possibly-stale in-memory array).
|
||||
*/
|
||||
|
||||
import { apiFetch } from "@/core/api/fetch-client";
|
||||
import { getBackendBaseURL } from "@/core/config";
|
||||
|
||||
import type { IntentSummary } from "@/roundtable-planning/api/intent";
|
||||
import type { ThreadIdMap } from "@/roundtable-planning/api/multi-agent";
|
||||
|
||||
/**
|
||||
* Step 1 snapshot. Shapes for the chat / timeline lists stay loose (`unknown[]`)
|
||||
* because their inline types in the hooks are wide; the hook casts on hydrate.
|
||||
*/
|
||||
export interface DraftStep1Snapshot {
|
||||
intentThreadId: string | null;
|
||||
intentReady: IntentSummary | null;
|
||||
interactiveMessages: unknown[];
|
||||
timelineEntries: unknown[];
|
||||
}
|
||||
|
||||
export interface DraftStep2Snapshot {
|
||||
/**
|
||||
* The seats actually selected for this session. Restored on load so the
|
||||
* Step 2/3 「参与角色」panel shows the chosen agents instead of the default 6.
|
||||
* Optional — drafts saved before 2026-06 won't carry it.
|
||||
*/
|
||||
selectedAgents?: Array<{ agent_id: string; name: string }>;
|
||||
threadIds: ThreadIdMap | null;
|
||||
coordinatorName: string | null;
|
||||
step2RoundtableDialogues: unknown[];
|
||||
lastLeaderContent: string;
|
||||
hasConsensus: boolean;
|
||||
consensusPercentage: number;
|
||||
budgetLimit: number;
|
||||
/** Per-seat stub AI messages for the sandbox `write-file:` virtual URL loader. */
|
||||
seatStubMessages?: Record<string, unknown[]>;
|
||||
}
|
||||
|
||||
/** Lightweight metadata row returned by the list endpoint. */
|
||||
export interface DraftMeta {
|
||||
id: string;
|
||||
/** Auto-derived task summary (objective → first user message → timestamp). */
|
||||
title: string;
|
||||
furthestStep: 1 | 2 | 3;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
/** Full record including the step snapshots. */
|
||||
export interface DraftRecord extends DraftMeta {
|
||||
step1: DraftStep1Snapshot | null;
|
||||
step2: DraftStep2Snapshot | null;
|
||||
}
|
||||
|
||||
/** Fields accepted when creating a draft. */
|
||||
export interface DraftCreatePayload {
|
||||
/** Optional stable id so the client can keep one id across create + updates. */
|
||||
id?: string;
|
||||
title: string;
|
||||
furthestStep: 1 | 2 | 3;
|
||||
step1: DraftStep1Snapshot;
|
||||
step2: DraftStep2Snapshot;
|
||||
}
|
||||
|
||||
/** Partial update — send only what changed. Omitting `title` preserves a rename. */
|
||||
export interface DraftUpdatePayload {
|
||||
title?: string;
|
||||
furthestStep?: 1 | 2 | 3;
|
||||
step1?: DraftStep1Snapshot;
|
||||
step2?: DraftStep2Snapshot;
|
||||
}
|
||||
|
||||
const BASE = () => `${getBackendBaseURL()}/api/roundtable-drafts`;
|
||||
|
||||
async function readJson<T>(res: Response, ctx: string): Promise<T> {
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(`${ctx} failed (${res.status}): ${text}`);
|
||||
}
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
// ── server ⇄ client field mapping ──────────────────────────────────────────
|
||||
// Backend uses snake_case (furthest_step / created_at / updated_at); the rest
|
||||
// of the frontend reads camelCase. Map at this boundary so callers stay clean.
|
||||
|
||||
interface ServerDraftMeta {
|
||||
id: string;
|
||||
title: string;
|
||||
furthest_step: number;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
}
|
||||
|
||||
interface ServerDraftFull extends ServerDraftMeta {
|
||||
step1: DraftStep1Snapshot | null;
|
||||
step2: DraftStep2Snapshot | null;
|
||||
}
|
||||
|
||||
function toMeta(s: ServerDraftMeta): DraftMeta {
|
||||
const step = Math.min(3, Math.max(1, s.furthest_step || 1)) as 1 | 2 | 3;
|
||||
return {
|
||||
id: s.id,
|
||||
title: s.title ?? "",
|
||||
furthestStep: step,
|
||||
createdAt: s.created_at ?? "",
|
||||
updatedAt: s.updated_at ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
function toRecord(s: ServerDraftFull): DraftRecord {
|
||||
return { ...toMeta(s), step1: s.step1 ?? null, step2: s.step2 ?? null };
|
||||
}
|
||||
|
||||
function fromCreate(p: DraftCreatePayload) {
|
||||
return {
|
||||
...(p.id ? { id: p.id } : {}),
|
||||
title: p.title,
|
||||
furthest_step: p.furthestStep,
|
||||
step1: p.step1,
|
||||
step2: p.step2,
|
||||
};
|
||||
}
|
||||
|
||||
function fromUpdate(p: DraftUpdatePayload) {
|
||||
const out: Record<string, unknown> = {};
|
||||
if (p.title !== undefined) out.title = p.title;
|
||||
if (p.furthestStep !== undefined) out.furthest_step = p.furthestStep;
|
||||
if (p.step1 !== undefined) out.step1 = p.step1;
|
||||
if (p.step2 !== undefined) out.step2 = p.step2;
|
||||
return out;
|
||||
}
|
||||
|
||||
// ── CRUD ────────────────────────────────────────────────────────────────────
|
||||
|
||||
/** List the current user's drafts, newest first (lightweight metadata only). */
|
||||
export async function listDrafts(): Promise<DraftMeta[]> {
|
||||
const res = await apiFetch(BASE(), { method: "GET" });
|
||||
const data = await readJson<{ drafts: ServerDraftMeta[] }>(res, "list drafts");
|
||||
return (data.drafts ?? []).map(toMeta);
|
||||
}
|
||||
|
||||
/** Fetch the full draft (incl. step1/step2). Returns null on 404. */
|
||||
export async function getDraft(id: string): Promise<DraftRecord | null> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(id)}`, { method: "GET" });
|
||||
if (res.status === 404) return null;
|
||||
const data = await readJson<ServerDraftFull>(res, "get draft");
|
||||
return toRecord(data);
|
||||
}
|
||||
|
||||
export async function createDraft(payload: DraftCreatePayload): Promise<DraftRecord> {
|
||||
const res = await apiFetch(BASE(), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(fromCreate(payload)),
|
||||
});
|
||||
const data = await readJson<ServerDraftFull>(res, "create draft");
|
||||
return toRecord(data);
|
||||
}
|
||||
|
||||
export async function updateDraft(id: string, patch: DraftUpdatePayload): Promise<DraftRecord | null> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(id)}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(fromUpdate(patch)),
|
||||
});
|
||||
if (res.status === 404) return null;
|
||||
const data = await readJson<ServerDraftFull>(res, "update draft");
|
||||
return toRecord(data);
|
||||
}
|
||||
|
||||
export async function deleteDraft(id: string): Promise<void> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(id)}`, { method: "DELETE" });
|
||||
if (!res.ok && res.status !== 404) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(`delete draft failed (${res.status}): ${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a short task-summary name from whatever the user supplied so far.
|
||||
* Preference: intent objective → first user message → timestamp. Trimmed to
|
||||
* ~40 chars so dropdown rows stay scannable. (Ported from the old utils/drafts.)
|
||||
*/
|
||||
export function deriveDraftName(args: {
|
||||
intentReady?: IntentSummary | null;
|
||||
interactiveMessages?: unknown[];
|
||||
}): string {
|
||||
const MAX = 40;
|
||||
const truncate = (s: string) => (s.length > MAX ? s.slice(0, MAX) + "…" : s);
|
||||
|
||||
const objective = args.intentReady?.objective?.trim();
|
||||
if (objective) return truncate(objective);
|
||||
|
||||
if (Array.isArray(args.interactiveMessages)) {
|
||||
for (const m of args.interactiveMessages) {
|
||||
if (!m || typeof m !== "object") continue;
|
||||
const obj = m as Record<string, unknown>;
|
||||
if (obj.sender === "user" && typeof obj.content === "string" && obj.content.trim()) {
|
||||
return truncate(obj.content.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return `未命名草稿 ${new Date().toLocaleString("zh-CN", { hour12: false })}`;
|
||||
}
|
||||
@@ -160,6 +160,14 @@ export interface StreamIntentRequest {
|
||||
toolName?: string,
|
||||
args?: Record<string, unknown>,
|
||||
) => void;
|
||||
/**
|
||||
* Fires for every `ask_clarification` tool message parsed out of the live
|
||||
* stream (the intent agent may emit several in a single turn). Lets the UI
|
||||
* surface each assistance question in real-time instead of waiting for the
|
||||
* terminal frame — which only carries the *first* question. `index` is the
|
||||
* 0-based arrival order within this turn.
|
||||
*/
|
||||
onClarification?: (clarification: ClarificationPayload, index: number) => void;
|
||||
}
|
||||
|
||||
export interface StreamIntentResult {
|
||||
@@ -172,8 +180,16 @@ export interface StreamIntentResult {
|
||||
/**
|
||||
* Populated when the intent agent called ask_clarification — render option
|
||||
* cards + custom input instead of treating the turn as plain text only.
|
||||
* This is the *first* clarification (kept for backward compat); prefer
|
||||
* `clarifications` which carries the full set.
|
||||
*/
|
||||
clarification: ClarificationPayload | null;
|
||||
/**
|
||||
* All `ask_clarification` questions the agent asked this turn, in arrival
|
||||
* order. Collected from the live `type:"tool"` frames (the terminal frame
|
||||
* only carries the first). Empty unless status === "clarification".
|
||||
*/
|
||||
clarifications: ClarificationPayload[];
|
||||
/**
|
||||
* Populated only when status === "error" and the backend emitted a
|
||||
* structured diagnostic (new in `_diagnose_exception`). UI uses this to show
|
||||
@@ -241,6 +257,54 @@ function extractAiTextDelta(parsed: unknown): { text: string; id: string } | nul
|
||||
return { text, id };
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a live `type:"tool"` `ask_clarification` frame into a ClarificationPayload.
|
||||
*
|
||||
* The intent agent emits one such frame per question (ClarificationMiddleware
|
||||
* formats them), each carrying a fully-formed clarification in
|
||||
* `additional_kwargs.clarification` — options already normalized to
|
||||
* `{id, label}` objects, snake_case keys. Returns null for any other frame
|
||||
* (AI text chunks, tool_call_chunks, value snapshots).
|
||||
*/
|
||||
function extractClarificationToolMessage(
|
||||
parsed: unknown,
|
||||
): { payload: ClarificationPayload; toolCallId: string } | null {
|
||||
if (!Array.isArray(parsed) || parsed.length < 1) return null;
|
||||
const msg = parsed[0];
|
||||
if (!msg || typeof msg !== "object") return null;
|
||||
const obj = msg as Record<string, unknown>;
|
||||
if (String(obj.type ?? "").toLowerCase() !== "tool") return null;
|
||||
if (obj.name !== "ask_clarification") return null;
|
||||
const kwargs = obj.additional_kwargs;
|
||||
if (!kwargs || typeof kwargs !== "object") return null;
|
||||
const clar = (kwargs as Record<string, unknown>).clarification;
|
||||
if (!clar || typeof clar !== "object") return null;
|
||||
const c = clar as Record<string, unknown>;
|
||||
const toolCallId =
|
||||
typeof obj.tool_call_id === "string" && obj.tool_call_id
|
||||
? obj.tool_call_id
|
||||
: typeof obj.id === "string"
|
||||
? obj.id
|
||||
: "";
|
||||
const clarificationType =
|
||||
typeof c.clarification_type === "string" ? c.clarification_type : "";
|
||||
return {
|
||||
toolCallId,
|
||||
payload: {
|
||||
id: toolCallId || undefined,
|
||||
question: typeof c.question === "string" ? c.question : "",
|
||||
clarificationType,
|
||||
context: typeof c.context === "string" ? c.context : "",
|
||||
options: Array.isArray(c.options) ? c.options : [],
|
||||
allowCustom: c.allow_custom !== false,
|
||||
allowMultiple: resolveAllowMultiple(
|
||||
typeof c.allow_multiple === "boolean" ? c.allow_multiple : undefined,
|
||||
clarificationType,
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an SSE connection to /api/intent/stream and resolve when the upstream
|
||||
* stream completes. Each call is one user turn; reuse the same threadId
|
||||
@@ -288,9 +352,24 @@ export async function streamIntent(req: StreamIntentRequest): Promise<StreamInte
|
||||
content: "",
|
||||
summary: null,
|
||||
clarification: null,
|
||||
clarifications: [],
|
||||
errorDetail: null,
|
||||
};
|
||||
|
||||
// Clarifications collected live from `type:"tool"` frames, deduped by
|
||||
// tool_call_id. The terminal frame only carries the first question, so this
|
||||
// is the source of truth for multi-question turns.
|
||||
const seenClarificationIds = new Set<string>();
|
||||
const collectClarification = (payload: ClarificationPayload, toolCallId: string) => {
|
||||
const dedupeKey = toolCallId || `idx-${result.clarifications.length}`;
|
||||
if (seenClarificationIds.has(dedupeKey)) return;
|
||||
seenClarificationIds.add(dedupeKey);
|
||||
const index = result.clarifications.length;
|
||||
result.clarifications.push(payload);
|
||||
if (!result.clarification) result.clarification = payload;
|
||||
req.onClarification?.(payload, index);
|
||||
};
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
@@ -331,10 +410,15 @@ export async function streamIntent(req: StreamIntentRequest): Promise<StreamInte
|
||||
if (parsed.status === "error") {
|
||||
result.errorDetail = parseIntentErrorDetail(parsed.error_detail);
|
||||
}
|
||||
if (parsed.status === "clarification") {
|
||||
if (parsed.status === "clarification" && result.clarifications.length === 0) {
|
||||
// Fallback path: no live `type:"tool"` clarification frames were seen
|
||||
// (older backend, or single-question turn) — synthesize one from the
|
||||
// terminal frame so the UI still gets a card. When tool frames *were*
|
||||
// seen, `clarifications` already holds the full (possibly multi-question)
|
||||
// set and we keep it.
|
||||
const clarificationType =
|
||||
typeof parsed.clarification_type === "string" ? parsed.clarification_type : "";
|
||||
result.clarification = {
|
||||
const fallback: ClarificationPayload = {
|
||||
question: typeof parsed.question === "string" ? parsed.question : "",
|
||||
clarificationType,
|
||||
context:
|
||||
@@ -346,11 +430,22 @@ export async function streamIntent(req: StreamIntentRequest): Promise<StreamInte
|
||||
clarificationType,
|
||||
),
|
||||
};
|
||||
result.clarification = fallback;
|
||||
result.clarifications = [fallback];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lastEvent === "messages") {
|
||||
// `ask_clarification` tool result frame → collect + surface in real-time.
|
||||
// These carry the fully-formed clarification (one per question); the
|
||||
// agent may emit several in a single turn.
|
||||
const toolClar = extractClarificationToolMessage(parsed);
|
||||
if (toolClar) {
|
||||
collectClarification(toolClar.payload, toolClar.toolCallId);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Phase inference from LangGraph messages-tuple frames. Tool calls
|
||||
// (typically ask_clarification) flip phase to tool_calling; AI text
|
||||
// chunks flip to streaming. Everything else leaves phase alone.
|
||||
|
||||
@@ -227,6 +227,13 @@ export interface StreamMultiAgentRequest {
|
||||
}
|
||||
|
||||
export interface ClarificationPayload {
|
||||
/**
|
||||
* Stable id for this clarification — the originating `ask_clarification`
|
||||
* tool_call_id. Lets the UI key per-question selections when the agent asks
|
||||
* several clarifications in one turn (Step 1 multi-question support).
|
||||
* Omitted on the Step 2 leader path (single clarification per turn).
|
||||
*/
|
||||
id?: string;
|
||||
/** Raw question text from the model's ask_clarification args. */
|
||||
question: string;
|
||||
/** Optional category hint from the model (e.g. "missing_info"). */
|
||||
|
||||
@@ -68,13 +68,20 @@ export interface RecommendCandidate {
|
||||
* Agent ids that must never enter the candidate pool. Centralized here so
|
||||
* every caller (recommend dialog, future tools) applies the same rule.
|
||||
*
|
||||
* - `roundtable-intent` — Step 1 clarification specialist, no role in research.
|
||||
* - `roundtable-recommender`— the recommender itself, can't recommend itself.
|
||||
* - `roundtable-coordinator-*` — disposable Step 2 coordinator shells (DB
|
||||
* accumulates one per session); meaningless as roundtable participants.
|
||||
* - `roundtable-intent` — Step 1 clarification specialist, no role in research.
|
||||
* - `roundtable-recommender` — the recommender itself, can't recommend itself.
|
||||
* - `roundtable-coordinator` — Step 2 coordinator singleton (2026-05 改造后固定 id,
|
||||
* ensure 自动落地;它是"协调者",不能反过来作为席位被协调)。
|
||||
* - `roundtable-coordinator-*` 前缀 — 历史残留:2026-05 之前每次 init 会创建
|
||||
* `roundtable-coordinator-<ts36>` 形式的临时 agent,DB 仍可能保留这些遗留记录。
|
||||
* 保留前缀过滤可以在管理员清理之前先把它们隐藏起来,避免出现在推荐弹窗候选池里。
|
||||
*/
|
||||
const EXCLUDED_AGENT_ID_PREFIX = "roundtable-coordinator-";
|
||||
const EXCLUDED_AGENT_IDS = new Set<string>(["roundtable-intent", "roundtable-recommender"]);
|
||||
const EXCLUDED_AGENT_IDS = new Set<string>([
|
||||
"roundtable-intent",
|
||||
"roundtable-recommender",
|
||||
"roundtable-coordinator",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Drop excluded ids from a raw `GET /api/agents` list and project each entry
|
||||
@@ -191,6 +198,104 @@ function extractAiTextDelta(parsed: unknown): { text: string; id: string } | nul
|
||||
return { text, id };
|
||||
}
|
||||
|
||||
/**
|
||||
* One persisted recommendation run, bound to a draft/session. Returned by
|
||||
* {@link listRecommendHistory}; lets the dialog show "last recommendation for
|
||||
* this session" before deciding whether to re-analyze.
|
||||
*/
|
||||
export interface RecommendHistoryItem {
|
||||
id: string;
|
||||
draftId: string;
|
||||
objective: string;
|
||||
/** How the run ended on the backend: "done" | "fallback" | "asking" | "error". */
|
||||
status: string;
|
||||
model: string | null;
|
||||
rationale: string | null;
|
||||
picks: RecommendPick[];
|
||||
/** Candidate-pool snapshot captured at recommend time. */
|
||||
candidates: RecommendCandidate[];
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
/** Payload persisted after a recommendation run completes. */
|
||||
export interface SaveRecommendHistoryPayload {
|
||||
objective: string;
|
||||
status: string;
|
||||
model?: string;
|
||||
rationale?: string;
|
||||
picks: RecommendPick[];
|
||||
candidates: RecommendCandidate[];
|
||||
}
|
||||
|
||||
interface ServerHistoryItem {
|
||||
id: string;
|
||||
draft_id: string;
|
||||
objective: string;
|
||||
status: string;
|
||||
model: string | null;
|
||||
rationale: string | null;
|
||||
picks: RecommendPick[];
|
||||
candidates: RecommendCandidate[];
|
||||
created_at: string | null;
|
||||
}
|
||||
|
||||
function toHistoryItem(s: ServerHistoryItem): RecommendHistoryItem {
|
||||
return {
|
||||
id: s.id,
|
||||
draftId: s.draft_id,
|
||||
objective: s.objective ?? "",
|
||||
status: s.status ?? "done",
|
||||
model: s.model ?? null,
|
||||
rationale: s.rationale ?? null,
|
||||
picks: Array.isArray(s.picks) ? s.picks : [],
|
||||
candidates: Array.isArray(s.candidates) ? s.candidates : [],
|
||||
createdAt: s.created_at ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
/** List a draft's recommendation history, newest first. */
|
||||
export async function listRecommendHistory(draftId: string): Promise<RecommendHistoryItem[]> {
|
||||
const res = await apiFetch(
|
||||
`${getBackendBaseURL()}/api/roundtable-drafts/${encodeURIComponent(draftId)}/recommendations`,
|
||||
{ method: "GET" },
|
||||
);
|
||||
if (res.status === 404) return [];
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(`list recommend history failed (${res.status}): ${text}`);
|
||||
}
|
||||
const data = (await res.json()) as { history: ServerHistoryItem[] };
|
||||
return (data.history ?? []).map(toHistoryItem);
|
||||
}
|
||||
|
||||
/** Append one recommendation run to a draft's history. */
|
||||
export async function saveRecommendHistory(
|
||||
draftId: string,
|
||||
payload: SaveRecommendHistoryPayload,
|
||||
): Promise<RecommendHistoryItem | null> {
|
||||
const res = await apiFetch(
|
||||
`${getBackendBaseURL()}/api/roundtable-drafts/${encodeURIComponent(draftId)}/recommendations`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
objective: payload.objective,
|
||||
status: payload.status,
|
||||
model: payload.model,
|
||||
rationale: payload.rationale,
|
||||
picks: payload.picks,
|
||||
candidates: payload.candidates,
|
||||
}),
|
||||
},
|
||||
);
|
||||
if (res.status === 404) return null; // draft gone — skip silently
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(`save recommend history failed (${res.status}): ${text}`);
|
||||
}
|
||||
return toHistoryItem((await res.json()) as ServerHistoryItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an SSE connection to `/api/recommend/stream` and resolve once the
|
||||
* upstream stream finishes. Each call is one recommendation round — the
|
||||
|
||||
@@ -12,6 +12,20 @@ export type IntentClarificationSelection = {
|
||||
custom: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Composite selection-map key for one clarification question. When the intent
|
||||
* agent asks several questions in one turn, each needs its own selection state,
|
||||
* so we key by `${msgId}::${clarificationId}` (falling back to the arrival
|
||||
* index when the payload has no id). The map itself lives in `useStep1Intent`.
|
||||
*/
|
||||
export function clarificationKey(
|
||||
msgId: number,
|
||||
clarId: string | undefined,
|
||||
index: number,
|
||||
): string {
|
||||
return `${msgId}::${clarId ?? `idx-${index}`}`;
|
||||
}
|
||||
|
||||
type ClarificationOption = {
|
||||
id: string;
|
||||
label: string;
|
||||
@@ -72,6 +86,13 @@ interface IntentClarificationCardProps {
|
||||
submitting?: boolean;
|
||||
/** Multi-select: submit current selection. Single-select: also used for custom text. */
|
||||
onSubmit: (overrideSelection?: IntentClarificationSelection) => void;
|
||||
/**
|
||||
* Defer submission: even single-select option clicks only *record* the
|
||||
* selection (via onSelectionChange) instead of sending immediately, and the
|
||||
* card hides its own submit button. Used when several questions are answered
|
||||
* together and the parent owns one combined submit button.
|
||||
*/
|
||||
deferSubmit?: boolean;
|
||||
}
|
||||
|
||||
export function IntentClarificationCard({
|
||||
@@ -82,6 +103,7 @@ export function IntentClarificationCard({
|
||||
disabled = false,
|
||||
submitting = false,
|
||||
onSubmit,
|
||||
deferSubmit = false,
|
||||
}: IntentClarificationCardProps) {
|
||||
const options = useMemo(
|
||||
() => normalizeOptions(Array.isArray(payload.options) ? payload.options : []),
|
||||
@@ -97,11 +119,18 @@ export function IntentClarificationCard({
|
||||
return selection.selectedIds.length > 0 || selection.custom.trim().length > 0;
|
||||
}, [selection.custom, selection.selectedIds]);
|
||||
|
||||
const showSubmitButton = allowMultiple || payload.allowCustom !== false;
|
||||
// In defer mode the parent owns the (combined) submit button.
|
||||
const showSubmitButton = !deferSubmit && (allowMultiple || payload.allowCustom !== false);
|
||||
|
||||
function handleOptionClick(optionId: string) {
|
||||
if (disabled || submitting) return;
|
||||
if (!allowMultiple) {
|
||||
if (deferSubmit) {
|
||||
// Single-select but combined submit: just record the choice (replace),
|
||||
// keep any custom text the user already typed.
|
||||
onSelectionChange({ ...selection, selectedIds: [optionId] });
|
||||
return;
|
||||
}
|
||||
onSubmit({ selectedIds: [optionId], custom: "" });
|
||||
return;
|
||||
}
|
||||
@@ -144,6 +173,10 @@ export function IntentClarificationCard({
|
||||
</div>
|
||||
{options.map((option) => {
|
||||
const isSelected = selection.selectedIds.includes(option.id);
|
||||
// Highlight selected options whenever the choice is "sticky" — i.e.
|
||||
// multi-select, or single-select in defer mode (where a click records
|
||||
// rather than immediately sends).
|
||||
const showSelected = isSelected && (allowMultiple || deferSubmit);
|
||||
return (
|
||||
<button
|
||||
key={option.id}
|
||||
@@ -152,10 +185,10 @@ export function IntentClarificationCard({
|
||||
onClick={() => handleOptionClick(option.id)}
|
||||
className={cn(
|
||||
"flex w-full items-start justify-between gap-2 rounded-xl border px-3 py-2 text-left transition",
|
||||
isSelected && allowMultiple
|
||||
showSelected
|
||||
? "border-primary bg-primary text-white shadow-sm"
|
||||
: "border-slate-200 bg-slate-50/80 text-slate-800 hover:border-primary/40 hover:bg-white",
|
||||
!allowMultiple && !disabled && !submitting && "active:scale-[0.99]",
|
||||
!allowMultiple && !deferSubmit && !disabled && !submitting && "active:scale-[0.99]",
|
||||
(disabled || submitting) && "cursor-not-allowed opacity-60",
|
||||
)}
|
||||
>
|
||||
@@ -165,14 +198,14 @@ export function IntentClarificationCard({
|
||||
<span
|
||||
className={cn(
|
||||
"text-[10px] leading-snug",
|
||||
isSelected && allowMultiple ? "text-white/80" : "text-slate-500",
|
||||
showSelected ? "text-white/80" : "text-slate-500",
|
||||
)}
|
||||
>
|
||||
{option.description}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
{isSelected && allowMultiple ? (
|
||||
{showSelected ? (
|
||||
<Check className="mt-0.5 h-3.5 w-3.5 shrink-0" />
|
||||
) : null}
|
||||
</button>
|
||||
|
||||
@@ -31,12 +31,17 @@ import { MessageStepsCard } from "./MessageStepsCard";
|
||||
import type { IntentSummary } from "../api/intent";
|
||||
import {
|
||||
filterRecommendCandidates,
|
||||
listRecommendHistory,
|
||||
parseRecommendStreamContent,
|
||||
saveRecommendHistory,
|
||||
streamRecommend,
|
||||
type RecommendCandidate,
|
||||
type RecommendHistoryItem,
|
||||
type RecommendStreamPhase,
|
||||
} from "../api/recommend";
|
||||
import { useAutoScroll } from "../hooks/useAutoScroll";
|
||||
import { splitInlineReasoning } from "../lib/reasoning";
|
||||
import { ScrollToBottomButton } from "./ScrollToBottomButton";
|
||||
|
||||
/**
|
||||
* Picks-selection dialog that sits between Step 1 (intent) and Step 2
|
||||
@@ -54,6 +59,13 @@ export interface RecommendAgentsDialogProps {
|
||||
intent: IntentSummary | null;
|
||||
/** Falls back to the recommender's own default if omitted. */
|
||||
model?: string;
|
||||
/**
|
||||
* Draft/session id this recommendation belongs to. When present, the dialog
|
||||
* shows the session's last recommendation on open (with a「重新分析」button)
|
||||
* and persists each fresh run to history. Null → behaves statelessly (always
|
||||
* runs a fresh recommendation, no history).
|
||||
*/
|
||||
draftId?: string | null;
|
||||
onCancel: () => void;
|
||||
/** Called with the user's final selection of agent ids (in display order). */
|
||||
onConfirm: (agents: Array<{ agent_id: string; name: string }>) => void;
|
||||
@@ -79,6 +91,8 @@ const FALLBACK_AGENT_IDS = [
|
||||
type DialogPhase =
|
||||
| "idle"
|
||||
| "loading_agents"
|
||||
| "loading_history"
|
||||
| "history"
|
||||
| "recommending"
|
||||
| "ready"
|
||||
| "fallback"
|
||||
@@ -109,6 +123,8 @@ interface InternalState {
|
||||
warning: string | null;
|
||||
/** Latest error message; only shown when `phase === "error"`. */
|
||||
errorMessage: string | null;
|
||||
/** ISO time of the historical record being shown (phase === "history"). */
|
||||
historyCreatedAt: string | null;
|
||||
}
|
||||
|
||||
const INITIAL_STATE: InternalState = {
|
||||
@@ -121,6 +137,7 @@ const INITIAL_STATE: InternalState = {
|
||||
recommendedIds: [],
|
||||
warning: null,
|
||||
errorMessage: null,
|
||||
historyCreatedAt: null,
|
||||
};
|
||||
|
||||
/** 推荐流程的 phase → 中文标签;与 RoundtablePlanningPage::phaseLabel 风格保持一致。 */
|
||||
@@ -162,6 +179,7 @@ export function RecommendAgentsDialog({
|
||||
open,
|
||||
intent,
|
||||
model,
|
||||
draftId,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
}: RecommendAgentsDialogProps) {
|
||||
@@ -183,172 +201,240 @@ export function RecommendAgentsDialog({
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* The full pipeline: fetch agents → run recommendation → seed selection.
|
||||
* Wrapped so the user can re-trigger it via the "重新推荐" button.
|
||||
* Render a stored history record as the current view (no streaming). Used on
|
||||
* open when the session already has a prior recommendation. The user can
|
||||
* confirm these picks directly or click「重新分析」to run a fresh one.
|
||||
*/
|
||||
const runRecommendation = useCallback(async () => {
|
||||
if (!intent || !intent.objective) {
|
||||
setState({
|
||||
...INITIAL_STATE,
|
||||
phase: "error",
|
||||
errorMessage: "缺少任务目标,无法启动推荐",
|
||||
});
|
||||
return;
|
||||
const applyHistory = useCallback((item: RecommendHistoryItem, candidates: RecommendCandidate[]) => {
|
||||
const reasons: Record<string, string> = {};
|
||||
const recommendedIds: string[] = [];
|
||||
for (const p of item.picks) {
|
||||
reasons[p.agent_id] = p.reason;
|
||||
recommendedIds.push(p.agent_id);
|
||||
}
|
||||
|
||||
cancelInflight();
|
||||
const myGen = ++generationRef.current;
|
||||
const controller = new AbortController();
|
||||
abortRef.current = controller;
|
||||
|
||||
setState({ ...INITIAL_STATE, phase: "loading_agents" });
|
||||
setSelectedIds(new Set());
|
||||
|
||||
let agents: Agent[];
|
||||
try {
|
||||
agents = await listAgents();
|
||||
} catch (err) {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState({
|
||||
...INITIAL_STATE,
|
||||
phase: "error",
|
||||
errorMessage: `加载智能体列表失败:${err instanceof Error ? err.message : String(err)}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (myGen !== generationRef.current) return;
|
||||
|
||||
const candidates = filterRecommendCandidates(agents);
|
||||
if (candidates.length === 0) {
|
||||
setState({
|
||||
...INITIAL_STATE,
|
||||
phase: "error",
|
||||
errorMessage: "候选智能体池为空,请先在系统里创建至少 2 个智能体",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const seed = intersectInOrder(recommendedIds, candidates);
|
||||
setSelectedIds(new Set(seed));
|
||||
const { rationale } = parseRecommendStreamContent(item.rationale || "");
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "recommending",
|
||||
phase: "history",
|
||||
candidates,
|
||||
rationale: "",
|
||||
streamPhase: "connecting",
|
||||
// 推荐开始,清空上一轮的步骤时间线并打第一条点。
|
||||
steps: [
|
||||
{ id: "0", key: "connecting", label: recommendPhaseLabel("connecting"), ts: nowTimeStr() },
|
||||
],
|
||||
rationale: rationale || item.rationale || "",
|
||||
recommendedIds: seed,
|
||||
reasons,
|
||||
streamPhase: null,
|
||||
steps: [],
|
||||
warning: null,
|
||||
historyCreatedAt: item.createdAt || null,
|
||||
}));
|
||||
}, []);
|
||||
|
||||
try {
|
||||
const result = await streamRecommend({
|
||||
intent,
|
||||
/**
|
||||
* Stream a fresh recommendation over the given candidate pool, seed the
|
||||
* selection, and (when bound to a draft) persist the run to history.
|
||||
*/
|
||||
const analyze = useCallback(
|
||||
async (candidates: RecommendCandidate[], myGen: number, signal: AbortSignal) => {
|
||||
if (!intent) return;
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "recommending",
|
||||
candidates,
|
||||
model,
|
||||
signal: controller.signal,
|
||||
onRationaleUpdate: (rationale) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState((prev) => ({ ...prev, rationale }));
|
||||
},
|
||||
onPicksUpdate: (picks) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
const reasons: Record<string, string> = {};
|
||||
const recommendedIds: string[] = [];
|
||||
for (const p of picks) {
|
||||
rationale: "",
|
||||
reasons: {},
|
||||
recommendedIds: [],
|
||||
warning: null,
|
||||
historyCreatedAt: null,
|
||||
streamPhase: "connecting",
|
||||
// 推荐开始,清空上一轮的步骤时间线并打第一条点。
|
||||
steps: [
|
||||
{ id: "0", key: "connecting", label: recommendPhaseLabel("connecting"), ts: nowTimeStr() },
|
||||
],
|
||||
}));
|
||||
setSelectedIds(new Set());
|
||||
|
||||
try {
|
||||
const result = await streamRecommend({
|
||||
intent,
|
||||
candidates,
|
||||
model,
|
||||
signal,
|
||||
onRationaleUpdate: (rationale) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState((prev) => ({ ...prev, rationale }));
|
||||
},
|
||||
onPicksUpdate: (picks) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
const reasons: Record<string, string> = {};
|
||||
const recommendedIds: string[] = [];
|
||||
for (const p of picks) {
|
||||
reasons[p.agent_id] = p.reason;
|
||||
recommendedIds.push(p.agent_id);
|
||||
}
|
||||
const seed = intersectInOrder(recommendedIds, candidates);
|
||||
setSelectedIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
for (const id of seed) next.add(id);
|
||||
return next;
|
||||
});
|
||||
setState((prev) => ({ ...prev, recommendedIds, reasons }));
|
||||
},
|
||||
onPhaseChange: (phase) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState((prev) => {
|
||||
const key = phase;
|
||||
const last = prev.steps[prev.steps.length - 1];
|
||||
const steps =
|
||||
last && last.key === key
|
||||
? prev.steps
|
||||
: [
|
||||
...prev.steps,
|
||||
{
|
||||
id: String(prev.steps.length),
|
||||
key,
|
||||
label: recommendPhaseLabel(phase),
|
||||
ts: nowTimeStr(),
|
||||
},
|
||||
];
|
||||
return { ...prev, streamPhase: phase, steps };
|
||||
});
|
||||
},
|
||||
});
|
||||
if (myGen !== generationRef.current) return;
|
||||
|
||||
const reasons: Record<string, string> = {};
|
||||
const recommendedIds: string[] = [];
|
||||
if (result.picks) {
|
||||
for (const p of result.picks) {
|
||||
reasons[p.agent_id] = p.reason;
|
||||
recommendedIds.push(p.agent_id);
|
||||
}
|
||||
const seed = intersectInOrder(recommendedIds, candidates);
|
||||
setSelectedIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
for (const id of seed) next.add(id);
|
||||
return next;
|
||||
});
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
recommendedIds,
|
||||
reasons,
|
||||
}));
|
||||
},
|
||||
onPhaseChange: (phase) => {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState((prev) => {
|
||||
const key = phase;
|
||||
const last = prev.steps[prev.steps.length - 1];
|
||||
// 连续重复阶段不重复 push,只在阶段切换时打点。
|
||||
const steps =
|
||||
last && last.key === key
|
||||
? prev.steps
|
||||
: [
|
||||
...prev.steps,
|
||||
{
|
||||
id: String(prev.steps.length),
|
||||
key,
|
||||
label: recommendPhaseLabel(phase),
|
||||
ts: nowTimeStr(),
|
||||
},
|
||||
];
|
||||
return { ...prev, streamPhase: phase, steps };
|
||||
});
|
||||
},
|
||||
});
|
||||
if (myGen !== generationRef.current) return;
|
||||
|
||||
const reasons: Record<string, string> = {};
|
||||
const recommendedIds: string[] = [];
|
||||
if (result.picks) {
|
||||
for (const p of result.picks) {
|
||||
reasons[p.agent_id] = p.reason;
|
||||
recommendedIds.push(p.agent_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.status === "done" && recommendedIds.length >= MIN_SELECTED) {
|
||||
const seed = intersectInOrder(recommendedIds, candidates);
|
||||
setSelectedIds(new Set(seed));
|
||||
const { rationale } = parseRecommendStreamContent(result.content || "");
|
||||
|
||||
let finalPhase: DialogPhase;
|
||||
let finalIds: string[];
|
||||
let warning: string | null;
|
||||
if (result.status === "done" && recommendedIds.length >= MIN_SELECTED) {
|
||||
finalPhase = "ready";
|
||||
finalIds = intersectInOrder(recommendedIds, candidates);
|
||||
warning = null;
|
||||
} else {
|
||||
// Fallback: status === "asking" or picks too few. Use the 6 built-in
|
||||
// roundtable seats, intersected against the live pool.
|
||||
finalPhase = "fallback";
|
||||
const fallback = intersectInOrder(FALLBACK_AGENT_IDS, candidates);
|
||||
finalIds =
|
||||
fallback.length >= MIN_SELECTED
|
||||
? fallback
|
||||
: candidates.slice(0, MIN_SELECTED).map((c) => c.agent_id);
|
||||
warning = "智能推荐未生成有效结果,已为你勾选默认的圆桌席位,可手动调整。";
|
||||
}
|
||||
|
||||
setSelectedIds(new Set(finalIds));
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "ready",
|
||||
phase: finalPhase,
|
||||
rationale: rationale || prev.rationale,
|
||||
recommendedIds,
|
||||
recommendedIds: finalIds,
|
||||
reasons,
|
||||
streamPhase: null,
|
||||
warning: null,
|
||||
warning,
|
||||
}));
|
||||
|
||||
// Persist this run to the session's history (best-effort).
|
||||
if (draftId) {
|
||||
const picks = finalIds.map((id) => ({ agent_id: id, reason: reasons[id] ?? "" }));
|
||||
void saveRecommendHistory(draftId, {
|
||||
objective: intent.objective,
|
||||
status: finalPhase === "ready" ? "done" : "fallback",
|
||||
model,
|
||||
rationale: rationale || result.content || "",
|
||||
picks,
|
||||
candidates,
|
||||
}).catch((err) => console.warn("[recommend] 保存推荐历史失败:", err));
|
||||
}
|
||||
} catch (err) {
|
||||
if (myGen !== generationRef.current) return;
|
||||
// AbortError fires when the user closes the dialog mid-stream — no
|
||||
// state update needed because the dialog is going away.
|
||||
if (err instanceof DOMException && err.name === "AbortError") return;
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "error",
|
||||
streamPhase: null,
|
||||
errorMessage: `推荐过程出错:${err instanceof Error ? err.message : String(err)}`,
|
||||
}));
|
||||
}
|
||||
},
|
||||
[intent, model, draftId],
|
||||
);
|
||||
|
||||
/**
|
||||
* Open pipeline: load candidates → (unless forceFresh) show the session's
|
||||
* last recommendation from history → otherwise run a fresh analysis.
|
||||
* `forceFresh=true` is the「重新分析」/「重新推荐」path.
|
||||
*/
|
||||
const start = useCallback(
|
||||
async (forceFresh: boolean) => {
|
||||
if (!intent || !intent.objective) {
|
||||
setState({ ...INITIAL_STATE, phase: "error", errorMessage: "缺少任务目标,无法启动推荐" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: status === "asking" or picks too few. Use the 6 built-in
|
||||
// roundtable seats, intersected against the live pool.
|
||||
const fallback = intersectInOrder(FALLBACK_AGENT_IDS, candidates);
|
||||
const seed = fallback.length >= MIN_SELECTED
|
||||
? fallback
|
||||
: candidates.slice(0, MIN_SELECTED).map((c) => c.agent_id);
|
||||
setSelectedIds(new Set(seed));
|
||||
const { rationale } = parseRecommendStreamContent(result.content || "");
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "fallback",
|
||||
rationale: rationale || prev.rationale,
|
||||
recommendedIds: seed,
|
||||
reasons,
|
||||
streamPhase: null,
|
||||
warning: "智能推荐未生成有效结果,已为你勾选默认的圆桌席位,可手动调整。",
|
||||
}));
|
||||
} catch (err) {
|
||||
cancelInflight();
|
||||
const myGen = ++generationRef.current;
|
||||
const controller = new AbortController();
|
||||
abortRef.current = controller;
|
||||
|
||||
setState({ ...INITIAL_STATE, phase: "loading_agents" });
|
||||
setSelectedIds(new Set());
|
||||
|
||||
let agents: Agent[];
|
||||
try {
|
||||
agents = await listAgents();
|
||||
} catch (err) {
|
||||
if (myGen !== generationRef.current) return;
|
||||
setState({
|
||||
...INITIAL_STATE,
|
||||
phase: "error",
|
||||
errorMessage: `加载智能体列表失败:${err instanceof Error ? err.message : String(err)}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (myGen !== generationRef.current) return;
|
||||
// AbortError fires when the user closes the dialog mid-stream — no
|
||||
// state update needed because the dialog is going away.
|
||||
if (err instanceof DOMException && err.name === "AbortError") return;
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
phase: "error",
|
||||
streamPhase: null,
|
||||
errorMessage: `推荐过程出错:${err instanceof Error ? err.message : String(err)}`,
|
||||
}));
|
||||
}
|
||||
}, [intent, model, cancelInflight]);
|
||||
|
||||
const candidates = filterRecommendCandidates(agents);
|
||||
if (candidates.length === 0) {
|
||||
setState({
|
||||
...INITIAL_STATE,
|
||||
phase: "error",
|
||||
errorMessage: "候选智能体池为空,请先在系统里创建至少 2 个智能体",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 若该会话已有推荐历史,默认展示最近一次(可重新分析),不自动重跑模型。
|
||||
if (!forceFresh && draftId) {
|
||||
setState((prev) => ({ ...prev, phase: "loading_history", candidates }));
|
||||
try {
|
||||
const history = await listRecommendHistory(draftId);
|
||||
if (myGen !== generationRef.current) return;
|
||||
if (history.length > 0) {
|
||||
applyHistory(history[0], candidates);
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
if (myGen !== generationRef.current) return;
|
||||
// 历史拉取失败不阻断:退化为直接跑一次新推荐。
|
||||
console.warn("[recommend] 拉取推荐历史失败,回退到新推荐:", err);
|
||||
}
|
||||
}
|
||||
|
||||
await analyze(candidates, myGen, controller.signal);
|
||||
},
|
||||
[intent, draftId, cancelInflight, analyze, applyHistory],
|
||||
);
|
||||
|
||||
// Trigger the pipeline whenever the dialog opens. Closing it aborts any
|
||||
// in-flight stream so the next open starts clean.
|
||||
@@ -357,11 +443,11 @@ export function RecommendAgentsDialog({
|
||||
cancelInflight();
|
||||
return;
|
||||
}
|
||||
void runRecommendation();
|
||||
void start(false);
|
||||
return () => {
|
||||
cancelInflight();
|
||||
};
|
||||
}, [open, runRecommendation, cancelInflight]);
|
||||
}, [open, start, cancelInflight]);
|
||||
|
||||
const handleToggle = useCallback((agentId: string) => {
|
||||
setSelectedIds((prev) => {
|
||||
@@ -389,7 +475,7 @@ export function RecommendAgentsDialog({
|
||||
|
||||
const selectedCount = selectedIds.size;
|
||||
const canConfirm =
|
||||
(state.phase === "ready" || state.phase === "fallback") &&
|
||||
(state.phase === "ready" || state.phase === "fallback" || state.phase === "history") &&
|
||||
selectedCount >= MIN_SELECTED &&
|
||||
selectedCount <= MAX_SELECTED;
|
||||
|
||||
@@ -450,9 +536,12 @@ export function RecommendAgentsDialog({
|
||||
============================================================ */}
|
||||
<CollapsibleModelOutput
|
||||
isLoading={
|
||||
state.phase === "loading_agents" || state.phase === "recommending"
|
||||
state.phase === "loading_agents" ||
|
||||
state.phase === "loading_history" ||
|
||||
state.phase === "recommending"
|
||||
}
|
||||
phase={state.phase}
|
||||
scrollDeps={[state.rationale, state.steps, state.streamPhase]}
|
||||
>
|
||||
<RecommenderOutput state={state} />
|
||||
</CollapsibleModelOutput>
|
||||
@@ -494,8 +583,20 @@ export function RecommendAgentsDialog({
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (state.phase === "ready" || state.phase === "fallback") ? (
|
||||
) : (state.phase === "ready" || state.phase === "fallback" || state.phase === "history") ? (
|
||||
<>
|
||||
{state.phase === "history" && (
|
||||
<div className="text-xs text-sky-700 dark:text-sky-300 p-2 border border-sky-300/50 dark:border-sky-700/50 rounded-md bg-sky-50 dark:bg-sky-950/30 flex items-center justify-between gap-2">
|
||||
<span>
|
||||
📌 这是本会话上次的推荐结果
|
||||
{state.historyCreatedAt
|
||||
? `(${new Date(state.historyCreatedAt).toLocaleString("zh-CN", { hour12: false })})`
|
||||
: ""}
|
||||
,可直接进入研讨,或点「重新分析」让模型重新推荐。
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{state.warning && (
|
||||
<div className="text-xs text-amber-700 dark:text-amber-300 p-2 border border-amber-300/50 dark:border-amber-700/50 rounded-md bg-amber-50 dark:bg-amber-950/30">
|
||||
{state.warning}
|
||||
@@ -548,15 +649,18 @@ export function RecommendAgentsDialog({
|
||||
>
|
||||
{selectionHint}
|
||||
</span>
|
||||
{(state.phase === "ready" || state.phase === "fallback" || state.phase === "error") && (
|
||||
{(state.phase === "ready" ||
|
||||
state.phase === "fallback" ||
|
||||
state.phase === "history" ||
|
||||
state.phase === "error") && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
variant={state.phase === "history" ? "secondary" : "ghost"}
|
||||
size="sm"
|
||||
onClick={() => void runRecommendation()}
|
||||
onClick={() => void start(true)}
|
||||
className="h-7 px-2 text-xs"
|
||||
>
|
||||
<RefreshCwIcon className="size-3 mr-1" />
|
||||
重新推荐
|
||||
{state.phase === "history" ? "重新分析" : "重新推荐"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -593,16 +697,22 @@ const MODEL_OUTPUT_AUTO_CLOSE_DELAY_MS = 1000;
|
||||
function CollapsibleModelOutput({
|
||||
isLoading,
|
||||
phase,
|
||||
scrollDeps,
|
||||
children,
|
||||
}: {
|
||||
/** True 时面板保持展开 + header 显示 spinner;涵盖加载候选 + 流式生成。 */
|
||||
isLoading: boolean;
|
||||
phase: DialogPhase;
|
||||
/** 内容变化时触发自动滚到底(与 Step1/Step2 对话区同一套 useAutoScroll)。 */
|
||||
scrollDeps: React.DependencyList;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const [open, setOpen] = useState<boolean>(true);
|
||||
const userTouchedRef = useRef<boolean>(false);
|
||||
const hasAutoClosedRef = useRef<boolean>(false);
|
||||
const modelOutputScrollRef = useRef<HTMLDivElement>(null);
|
||||
const { atBottom: modelOutputAtBottom, scrollToBottom: scrollModelOutputToBottom } =
|
||||
useAutoScroll(modelOutputScrollRef, scrollDeps);
|
||||
|
||||
// 加载中 → 保持展开(用户没手动动过的前提下)。
|
||||
// 加载完成 → 延迟自动收起一次(仅一次),让出焦点给下方推荐卡片。
|
||||
@@ -615,7 +725,8 @@ function CollapsibleModelOutput({
|
||||
hasAutoClosedRef.current = false;
|
||||
return;
|
||||
}
|
||||
const isCompleted = phase === "ready" || phase === "fallback" || phase === "error";
|
||||
const isCompleted =
|
||||
phase === "ready" || phase === "fallback" || phase === "error" || phase === "history";
|
||||
if (isCompleted && !hasAutoClosedRef.current && open) {
|
||||
const timer = setTimeout(() => {
|
||||
setOpen(false);
|
||||
@@ -630,6 +741,10 @@ function CollapsibleModelOutput({
|
||||
switch (phase) {
|
||||
case "loading_agents":
|
||||
return { label: "加载候选", className: "bg-slate-100 text-slate-600" };
|
||||
case "loading_history":
|
||||
return { label: "读取历史", className: "bg-slate-100 text-slate-600" };
|
||||
case "history":
|
||||
return { label: "历史记录", className: "bg-sky-50 text-sky-700 border border-sky-200" };
|
||||
case "recommending":
|
||||
return { label: "正在生成", className: "bg-purple-50 text-purple-700 border border-purple-200" };
|
||||
case "ready":
|
||||
@@ -677,8 +792,16 @@ function CollapsibleModelOutput({
|
||||
/>
|
||||
</button>
|
||||
{open && (
|
||||
<div className="px-3 pb-3 min-h-0 flex-1 overflow-y-auto custom-scrollbar">
|
||||
{children}
|
||||
<div className="relative min-h-0 flex-1 flex flex-col">
|
||||
<div
|
||||
ref={modelOutputScrollRef}
|
||||
className="px-3 pb-3 min-h-0 flex-1 overflow-y-auto custom-scrollbar"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
{!modelOutputAtBottom && (
|
||||
<ScrollToBottomButton onClick={scrollModelOutputToBottom} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
@@ -696,11 +819,11 @@ function CollapsibleModelOutput({
|
||||
* - 流式中正文末尾跟一个闪烁竖线
|
||||
*/
|
||||
function RecommenderOutput({ state }: { state: InternalState }) {
|
||||
if (state.phase === "loading_agents") {
|
||||
if (state.phase === "loading_agents" || state.phase === "loading_history") {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-muted-foreground text-sm">
|
||||
<Loader2Icon className="size-4 animate-spin" />
|
||||
正在加载候选智能体...
|
||||
{state.phase === "loading_history" ? "正在读取历史推荐..." : "正在加载候选智能体..."}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -716,7 +839,8 @@ function RecommenderOutput({ state }: { state: InternalState }) {
|
||||
const showRationaleStage =
|
||||
state.phase === "recommending" ||
|
||||
state.phase === "ready" ||
|
||||
state.phase === "fallback";
|
||||
state.phase === "fallback" ||
|
||||
state.phase === "history";
|
||||
if (!showRationaleStage) return null;
|
||||
|
||||
const isStreaming = state.phase === "recommending";
|
||||
@@ -751,7 +875,10 @@ function RecommenderOutput({ state }: { state: InternalState }) {
|
||||
{hasReasoning && (
|
||||
<ReasoningBlock
|
||||
streaming={isStreaming}
|
||||
contentClassName="max-h-48 overflow-y-auto custom-scrollbar"
|
||||
contentClassName={cn(
|
||||
"overflow-y-auto custom-scrollbar",
|
||||
isStreaming ? "max-h-none" : "max-h-48",
|
||||
)}
|
||||
>
|
||||
{reasoning!}
|
||||
</ReasoningBlock>
|
||||
@@ -762,7 +889,12 @@ function RecommenderOutput({ state }: { state: InternalState }) {
|
||||
)}
|
||||
|
||||
{hasRationale && (
|
||||
<div className="max-h-40 overflow-y-auto custom-scrollbar rounded-md border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-700 leading-relaxed">
|
||||
<div
|
||||
className={cn(
|
||||
"overflow-y-auto custom-scrollbar rounded-md border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-700 leading-relaxed",
|
||||
isStreaming ? "max-h-none" : "max-h-40",
|
||||
)}
|
||||
>
|
||||
<MarkdownContent>{cleanedRationale}</MarkdownContent>
|
||||
{isStreaming && <StreamingCursor />}
|
||||
</div>
|
||||
|
||||
@@ -25,8 +25,10 @@ import {
|
||||
X,
|
||||
} from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Man1Avatar, RobotAvatar } from "@/roundtable-planning/components/Avatars";
|
||||
import {
|
||||
clarificationKey,
|
||||
IntentClarificationCard,
|
||||
type IntentClarificationSelection,
|
||||
} from "@/roundtable-planning/components/IntentClarificationCard";
|
||||
@@ -55,10 +57,10 @@ export interface Step1PanelProps {
|
||||
intentReady: object | null;
|
||||
isIntentSending: boolean;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<number, IntentClarificationSelection>;
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
// ─── Setters / Handlers ──────────────────────────────────────
|
||||
setIntentClarificationSelections: React.Dispatch<
|
||||
React.SetStateAction<Map<number, IntentClarificationSelection>>
|
||||
React.SetStateAction<Map<string, IntentClarificationSelection>>
|
||||
>;
|
||||
onSendMessage: (text: string) => void;
|
||||
onStopIntent: () => void;
|
||||
@@ -67,10 +69,10 @@ export interface Step1PanelProps {
|
||||
onEnterRoundtable: () => void;
|
||||
onManualSave: () => void;
|
||||
onTriggerToast: (msg: string) => void;
|
||||
submitIntentClarification: (
|
||||
submitIntentClarifications: (
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
@@ -90,7 +92,7 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
onEnterRoundtable,
|
||||
onManualSave,
|
||||
onTriggerToast,
|
||||
submitIntentClarification,
|
||||
submitIntentClarifications,
|
||||
} = props;
|
||||
|
||||
const step1ScrollRef = useRef<HTMLDivElement>(null);
|
||||
@@ -138,7 +140,7 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
intentClarificationSelections={intentClarificationSelections}
|
||||
setIntentClarificationSelections={setIntentClarificationSelections}
|
||||
isIntentSending={isIntentSending}
|
||||
submitIntentClarification={submitIntentClarification}
|
||||
submitIntentClarifications={submitIntentClarifications}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -266,15 +268,15 @@ interface Step1MessageProps {
|
||||
msg: InteractiveMessage;
|
||||
intentReady: object | null;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<number, IntentClarificationSelection>;
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
setIntentClarificationSelections: React.Dispatch<
|
||||
React.SetStateAction<Map<number, IntentClarificationSelection>>
|
||||
React.SetStateAction<Map<string, IntentClarificationSelection>>
|
||||
>;
|
||||
isIntentSending: boolean;
|
||||
submitIntentClarification: (
|
||||
submitIntentClarifications: (
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
@@ -285,7 +287,7 @@ function Step1Message({
|
||||
intentClarificationSelections,
|
||||
setIntentClarificationSelections,
|
||||
isIntentSending,
|
||||
submitIntentClarification,
|
||||
submitIntentClarifications,
|
||||
}: Step1MessageProps) {
|
||||
const isStreaming = msg.streaming === true;
|
||||
const isAgent = msg.sender !== "user";
|
||||
@@ -297,24 +299,23 @@ function Step1Message({
|
||||
? splitInlineReasoning(rawContent)
|
||||
: { content: rawContent, reasoning: null };
|
||||
const hasContent = thoughtFreeContent.length > 0;
|
||||
const clarification = msg.clarification;
|
||||
// 一轮可能有多条澄清问题(任务理解智能体一次问多个)。流式期就逐个灌进来,
|
||||
// 实时展示「协助过程」;终态再以权威集合覆盖。
|
||||
const clarifications = msg.clarifications ?? [];
|
||||
const parts = isAgent
|
||||
? splitIntentReadyBlock(thoughtFreeContent)
|
||||
: { before: thoughtFreeContent, summary: null as IntentSummary | null, after: "" };
|
||||
const isPendingClarification =
|
||||
isAgent &&
|
||||
clarification &&
|
||||
!intentReady &&
|
||||
!parts.summary &&
|
||||
pendingIntentClarificationMsgId === msg.id;
|
||||
const clarificationSelection =
|
||||
intentClarificationSelections.get(msg.id) ?? {
|
||||
selectedIds: [],
|
||||
custom: "",
|
||||
};
|
||||
// 是否展示澄清卡(还没出 summary / 还没整体就绪时)。流式中也展示(只读),
|
||||
// 终态且该消息为当前待澄清条目时才可交互。
|
||||
const showClarifications =
|
||||
isAgent && clarifications.length > 0 && !intentReady && !parts.summary;
|
||||
// 一轮多个问题才进入「逐题作答 + 合并发送」模式;单问题沿用「点击即发送」。
|
||||
const multiQuestion = clarifications.length > 1;
|
||||
const isPending = pendingIntentClarificationMsgId === msg.id;
|
||||
const clarificationsInteractive = isPending && !isStreaming;
|
||||
const introText =
|
||||
clarification &&
|
||||
parts.before.trim() === (clarification.question || "").trim()
|
||||
clarifications.length === 1 &&
|
||||
parts.before.trim() === (clarifications[0].question || "").trim()
|
||||
? ""
|
||||
: parts.before;
|
||||
|
||||
@@ -361,24 +362,63 @@ function Step1Message({
|
||||
把它丢弃,让用户看到的就是"复述 + 摘要卡",干净结束。
|
||||
*/}
|
||||
{isStreaming && <StreamingCursor />}
|
||||
{isPendingClarification && clarification && (
|
||||
<IntentClarificationCard
|
||||
payload={clarification}
|
||||
fallbackContent={parts.before || undefined}
|
||||
selection={clarificationSelection}
|
||||
onSelectionChange={(next) => {
|
||||
setIntentClarificationSelections((prev) => {
|
||||
const map = new Map(prev);
|
||||
map.set(msg.id, next);
|
||||
return map;
|
||||
});
|
||||
}}
|
||||
disabled={!isPendingClarification}
|
||||
submitting={isIntentSending && Boolean(isPendingClarification)}
|
||||
onSubmit={(override) =>
|
||||
submitIntentClarification(msg.id, clarification, override)
|
||||
}
|
||||
/>
|
||||
{showClarifications && (
|
||||
<div className="space-y-2">
|
||||
{clarifications.map((clar, index) => {
|
||||
const key = clarificationKey(msg.id, clar.id, index);
|
||||
const selection =
|
||||
intentClarificationSelections.get(key) ?? {
|
||||
selectedIds: [],
|
||||
custom: "",
|
||||
};
|
||||
return (
|
||||
<IntentClarificationCard
|
||||
key={key}
|
||||
payload={clar}
|
||||
fallbackContent={clar.question || parts.before || undefined}
|
||||
selection={selection}
|
||||
// 单问题:沿用原交互(单选点击即发送 / 多选 / 自定义走卡片自己的按钮)。
|
||||
// 多问题:才 defer —— 逐题只记录选择,由下方一个合并按钮统一发送。
|
||||
deferSubmit={multiQuestion}
|
||||
onSelectionChange={(next) => {
|
||||
setIntentClarificationSelections((prev) => {
|
||||
const map = new Map(prev);
|
||||
map.set(key, next);
|
||||
return map;
|
||||
});
|
||||
}}
|
||||
disabled={!clarificationsInteractive}
|
||||
submitting={isIntentSending && isPending}
|
||||
onSubmit={(override) =>
|
||||
submitIntentClarifications(
|
||||
msg.id,
|
||||
clarifications,
|
||||
// 单题单选「点击即发送」时选择还没进 state map,把即时值
|
||||
// 按 key 传进去直接用。
|
||||
override ? { [key]: override } : undefined,
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{/* 合并提交按钮仅多问题时出现;单问题点选项即发送,无需此按钮。 */}
|
||||
{multiQuestion && clarificationsInteractive && (
|
||||
<div className="flex items-center justify-between gap-2 pt-0.5">
|
||||
<span className="text-[10px] text-slate-400">
|
||||
共 {clarifications.length} 个问题,可逐个作答后一并发送
|
||||
</span>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
disabled={isIntentSending}
|
||||
onClick={() => submitIntentClarifications(msg.id, clarifications)}
|
||||
className="h-8 rounded-xl px-4 text-xs font-bold"
|
||||
>
|
||||
{isIntentSending ? "发送中…" : "发送全部回答"}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -1,26 +1,42 @@
|
||||
/**
|
||||
* 圆桌规划草稿持久化 hook。
|
||||
* 圆桌规划草稿持久化 hook(后端版)。
|
||||
*
|
||||
* 维护 localStorage 草稿列表与 currentDraftId、自动保存(前进切换 1→2、2→3)、
|
||||
* 手动保存、加载 / 重命名 / 删除。Step 1 / Step 2 的状态由各自的 hook 提供
|
||||
* 快照函数与 hydrateFromDraft;本 hook 只负责编排「什么时机存 / 加载到哪里」。
|
||||
* 2026-06 改造:草稿从浏览器 localStorage 迁移到后端 MySQL(`/api/roundtable-drafts`),
|
||||
* 按登录用户隔离、跨设备/会话保留。本 hook 仍只负责编排「什么时机存 / 加载到哪里」,
|
||||
* Step 1 / Step 2 的状态由各自的 hook 提供快照函数与 hydrate。
|
||||
*
|
||||
* 对外返回的接口(`drafts` 列表项含 `name` 等字段、各 handler 签名)与旧版保持一致,
|
||||
* 主页面无需改动。
|
||||
*
|
||||
* 同时修复了旧 localStorage 版的几个存储 bug:
|
||||
* 1. **自动保存会覆盖手动重命名** —— 现在 create 时写一次派生标题,之后所有 update
|
||||
* 一律不带 title;标题只由显式「重命名」改写。
|
||||
* 2. **快速连续前进(1→2→3)产生重复草稿** —— 所有保存经一条串行队列,create 完成
|
||||
* 即写入 `currentDraftIdRef`,后续保存读到 id 走 update 而非再 create。
|
||||
* 3. **加载读到 state 里的旧列表快照** —— load 走 `getDraft(id)` 实时拉服务端最新全量。
|
||||
* 4. localStorage 配额导致的静默写失败 / 数据丢失 —— 改后端后不复存在。
|
||||
*/
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
import type {
|
||||
Step1Snapshot,
|
||||
} from "@/roundtable-planning/hooks/useStep1Intent";
|
||||
import type {
|
||||
Step2Snapshot,
|
||||
} from "@/roundtable-planning/hooks/useStep2Orchestration";
|
||||
import type { Step1Snapshot } from "@/roundtable-planning/hooks/useStep1Intent";
|
||||
import type { Step2Snapshot } from "@/roundtable-planning/hooks/useStep2Orchestration";
|
||||
import {
|
||||
createDraft,
|
||||
deleteDraft,
|
||||
deriveDraftName,
|
||||
getDraft,
|
||||
listDrafts,
|
||||
renameDraft,
|
||||
upsertDraft,
|
||||
type DraftRecord,
|
||||
} from "@/roundtable-planning/utils/drafts";
|
||||
updateDraft,
|
||||
} from "@/roundtable-planning/api/drafts";
|
||||
|
||||
/** 历史下拉渲染用的轻量列表项(`name` 映射自后端 `title`)。 */
|
||||
export interface DraftListItem {
|
||||
id: string;
|
||||
name: string;
|
||||
furthestStep: 1 | 2 | 3;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface UseDraftPersistenceOptions {
|
||||
currentStep: number;
|
||||
@@ -44,16 +60,12 @@ export interface UseDraftPersistenceOptions {
|
||||
}
|
||||
|
||||
export interface UseDraftPersistenceReturn {
|
||||
drafts: DraftRecord[];
|
||||
drafts: DraftListItem[];
|
||||
currentDraftId: string | null;
|
||||
isHistoryOpen: boolean;
|
||||
renamingDraftId: string | null;
|
||||
renameDraftValue: string;
|
||||
historyDropdownRef: React.MutableRefObject<HTMLDivElement | null>;
|
||||
/**
|
||||
* Shared latch: 加载草稿后置 true,影响 LeftSidebar 在 Step 2 时角色面板的
|
||||
* 初始 status(在线 vs 正在上线)。由主页面在加载完后 read,使用完可手动复位。
|
||||
*/
|
||||
loadedFromDraftRef: React.MutableRefObject<boolean>;
|
||||
setIsHistoryOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
setRenameDraftValue: React.Dispatch<React.SetStateAction<string>>;
|
||||
@@ -61,9 +73,14 @@ export interface UseDraftPersistenceReturn {
|
||||
handleManualSave: () => void;
|
||||
handleLoadDraft: (id: string) => void;
|
||||
handleDeleteDraft: (id: string) => void;
|
||||
handleStartRename: (draft: DraftRecord) => void;
|
||||
handleStartRename: (draft: DraftListItem) => void;
|
||||
handleCommitRename: (id: string) => void;
|
||||
handleCancelRename: () => void;
|
||||
/**
|
||||
* 幂等地保证后端存在一条对应当前会话的草稿,返回其 id(无可保存内容时返回 null)。
|
||||
* 推荐弹窗打开前调用,确保推荐历史有 draft_id 可归属。
|
||||
*/
|
||||
ensureDraft: (furthestStep?: 1 | 2 | 3) => Promise<string | null>;
|
||||
}
|
||||
|
||||
export function useDraftPersistence(
|
||||
@@ -81,8 +98,8 @@ export function useDraftPersistence(
|
||||
setStep2InitGate,
|
||||
} = options;
|
||||
|
||||
const [drafts, setDrafts] = useState<DraftRecord[]>(() => listDrafts());
|
||||
const [currentDraftId, setCurrentDraftId] = useState<string | null>(null);
|
||||
const [drafts, setDrafts] = useState<DraftListItem[]>([]);
|
||||
const [currentDraftId, setCurrentDraftIdState] = useState<string | null>(null);
|
||||
const [isHistoryOpen, setIsHistoryOpen] = useState<boolean>(false);
|
||||
const [renamingDraftId, setRenamingDraftId] = useState<string | null>(null);
|
||||
const [renameDraftValue, setRenameDraftValue] = useState<string>("");
|
||||
@@ -91,95 +108,164 @@ export function useDraftPersistence(
|
||||
const prevStepRef = useRef<number>(currentStep);
|
||||
const historyDropdownRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const buildDraftPayload = useCallback(
|
||||
(
|
||||
furthestStep: 1 | 2 | 3,
|
||||
idOverride?: string | null,
|
||||
): Parameters<typeof upsertDraft>[0] => {
|
||||
const step1 = getStep1Snapshot();
|
||||
const step2 = getStep2Snapshot();
|
||||
const resolvedId = idOverride ?? currentDraftId;
|
||||
return {
|
||||
...(resolvedId ? { id: resolvedId } : {}),
|
||||
name: deriveDraftName({
|
||||
intentReady: step1.intentReady,
|
||||
interactiveMessages: step1.interactiveMessages,
|
||||
}),
|
||||
furthestStep,
|
||||
step1,
|
||||
step2,
|
||||
};
|
||||
// 同步镜像,供保存队列在 render 之前读到最新 id(修复重复建草稿竞态)。
|
||||
const currentDraftIdRef = useRef<string | null>(null);
|
||||
// 串行化所有写操作,避免并发 create。
|
||||
const saveQueueRef = useRef<Promise<unknown>>(Promise.resolve());
|
||||
|
||||
// 包一层 setter:同时更新 state 与同步 ref。主页面通过它 setCurrentDraftId(null)。
|
||||
const setCurrentDraftId = useCallback<React.Dispatch<React.SetStateAction<string | null>>>(
|
||||
(action) => {
|
||||
setCurrentDraftIdState((prev) => {
|
||||
const next = typeof action === "function" ? (action as (p: string | null) => string | null)(prev) : action;
|
||||
currentDraftIdRef.current = next;
|
||||
return next;
|
||||
});
|
||||
},
|
||||
[currentDraftId, getStep1Snapshot, getStep2Snapshot],
|
||||
[],
|
||||
);
|
||||
|
||||
const saveDraft = useCallback(
|
||||
(furthestStep: 1 | 2 | 3): DraftRecord | null => {
|
||||
const step1 = getStep1Snapshot();
|
||||
const step2 = getStep2Snapshot();
|
||||
const hasUserMessage = step1.interactiveMessages.some(
|
||||
(m) => m.sender === "user",
|
||||
const refreshList = useCallback(async () => {
|
||||
try {
|
||||
const metas = await listDrafts();
|
||||
setDrafts(
|
||||
metas.map((m) => ({
|
||||
id: m.id,
|
||||
name: m.title,
|
||||
furthestStep: m.furthestStep,
|
||||
createdAt: m.createdAt,
|
||||
updatedAt: m.updatedAt,
|
||||
})),
|
||||
);
|
||||
if (!hasUserMessage && step2.step2RoundtableDialogues.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const saved = upsertDraft(buildDraftPayload(furthestStep));
|
||||
setCurrentDraftId(saved.id);
|
||||
setDrafts(listDrafts());
|
||||
return saved;
|
||||
} catch (err) {
|
||||
console.warn("[drafts] 刷新草稿列表失败:", err);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 首次挂载拉一次草稿列表。
|
||||
useEffect(() => {
|
||||
void refreshList();
|
||||
}, [refreshList]);
|
||||
|
||||
/** 当前会话是否有值得保存的内容。 */
|
||||
const hasSavableContent = useCallback((step1: Step1Snapshot, step2: Step2Snapshot): boolean => {
|
||||
const hasUserMessage = step1.interactiveMessages.some((m) => m.sender === "user");
|
||||
return hasUserMessage || step2.step2RoundtableDialogues.length > 0;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* 串行执行一次保存:有 id 走 update(不带 title,保护重命名);无 id 走 create
|
||||
* (写一次派生标题)。create/update 成功后同步 currentDraftIdRef。
|
||||
* 返回 draft id(无可保存内容返回 null)。
|
||||
*/
|
||||
const enqueueSave = useCallback(
|
||||
(furthestStep: 1 | 2 | 3): Promise<string | null> => {
|
||||
const run = async (): Promise<string | null> => {
|
||||
const step1 = getStep1Snapshot();
|
||||
const step2 = getStep2Snapshot();
|
||||
if (!hasSavableContent(step1, step2)) return null;
|
||||
|
||||
const id = currentDraftIdRef.current;
|
||||
if (id) {
|
||||
const updated = await updateDraft(id, { furthestStep, step1, step2 });
|
||||
if (updated) return updated.id;
|
||||
// 服务端已不存在(被删/换账号)→ 落回新建。
|
||||
}
|
||||
const created = await createDraft({
|
||||
title: deriveDraftName({
|
||||
intentReady: step1.intentReady,
|
||||
interactiveMessages: step1.interactiveMessages,
|
||||
}),
|
||||
furthestStep,
|
||||
step1,
|
||||
step2,
|
||||
});
|
||||
currentDraftIdRef.current = created.id;
|
||||
setCurrentDraftId(created.id);
|
||||
return created.id;
|
||||
};
|
||||
const next = saveQueueRef.current.then(run, run);
|
||||
saveQueueRef.current = next.catch(() => undefined);
|
||||
return next as Promise<string | null>;
|
||||
},
|
||||
[buildDraftPayload, getStep1Snapshot, getStep2Snapshot],
|
||||
[getStep1Snapshot, getStep2Snapshot, hasSavableContent, setCurrentDraftId],
|
||||
);
|
||||
|
||||
const ensureDraft = useCallback(
|
||||
async (furthestStep: 1 | 2 | 3 = (currentStep as 1 | 2 | 3) || 1): Promise<string | null> => {
|
||||
if (currentDraftIdRef.current) return currentDraftIdRef.current;
|
||||
const id = await enqueueSave(furthestStep);
|
||||
if (id) await refreshList();
|
||||
return id;
|
||||
},
|
||||
[currentStep, enqueueSave, refreshList],
|
||||
);
|
||||
|
||||
const handleManualSave = useCallback(() => {
|
||||
const furthest = (currentStep as 1 | 2 | 3) ?? 1;
|
||||
const saved = saveDraft(furthest);
|
||||
if (saved) {
|
||||
triggerToast(`💾 已保存为草稿:${saved.name}`);
|
||||
} else {
|
||||
triggerToast("当前会话还没有可保存的内容");
|
||||
}
|
||||
}, [currentStep, saveDraft, triggerToast]);
|
||||
const furthest = (currentStep as 1 | 2 | 3) || 1;
|
||||
void (async () => {
|
||||
const id = await enqueueSave(furthest);
|
||||
if (id) {
|
||||
await refreshList();
|
||||
triggerToast("💾 已保存为草稿");
|
||||
} else {
|
||||
triggerToast("当前会话还没有可保存的内容");
|
||||
}
|
||||
})();
|
||||
}, [currentStep, enqueueSave, refreshList, triggerToast]);
|
||||
|
||||
// 前进切换时自动保存;后退不保存以避免覆盖 furthestStep。
|
||||
useEffect(() => {
|
||||
const prev = prevStepRef.current;
|
||||
prevStepRef.current = currentStep;
|
||||
if (currentStep > prev) {
|
||||
saveDraft(currentStep as 1 | 2 | 3);
|
||||
void (async () => {
|
||||
const id = await enqueueSave(currentStep as 1 | 2 | 3);
|
||||
if (id) await refreshList();
|
||||
})();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentStep]);
|
||||
|
||||
const handleLoadDraft = useCallback(
|
||||
(id: string) => {
|
||||
const draft = drafts.find((d) => d.id === id) ?? null;
|
||||
if (!draft) {
|
||||
triggerToast("⚠️ 该草稿已不存在");
|
||||
setDrafts(listDrafts());
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
let draft;
|
||||
try {
|
||||
draft = await getDraft(id);
|
||||
} catch (err) {
|
||||
console.warn("[drafts] 加载草稿失败:", err);
|
||||
triggerToast("⚠️ 加载草稿失败,请重试");
|
||||
return;
|
||||
}
|
||||
if (!draft) {
|
||||
triggerToast("⚠️ 该草稿已不存在");
|
||||
await refreshList();
|
||||
return;
|
||||
}
|
||||
|
||||
cancelAllStreams();
|
||||
// 先置 latch,再 setCurrentStep —— 顺序反过来会让 step1/step2 init effect
|
||||
// 把 loadedFromDraftRef.current 当成 false 处理,导致角色面板卡在「正在上线」。
|
||||
loadedFromDraftRef.current = true;
|
||||
cancelAllStreams();
|
||||
// 先置 latch,再 setCurrentStep —— 顺序反过来会让 step1/step2 init effect
|
||||
// 把 loadedFromDraftRef.current 当成 false 处理,导致角色面板卡在「正在上线」。
|
||||
loadedFromDraftRef.current = true;
|
||||
|
||||
hydrateStep1(draft.step1 as Step1Snapshot);
|
||||
hydrateStep2(draft.step2 as Step2Snapshot);
|
||||
setStep2InitGate(draft.furthestStep >= 2);
|
||||
if (draft.step1) hydrateStep1(draft.step1 as Step1Snapshot);
|
||||
if (draft.step2) hydrateStep2(draft.step2 as Step2Snapshot);
|
||||
setStep2InitGate(draft.furthestStep >= 2);
|
||||
|
||||
setCurrentDraftId(draft.id);
|
||||
setIsHistoryOpen(false);
|
||||
prevStepRef.current = draft.furthestStep;
|
||||
setCurrentStep(draft.furthestStep);
|
||||
triggerToast(`📂 已加载草稿:${draft.name}`);
|
||||
setCurrentDraftId(draft.id);
|
||||
setIsHistoryOpen(false);
|
||||
prevStepRef.current = draft.furthestStep;
|
||||
setCurrentStep(draft.furthestStep);
|
||||
triggerToast(`📂 已加载草稿:${draft.title}`);
|
||||
})();
|
||||
},
|
||||
[
|
||||
cancelAllStreams,
|
||||
drafts,
|
||||
hydrateStep1,
|
||||
hydrateStep2,
|
||||
refreshList,
|
||||
setCurrentDraftId,
|
||||
setCurrentStep,
|
||||
setStep2InitGate,
|
||||
triggerToast,
|
||||
@@ -191,31 +277,54 @@ export function useDraftPersistence(
|
||||
if (typeof window !== "undefined" && !window.confirm("确定要删除这条历史记录吗?此操作不可恢复。")) {
|
||||
return;
|
||||
}
|
||||
deleteDraft(id);
|
||||
setDrafts(listDrafts());
|
||||
if (currentDraftId === id) setCurrentDraftId(null);
|
||||
if (renamingDraftId === id) setRenamingDraftId(null);
|
||||
triggerToast("🗑 已删除历史记录");
|
||||
void (async () => {
|
||||
try {
|
||||
await deleteDraft(id);
|
||||
} catch (err) {
|
||||
console.warn("[drafts] 删除草稿失败:", err);
|
||||
triggerToast("⚠️ 删除失败,请重试");
|
||||
return;
|
||||
}
|
||||
await refreshList();
|
||||
if (currentDraftIdRef.current === id) setCurrentDraftId(null);
|
||||
if (renamingDraftId === id) setRenamingDraftId(null);
|
||||
triggerToast("🗑 已删除历史记录");
|
||||
})();
|
||||
},
|
||||
[currentDraftId, renamingDraftId, triggerToast],
|
||||
[refreshList, renamingDraftId, setCurrentDraftId, triggerToast],
|
||||
);
|
||||
|
||||
const handleStartRename = useCallback((draft: DraftRecord) => {
|
||||
const handleStartRename = useCallback((draft: DraftListItem) => {
|
||||
setRenamingDraftId(draft.id);
|
||||
setRenameDraftValue(draft.name);
|
||||
}, []);
|
||||
|
||||
const handleCommitRename = useCallback(
|
||||
(id: string) => {
|
||||
const updated = renameDraft(id, renameDraftValue);
|
||||
if (updated) {
|
||||
setDrafts(listDrafts());
|
||||
triggerToast("✏️ 已重命名");
|
||||
const trimmed = renameDraftValue.trim();
|
||||
if (!trimmed) {
|
||||
setRenamingDraftId(null);
|
||||
setRenameDraftValue("");
|
||||
return;
|
||||
}
|
||||
setRenamingDraftId(null);
|
||||
setRenameDraftValue("");
|
||||
void (async () => {
|
||||
try {
|
||||
// 只发 title —— 与自动保存的「不带 title」互补,重命名是唯一改标题的入口。
|
||||
const updated = await updateDraft(id, { title: trimmed });
|
||||
if (updated) {
|
||||
await refreshList();
|
||||
triggerToast("✏️ 已重命名");
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[drafts] 重命名失败:", err);
|
||||
triggerToast("⚠️ 重命名失败,请重试");
|
||||
} finally {
|
||||
setRenamingDraftId(null);
|
||||
setRenameDraftValue("");
|
||||
}
|
||||
})();
|
||||
},
|
||||
[renameDraftValue, triggerToast],
|
||||
[refreshList, renameDraftValue, triggerToast],
|
||||
);
|
||||
|
||||
const handleCancelRename = useCallback(() => {
|
||||
@@ -253,5 +362,6 @@ export function useDraftPersistence(
|
||||
handleStartRename,
|
||||
handleCommitRename,
|
||||
handleCancelRename,
|
||||
ensureDraft,
|
||||
};
|
||||
}
|
||||
@@ -22,7 +22,11 @@ import {
|
||||
type IntentStreamPhase,
|
||||
type IntentSummary,
|
||||
} from "@/roundtable-planning/api/intent";
|
||||
import { formatIntentClarificationAnswer, type IntentClarificationSelection } from "@/roundtable-planning/components/IntentClarificationCard";
|
||||
import {
|
||||
clarificationKey,
|
||||
formatIntentClarificationAnswer,
|
||||
type IntentClarificationSelection,
|
||||
} from "@/roundtable-planning/components/IntentClarificationCard";
|
||||
import type { ClarificationPayload } from "@/roundtable-planning/api/multi-agent";
|
||||
import {
|
||||
nowTime,
|
||||
@@ -38,7 +42,15 @@ export type InteractiveMessage = {
|
||||
time: string;
|
||||
streaming?: boolean;
|
||||
phase?: string;
|
||||
/** First clarification (back-compat); prefer `clarifications`. */
|
||||
clarification?: ClarificationPayload;
|
||||
/**
|
||||
* All `ask_clarification` questions the agent asked this turn (the agent may
|
||||
* ask several at once). Populated live from the stream so each question card
|
||||
* appears in real-time. Each carries a stable `id` (tool_call_id) for keying
|
||||
* per-question selections.
|
||||
*/
|
||||
clarifications?: ClarificationPayload[];
|
||||
/**
|
||||
* ChainOfThought 折叠卡的步骤累积。每次 `onPhaseChange` 都会把当前 phase + toolName
|
||||
* 拼成 `phase:toolName` 作为 key,与 Step 2 的 `Step2Dialogue.steps` 同形。
|
||||
@@ -86,23 +98,30 @@ export interface UseStep1IntentReturn {
|
||||
intentInitErrorDetail: IntentErrorDetail | null;
|
||||
isIntentSending: boolean;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<number, IntentClarificationSelection>;
|
||||
/** Per-question selections, keyed by `clarificationKey(msgId, clarId, index)`. */
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
interactiveMessages: InteractiveMessage[];
|
||||
timelineEntries: TimelineEntry[];
|
||||
// ─── Mutators ────────────────────────────────────────────────────────
|
||||
setIntentClarificationSelections: React.Dispatch<
|
||||
React.SetStateAction<Map<number, IntentClarificationSelection>>
|
||||
React.SetStateAction<Map<string, IntentClarificationSelection>>
|
||||
>;
|
||||
// ─── Handlers ────────────────────────────────────────────────────────
|
||||
/** 清空当前 Step 1 状态并重新拉取 intent thread。 */
|
||||
runStep1Init: () => void;
|
||||
/** 把 `userText` 作为用户气泡发给 intent agent,流式渲染回复。 */
|
||||
sendIntentMessage: (userText: string) => Promise<void>;
|
||||
/** 提交澄清卡片的选项 / 自定义回答。 */
|
||||
submitIntentClarification: (
|
||||
/**
|
||||
* 提交某条 agent 消息的全部澄清问题答案 —— 逐题取各自选择,拼成一条合并消息
|
||||
* 发回。至少答一题才会发送。单题时退化为发送该题答案。
|
||||
*
|
||||
* `overrideByKey`:单题「点击即发送」用 —— 单选卡点击选项时选择还没写进 state
|
||||
* map(setState 异步),把该题的即时选择按 `clarificationKey` 传进来直接用。
|
||||
*/
|
||||
submitIntentClarifications: (
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => void;
|
||||
/** Abort 当前 intent 流。气泡尾部追加「(已暂停)」并 toast。 */
|
||||
stopIntentStream: () => void;
|
||||
@@ -143,7 +162,7 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
const [pendingIntentClarificationMsgId, setPendingIntentClarificationMsgId] =
|
||||
useState<number | null>(null);
|
||||
const [intentClarificationSelections, setIntentClarificationSelections] = useState<
|
||||
Map<number, IntentClarificationSelection>
|
||||
Map<string, IntentClarificationSelection>
|
||||
>(new Map());
|
||||
|
||||
// 原始页面带了一段写死的 demo 对话,只是首次进入 Step 1 还没初始化前的占位;
|
||||
@@ -355,10 +374,53 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
}),
|
||||
);
|
||||
},
|
||||
onClarification: (clarification, index) => {
|
||||
// 实时把每条澄清问题灌进气泡 —— 用户能边流边看到「协助过程」逐个出现,
|
||||
// 而不是等终态帧(终态帧只带第 1 个问题)。同时往步骤链补一条
|
||||
// 「追问 N:<问题>」,与「强化步骤链」诉求对齐。
|
||||
const clarId = clarification.id ?? `idx-${index}`;
|
||||
const stepKey = `clarification:${clarId}`;
|
||||
const qLabel = clarification.question
|
||||
? `追问 ${index + 1}:${
|
||||
clarification.question.length > 24
|
||||
? clarification.question.slice(0, 24) + "…"
|
||||
: clarification.question
|
||||
}`
|
||||
: `追问 ${index + 1}`;
|
||||
setInteractiveMessages((prev) =>
|
||||
prev.map((m) => {
|
||||
if (m.id !== agentMsgId) return m;
|
||||
const list = m.clarifications ?? [];
|
||||
// 按 id 去重 / 覆盖,流式重发同一条时不重复 push。
|
||||
const existingIdx = list.findIndex(
|
||||
(c) => (c.id ?? "") === (clarification.id ?? ""),
|
||||
);
|
||||
const nextList =
|
||||
existingIdx >= 0 && clarification.id
|
||||
? list.map((c, i) => (i === existingIdx ? clarification : c))
|
||||
: [...list, clarification];
|
||||
const steps = m.steps ?? [];
|
||||
const hasStep = steps.some((s) => s.key === stepKey);
|
||||
const nextSteps = hasStep
|
||||
? steps
|
||||
: [
|
||||
...steps,
|
||||
{
|
||||
id: `${agentMsgId}-clar-${clarId}`,
|
||||
key: stepKey,
|
||||
label: qLabel,
|
||||
ts: nowTime(),
|
||||
},
|
||||
];
|
||||
return { ...m, clarifications: nextList, steps: nextSteps };
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
const parsedFromContent = splitIntentReadyBlock(res.content || "").summary;
|
||||
const resolvedSummary = res.summary ?? parsedFromContent;
|
||||
|
||||
const finalClarifications = resolvedSummary ? [] : res.clarifications;
|
||||
setInteractiveMessages((prev) =>
|
||||
prev.map((m) =>
|
||||
m.id === agentMsgId
|
||||
@@ -366,9 +428,13 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
...m,
|
||||
content: res.content || m.content || "(无文本输出)",
|
||||
streaming: false,
|
||||
// 终态以 res.clarifications 为权威集合(覆盖流式期增量构建的),
|
||||
// 既保证多问题完整,也在解析出 summary 时清空澄清卡。
|
||||
clarification: resolvedSummary
|
||||
? undefined
|
||||
: res.clarification ?? undefined,
|
||||
clarifications:
|
||||
finalClarifications.length > 0 ? finalClarifications : undefined,
|
||||
}
|
||||
: m,
|
||||
),
|
||||
@@ -390,11 +456,14 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
},
|
||||
]);
|
||||
triggerToast("✅ 任务理解完成,可进入多智能体圆桌研讨");
|
||||
} else if (res.status === "clarification" && res.clarification) {
|
||||
} else if (res.status === "clarification" && res.clarifications.length > 0) {
|
||||
setPendingIntentClarificationMsgId(agentMsgId);
|
||||
setIntentClarificationSelections((prev) => {
|
||||
const next = new Map(prev);
|
||||
next.set(agentMsgId, { selectedIds: [], custom: "" });
|
||||
res.clarifications.forEach((c, i) => {
|
||||
const key = clarificationKey(agentMsgId, c.id, i);
|
||||
if (!next.has(key)) next.set(key, { selectedIds: [], custom: "" });
|
||||
});
|
||||
return next;
|
||||
});
|
||||
} else if (res.status === "error") {
|
||||
@@ -448,24 +517,37 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
[intentThreadId, triggerToast],
|
||||
);
|
||||
|
||||
const submitIntentClarification = useCallback(
|
||||
const submitIntentClarifications = useCallback(
|
||||
(
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => {
|
||||
const selection =
|
||||
overrideSelection ??
|
||||
intentClarificationSelections.get(msgId) ?? {
|
||||
selectedIds: [],
|
||||
custom: "",
|
||||
};
|
||||
const answer = formatIntentClarificationAnswer(payload, selection);
|
||||
if (!answer) {
|
||||
triggerToast("请先选择选项或输入回答");
|
||||
// 逐题取选择并格式化;只把答了的题拼进去。
|
||||
const answered = clarifications
|
||||
.map((payload, index) => {
|
||||
const key = clarificationKey(msgId, payload.id, index);
|
||||
const selection =
|
||||
overrideByKey?.[key] ??
|
||||
intentClarificationSelections.get(key) ?? { selectedIds: [], custom: "" };
|
||||
const answer = formatIntentClarificationAnswer(payload, selection);
|
||||
return answer ? { question: payload.question, answer } : null;
|
||||
})
|
||||
.filter((x): x is { question: string; answer: string } => x !== null);
|
||||
|
||||
if (answered.length === 0) {
|
||||
triggerToast("请至少回答一个问题");
|
||||
return;
|
||||
}
|
||||
void sendIntentMessage(answer);
|
||||
|
||||
// 单题:直接发答案(与旧行为一致)。多题:带上问题做编号 Q/A,合并成一条消息。
|
||||
const combined =
|
||||
answered.length === 1
|
||||
? answered[0].answer
|
||||
: answered
|
||||
.map((qa, i) => `${i + 1}. ${qa.question}\n答:${qa.answer}`)
|
||||
.join("\n\n");
|
||||
void sendIntentMessage(combined);
|
||||
},
|
||||
[intentClarificationSelections, sendIntentMessage, triggerToast],
|
||||
);
|
||||
@@ -499,7 +581,7 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
setIntentClarificationSelections,
|
||||
runStep1Init,
|
||||
sendIntentMessage,
|
||||
submitIntentClarification,
|
||||
submitIntentClarifications,
|
||||
stopIntentStream,
|
||||
hydrateFromDraft,
|
||||
appendLocalMessage,
|
||||
|
||||
@@ -84,6 +84,13 @@ export type AgentConfig = {
|
||||
|
||||
/** 草稿持久化的 Step 2 快照。 */
|
||||
export type Step2Snapshot = {
|
||||
/**
|
||||
* 本次研讨实际选中的席位 —— 加载草稿后据此重建左侧「参与角色」面板。
|
||||
* 不存的话(2026-06 之前的旧草稿)hydrate 会回退到 DEFAULT_SELECTED_AGENTS,
|
||||
* 导致 Step 2/3 左侧显示默认 6 个而非当时真正选的那几个。反序列化时
|
||||
* 老草稿按 undefined 兜底(保留当前 selectedAgents,不强行覆盖)。
|
||||
*/
|
||||
selectedAgents?: SelectedAgent[];
|
||||
threadIds: ThreadIdMap | null;
|
||||
coordinatorName: string | null;
|
||||
step2RoundtableDialogues: Step2Dialogue[];
|
||||
@@ -833,16 +840,19 @@ export function useStep2Orchestration(
|
||||
|
||||
const markSpeakerStreaming = useCallback(
|
||||
(speakerId: number) => {
|
||||
setActiveSpeakerSet((prev) => {
|
||||
if (prev.has(speakerId)) return prev;
|
||||
const next = new Set(prev);
|
||||
next.add(speakerId);
|
||||
return next;
|
||||
});
|
||||
// 编排循环已经改成**顺序**派 special(详见 §5.4 / 文件顶部注释),
|
||||
// 任意时刻只有一个子智能体在跑。因此这里既要把当前发言席位置为"研讨中",
|
||||
// 又要把上一轮 / 历史残留下来的"研讨中"统一清成"在线",保证右侧"参与角色"
|
||||
// 面板任何时刻**只有一个** sub agent 显示研讨中,与对话区实际在 stream 的
|
||||
// 那一个一致。activeSpeakerSet 沿用 Set 形态(虽然实际只放 1 个)以兼容外部
|
||||
// 消费方,真正的"高亮排他"靠 roles 的 status reset。
|
||||
setActiveSpeakerSet(() => new Set([speakerId]));
|
||||
setRoles((prev) =>
|
||||
prev.map((item) =>
|
||||
item.id === speakerId ? { ...item, status: "研讨中" } : item,
|
||||
),
|
||||
prev.map((item) => {
|
||||
if (item.id === speakerId) return { ...item, status: "研讨中" };
|
||||
if (item.status === "研讨中") return { ...item, status: "在线" };
|
||||
return item;
|
||||
}),
|
||||
);
|
||||
},
|
||||
[setRoles],
|
||||
@@ -912,7 +922,14 @@ export function useStep2Orchestration(
|
||||
safetyCounter < MAX_CYCLES
|
||||
) {
|
||||
safetyCounter += 1;
|
||||
highlightSpeaker(2);
|
||||
// Leader(协调智能体)正在派活,**不应该**让任何 sub agent 显示"研讨中"——
|
||||
// 协调者本身不在右侧"参与角色"面板里(COMMANDER_SEAT_ID=1 是人类主持人,
|
||||
// sub agent 从 id=2 起)。历史代码这里写的是 `highlightSpeaker(2)`,会
|
||||
// 错把第一个 sub agent 误标为研讨中,叠加 special 派活时另一个 sub 也被
|
||||
// markSpeakerStreaming,就出现"两个 sub 同时研讨中"的视觉 bug。
|
||||
// 改成 null 后:leader 跑的阶段所有 sub 都是"在线",special 跑哪个就只
|
||||
// 高亮哪个。activeSpeakerId 同步置空,圆桌可视化也不会高亮错的位置。
|
||||
highlightSpeaker(null);
|
||||
|
||||
// 总控也可能直接 write_file —— 之前只接了 special 流,导致总控写文件时沙箱不自动打开。
|
||||
// 这里把 leader thread id 绑到气泡 + artifact handler 上,与 special 同样的行为。
|
||||
@@ -1410,6 +1427,12 @@ export function useStep2Orchestration(
|
||||
setPendingClarification(null);
|
||||
setClarificationDraft("");
|
||||
|
||||
// 先恢复 selectedAgents —— roleTemplates / agentNameToRole 都由它派生,
|
||||
// 主页面的「参与角色」面板据此重建,否则会停留在默认 6 个席位。
|
||||
// 老草稿没有这字段时保持当前值不动(避免清空成空数组)。
|
||||
if (snapshot.selectedAgents && snapshot.selectedAgents.length > 0) {
|
||||
setSelectedAgents(snapshot.selectedAgents);
|
||||
}
|
||||
setThreadIds(snapshot.threadIds);
|
||||
setCoordinatorName(snapshot.coordinatorName);
|
||||
setStep2RoundtableDialogues(snapshot.step2RoundtableDialogues);
|
||||
|
||||
@@ -130,8 +130,27 @@ export function nowTime(): string {
|
||||
return new Date().toLocaleTimeString("zh-CN", { hour12: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* 圆桌总控协调智能体的**固定单例 id**。后端 `_roundtable_seed.COORDINATOR_AGENT_ID`
|
||||
* 与本常量必须保持一致(2026-05 改造前是 `roundtable-coordinator-<ts36>` 形式,
|
||||
* 每次会话生成新 id 导致 `.deer-flow/agents/` 累积大量壳目录)。
|
||||
*
|
||||
* 改造后:
|
||||
* - 后端 ensure 机制保证磁盘上始终存在 `.deer-flow/agents/roundtable-coordinator/`;
|
||||
* - 本次会话的「可调度席位列表」由后端 init 通过 human 消息注入 coordinator
|
||||
* thread 历史,不再写入 SOUL,所以单例 SOUL 长期稳定;
|
||||
* - 前端 `streamMultiAgent({ coordinatorName })` 等位置不需要任何改动,因为
|
||||
* `coordinatorName` 仍然是一个**字符串**,只是值不再每次变化。
|
||||
*/
|
||||
export const COORDINATOR_AGENT_ID = "roundtable-coordinator";
|
||||
|
||||
/**
|
||||
* 兼容性保留:历史上叫 `newCoordinatorName()`,意为"生成新的一次性 coordinator id"。
|
||||
* 改造为单例后实际只返回常量;命名不再准确,但留下避免触发跨文件级联改名。
|
||||
* 新代码请直接使用 {@link COORDINATOR_AGENT_ID}。
|
||||
*/
|
||||
export function newCoordinatorName(): string {
|
||||
return `roundtable-coordinator-${Date.now().toString(36)}`;
|
||||
return COORDINATOR_AGENT_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,8 +63,6 @@ import { useStep2Orchestration } from "@/roundtable-planning/hooks/useStep2Orche
|
||||
import { useDraftPersistence } from "@/roundtable-planning/hooks/useDraftPersistence";
|
||||
import {
|
||||
BUILTIN_AGENT_META,
|
||||
getAvatarTypeFor,
|
||||
getDisplayNameFor,
|
||||
makeRolesFromTemplates,
|
||||
nowTime,
|
||||
type RoleEntry,
|
||||
@@ -187,6 +185,7 @@ export default function RoundtablePlanningPage() {
|
||||
timelineEntries: step1.timelineEntries,
|
||||
}),
|
||||
getStep2Snapshot: () => ({
|
||||
selectedAgents: step2.selectedAgents,
|
||||
threadIds: step2.threadIds,
|
||||
coordinatorName: step2.coordinatorName,
|
||||
step2RoundtableDialogues: step2.step2RoundtableDialogues,
|
||||
@@ -320,6 +319,7 @@ export default function RoundtablePlanningPage() {
|
||||
open={isRecommendDialogOpen}
|
||||
intent={step1.intentReady}
|
||||
model={selectedModel || undefined}
|
||||
draftId={drafts.currentDraftId}
|
||||
onCancel={() => setIsRecommendDialogOpen(false)}
|
||||
onConfirm={handleConfirmAgents}
|
||||
/>
|
||||
@@ -437,7 +437,6 @@ export default function RoundtablePlanningPage() {
|
||||
currentStep={currentStep}
|
||||
roles={roles}
|
||||
agentNameToRole={step2.agentNameToRole}
|
||||
selectedAgents={step2.selectedAgents}
|
||||
budgetLimit={step2.budgetLimit}
|
||||
intentReady={step1.intentReady}
|
||||
sidebarExpanded={step2SidebarExpanded}
|
||||
@@ -467,11 +466,13 @@ export default function RoundtablePlanningPage() {
|
||||
triggerToast("⚠️ 请先与任务理解智能体完成澄清,生成任务摘要后再进入");
|
||||
return;
|
||||
}
|
||||
setIsRecommendDialogOpen(true);
|
||||
// 先把草稿落地拿到 draft_id,推荐历史才有归属;失败也照常打开弹窗
|
||||
// (弹窗在无 draftId 时退化为「直接推荐、不存历史」)。
|
||||
void drafts.ensureDraft(1).finally(() => setIsRecommendDialogOpen(true));
|
||||
}}
|
||||
onManualSave={drafts.handleManualSave}
|
||||
onTriggerToast={triggerToast}
|
||||
submitIntentClarification={step1.submitIntentClarification}
|
||||
submitIntentClarifications={step1.submitIntentClarifications}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -811,7 +812,6 @@ interface LeftSidebarProps {
|
||||
string,
|
||||
{ speakerId: number; avatarType: string; displayName: string }
|
||||
>;
|
||||
selectedAgents: SelectedAgent[];
|
||||
budgetLimit: number;
|
||||
intentReady: ReturnType<typeof useStep1Intent>["intentReady"];
|
||||
sidebarExpanded: boolean;
|
||||
@@ -848,7 +848,6 @@ function LeftSidebar({
|
||||
currentStep,
|
||||
roles,
|
||||
agentNameToRole,
|
||||
selectedAgents,
|
||||
budgetLimit: _budgetLimit,
|
||||
intentReady,
|
||||
sidebarExpanded,
|
||||
@@ -856,6 +855,10 @@ function LeftSidebar({
|
||||
}: LeftSidebarProps) {
|
||||
const isStep2 = currentStep === 2;
|
||||
|
||||
// Step 3 隐藏左侧栏(原「参与与结论贡献」列),让中间「最终方案展示」自适应
|
||||
// 撑满整行宽度(右侧栏在 Step !==1 时也已 return null)。
|
||||
if (currentStep === 3) return null;
|
||||
|
||||
return (
|
||||
<section
|
||||
id="left-sidebar"
|
||||
@@ -876,55 +879,7 @@ function LeftSidebar({
|
||||
</button>
|
||||
)}
|
||||
|
||||
{currentStep === 3 ? (
|
||||
<>
|
||||
{/* Step 3 时只保留「参与与结论贡献」面板;原文件里其它两个 hidden 块未启用,
|
||||
删掉以降低维护负担,需要时去 git history 翻 fdeffde 之前的 commit。 */}
|
||||
<div className="bg-white border border-slate-200/50 rounded-2xl p-4.5 shadow-[0_2px_8px_rgba(0,0,0,0.015)] flex-1 flex flex-col min-h-[300px]">
|
||||
<div className="flex items-center gap-2 border-b border-slate-100 pb-2.5 mb-3">
|
||||
<Users className="w-4 h-4 text-primary" strokeWidth={2.5} />
|
||||
<h2 className="text-xs font-black text-slate-900 uppercase tracking-widest">参与与结论贡献</h2>
|
||||
</div>
|
||||
<div className="space-y-2 overflow-y-auto flex-1 pr-1 custom-scrollbar">
|
||||
{[
|
||||
{
|
||||
id: "human",
|
||||
name: "用户 (指挥官)",
|
||||
role: "人类介入协调",
|
||||
icon: <Man1Avatar size="h-7 w-7" />,
|
||||
},
|
||||
...selectedAgents.map((agent, i) => ({
|
||||
id: agent.agent_id,
|
||||
name: getDisplayNameFor(agent),
|
||||
role: BUILTIN_AGENT_META[agent.agent_id]
|
||||
? `${BUILTIN_AGENT_META[agent.agent_id].displayName} 席位`
|
||||
: "圆桌席位",
|
||||
icon: getAvatar(getAvatarTypeFor(agent.agent_id, i), "h-7 w-7"),
|
||||
})),
|
||||
].map((contrib, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex items-center justify-between p-2 rounded-xl bg-slate-50 border border-slate-100 transition hover:border-emerald-100 hover:bg-emerald-50/10"
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
{contrib.icon}
|
||||
<div className="flex flex-col">
|
||||
<span className="text-xs font-bold text-slate-800 tracking-tight leading-tight">
|
||||
{contrib.name}
|
||||
</span>
|
||||
<span className="text-[9px] text-primary font-semibold">{contrib.role}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 shrink-0 text-emerald-600 bg-emerald-50 font-bold text-[9.5px] px-1.5 py-0.5 rounded-full">
|
||||
<Check className="h-3 w-3 text-emerald-500 font-black" />
|
||||
已贡献
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : currentStep === 2 ? (
|
||||
{currentStep === 2 ? (
|
||||
sidebarExpanded ? (
|
||||
<>
|
||||
<IntentSummaryCard
|
||||
|
||||
@@ -21,9 +21,41 @@
|
||||
background: #fddadc;
|
||||
}
|
||||
|
||||
/* 深色模式:跟随全局 ThemeContext(html.dark)或组件 .roundtable-planning--dark */
|
||||
/* 深色模式:跟随全局 ThemeContext(html.dark)或组件 .roundtable-planning--dark
|
||||
*
|
||||
* 仅在本页 + 深色下,把语义 token 覆盖为《深蓝色 UI 规范》取值
|
||||
* (docs/ui规范-深蓝/tokens.css,§1 深蓝系 ZS-004 / 渐蓝系 ZS-002)。
|
||||
* 全模块组件均经由这些 token(bg-background / text-foreground / border-border …)
|
||||
* 着色,所以这里统一覆盖即可整页换肤;浅色模式(无 .dark)保持红色主题不受影响。 */
|
||||
.dark .roundtable-planning,
|
||||
.roundtable-planning--dark {
|
||||
/* —— 背景 / 容器(ZS-004 深蓝系) —— */
|
||||
--background: #0c1836; /* zs-004-09 页面背景 */
|
||||
--foreground: #c5cfe0; /* zs-004-02 正文字体 */
|
||||
--card: #122347; /* zs-004-08 卡片背景 */
|
||||
--card-foreground: #c5cfe0;
|
||||
--popover: #122347; /* 下拉 / 浮层与卡片同底 */
|
||||
--popover-foreground: #c5cfe0;
|
||||
--muted: #16294d; /* 次级容器(步骤条 / slate-50 表面) */
|
||||
--muted-foreground: #6e88b0; /* zs-004-04 次级字体 */
|
||||
--secondary: #1a2f5a; /* zs-004-07 次级按钮底 */
|
||||
--secondary-foreground: #c5cfe0;
|
||||
--accent: #1a2f5a; /* hover / 软高亮表面 */
|
||||
--accent-foreground: #e8edf5; /* zs-004-01 */
|
||||
|
||||
/* —— 主色 / 链接(ZS-002 渐蓝系) —— */
|
||||
--primary: #1677ff; /* zs-002-06 主操作 */
|
||||
--primary-foreground: #ffffff;
|
||||
--ring: rgba(22, 119, 255, 0.45);
|
||||
|
||||
/* —— 边框 / 控件描边(取较浅阶以保证深底上可见) —— */
|
||||
--border: #2d4473; /* zs-004-06 容器边框 */
|
||||
--input: #4a6491; /* zs-004-05 控件描边 */
|
||||
|
||||
/* —— 功能语义色 —— */
|
||||
--destructive: #f5222d; /* zs-001-06 错误 */
|
||||
|
||||
/* —— 圆桌局部别名(回落到上面已覆盖的 token) —— */
|
||||
--rt-page-bg: var(--background);
|
||||
--rt-primary: var(--primary);
|
||||
--rt-primary-hover: var(--primary);
|
||||
@@ -47,98 +79,226 @@
|
||||
background: color-mix(in oklch, var(--primary) 35%, transparent);
|
||||
}
|
||||
|
||||
/* 页面底与浅色专用背景 */
|
||||
.dark .roundtable-planning.bg-\[\#fef6f6\],
|
||||
.roundtable-planning--dark.bg-\[\#fef6f6\] {
|
||||
/* =============================================================================
|
||||
* 深色兜底映射 —— 把组件里写死的浅色 Tailwind 类映射到上面的深蓝 token。
|
||||
*
|
||||
* 这些组件原本只为浅色红主题写死了 slate / white / emerald 等色,深色靠这里
|
||||
* 统一改写。作用域 :is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
* 同时覆盖「全局 html.dark」与「组件 --dark 修饰类」两种触发方式;浅色模式
|
||||
* (无 .dark / 无 --dark)完全不命中,红主题不受影响。
|
||||
*
|
||||
* 维护:组件里新增写死颜色时,往下面对应分组补一行即可,不要在组件里写
|
||||
* `dark:` 变体与本表打架(本表用 !important,会盖过同元素的 dark: 变体)。
|
||||
* ========================================================================== */
|
||||
|
||||
/* ---- 页面底色:浅红 → 深蓝页面底 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark).bg-\[\#fef6f6\],
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .bg-\[\#fef6f6\] {
|
||||
background-color: var(--background) !important;
|
||||
}
|
||||
|
||||
/* 表面:白底卡片 → card */
|
||||
.dark .roundtable-planning .bg-white,
|
||||
.roundtable-planning--dark .bg-white {
|
||||
/* ---- 表面:白 / 近白底 → 卡片底 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.bg-white, .hover\:bg-white:hover, .bg-\[\#fcfcfd\], .bg-\[\#fffdfa\]) {
|
||||
background-color: var(--card) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .bg-slate-50,
|
||||
.dark .roundtable-planning .bg-slate-50\/20,
|
||||
.dark .roundtable-planning .bg-slate-50\/30,
|
||||
.roundtable-planning--dark .bg-slate-50,
|
||||
.roundtable-planning--dark .bg-slate-50\/20,
|
||||
.roundtable-planning--dark .bg-slate-50\/30 {
|
||||
background-color: color-mix(in oklch, var(--muted) 80%, transparent) !important;
|
||||
/* ---- 次级表面:slate-50/100(含透明度档)→ muted ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.bg-slate-50, .bg-slate-50\/20, .bg-slate-50\/30, .bg-slate-50\/50,
|
||||
.bg-slate-50\/60, .bg-slate-50\/80, .bg-slate-100, .bg-slate-100\/80
|
||||
) {
|
||||
background-color: var(--muted) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .from-slate-50,
|
||||
.roundtable-planning--dark .from-slate-50 {
|
||||
/* ---- 次级表面 hover → accent ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.hover\:bg-slate-50:hover, .hover\:bg-slate-50\/60:hover,
|
||||
.hover\:bg-slate-100:hover
|
||||
) {
|
||||
background-color: var(--accent) !important;
|
||||
}
|
||||
|
||||
/* ---- 禁用 / 较实的中性底 → secondary ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.bg-slate-300, .disabled\:bg-slate-300:disabled) {
|
||||
background-color: var(--secondary) !important;
|
||||
}
|
||||
|
||||
/* ---- slate-200 作分隔条 → border 色 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .bg-slate-200 {
|
||||
background-color: var(--border) !important;
|
||||
}
|
||||
|
||||
/* ---- 渐变端点 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .from-slate-50 {
|
||||
--tw-gradient-from: var(--muted) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .to-white,
|
||||
.roundtable-planning--dark .to-white {
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .to-white {
|
||||
--tw-gradient-to: var(--card) !important;
|
||||
}
|
||||
|
||||
/* 品牌浅红底 → accent */
|
||||
.dark .roundtable-planning [class*="brand-200"],
|
||||
.roundtable-planning--dark [class*="brand-200"] {
|
||||
background-color: color-mix(in oklch, var(--accent) 55%, transparent) !important;
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.from-\[var\(--brand-200\)\]) {
|
||||
--tw-gradient-from: color-mix(in oklch, var(--accent) 60%, transparent) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.via-\[var\(--brand-200\)\]) {
|
||||
--tw-gradient-via: color-mix(in oklch, var(--accent) 60%, transparent) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .border-red-100,
|
||||
.dark .roundtable-planning .border-red-100\/50,
|
||||
.dark .roundtable-planning .border-red-200,
|
||||
.dark .roundtable-planning .border-red-200\/50,
|
||||
.dark .roundtable-planning .border-red-200\/85,
|
||||
.roundtable-planning--dark .border-red-100,
|
||||
.roundtable-planning--dark .border-red-100\/50,
|
||||
.roundtable-planning--dark .border-red-200,
|
||||
.roundtable-planning--dark .border-red-200\/50,
|
||||
.roundtable-planning--dark .border-red-200\/85 {
|
||||
border-color: var(--border) !important;
|
||||
/* ---- 品牌浅红底(brand-200 等) → accent ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) [class*="brand-200"] {
|
||||
background-color: color-mix(in oklch, var(--accent) 70%, transparent) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .border-slate-100,
|
||||
.dark .roundtable-planning .border-slate-200,
|
||||
.dark .roundtable-planning .border-slate-200\/50,
|
||||
.dark .roundtable-planning .border-\[\#e2e8f0\],
|
||||
.roundtable-planning--dark .border-slate-100,
|
||||
.roundtable-planning--dark .border-slate-200,
|
||||
.roundtable-planning--dark .border-slate-200\/50,
|
||||
.roundtable-planning--dark .border-\[\#e2e8f0\] {
|
||||
border-color: var(--border) !important;
|
||||
}
|
||||
|
||||
/* 文字 */
|
||||
.dark .roundtable-planning .text-slate-900,
|
||||
.dark .roundtable-planning .text-slate-800,
|
||||
.dark .roundtable-planning .text-slate-700,
|
||||
.dark .roundtable-planning .text-\[\#334155\],
|
||||
.roundtable-planning--dark .text-slate-900,
|
||||
.roundtable-planning--dark .text-slate-800,
|
||||
.roundtable-planning--dark .text-slate-700,
|
||||
.roundtable-planning--dark .text-\[\#334155\] {
|
||||
/* ---- 中性文字:深 → 正文色 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.text-slate-900, .text-slate-800, .text-slate-700, .text-\[\#334155\],
|
||||
.hover\:text-slate-900:hover, .hover\:text-slate-800:hover,
|
||||
.hover\:text-slate-700:hover
|
||||
) {
|
||||
color: var(--foreground) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .text-slate-600,
|
||||
.dark .roundtable-planning .text-slate-500,
|
||||
.dark .roundtable-planning .text-slate-400,
|
||||
.roundtable-planning--dark .text-slate-600,
|
||||
.roundtable-planning--dark .text-slate-500,
|
||||
.roundtable-planning--dark .text-slate-400 {
|
||||
/* ---- 中性文字:中 / 浅 → 次级文字色 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.text-slate-650, .text-slate-600, .text-slate-500, .text-slate-400,
|
||||
.text-slate-300, .text-\[\#94a3b8\],
|
||||
.hover\:text-slate-650:hover, .hover\:text-slate-600:hover,
|
||||
.placeholder\:text-slate-400::placeholder
|
||||
) {
|
||||
color: var(--muted-foreground) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .hover\:text-slate-800:hover,
|
||||
.roundtable-planning--dark .hover\:text-slate-800:hover {
|
||||
color: var(--foreground) !important;
|
||||
/* ---- 中性边框:slate / red / 白 / #e2e8f0(含透明度档)→ border ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.border-white, .border-slate-50, .border-slate-100, .border-slate-150,
|
||||
.border-slate-200, .border-slate-200\/50, .border-slate-200\/80,
|
||||
.border-slate-300, .border-slate-400, .border-slate-700,
|
||||
.border-\[\#e2e8f0\],
|
||||
.border-red-50, .border-red-100, .border-red-100\/50, .border-red-200,
|
||||
.border-red-200\/50, .border-red-200\/85
|
||||
) {
|
||||
border-color: var(--border) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .hover\:bg-slate-50:hover,
|
||||
.roundtable-planning--dark .hover\:bg-slate-50:hover {
|
||||
background-color: var(--accent) !important;
|
||||
/* ---- divide-slate-100 子项分隔线 → border ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
.divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
|
||||
border-color: var(--border) !important;
|
||||
}
|
||||
|
||||
/* ---- focus ring:brand-200 → 主色淡环 ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.ring-\[var\(--brand-200\)\],
|
||||
.focus-within\:ring-\[var\(--brand-200\)\]\/50:focus-within,
|
||||
.focus\:ring-\[var\(--brand-200\)\]\/50:focus
|
||||
) {
|
||||
--tw-ring-color: color-mix(in oklch, var(--primary) 30%, transparent) !important;
|
||||
}
|
||||
|
||||
/* ---- 选中边框 border-primary → 主色描边(柔化) ---- */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .border-primary,
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .border-2.border-primary {
|
||||
border-color: color-mix(in oklch, var(--primary) 55%, var(--border)) !important;
|
||||
}
|
||||
|
||||
/* =============================================================================
|
||||
* 功能语义色(成功/警告/错误/信息/装饰)—— 深色下:浅底改深色同色调、深字提亮。
|
||||
* 保留色相作为语义提示,只调明度以适配深蓝底。实心中等色按钮(emerald-600 等
|
||||
* 配白字)本就在深底上可读,故不改。
|
||||
* ========================================================================== */
|
||||
|
||||
/* —— 成功 · emerald —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.bg-emerald-50, .bg-emerald-50\/40, .bg-emerald-50\/50, .bg-emerald-100, .bg-emerald-100\/40) {
|
||||
background-color: color-mix(in oklch, #10b981 18%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.border-emerald-200, .border-emerald-200\/40, .border-emerald-200\/50) {
|
||||
border-color: color-mix(in oklch, #10b981 42%, var(--border)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.text-emerald-800, .text-emerald-700, .text-emerald-600) {
|
||||
color: #6ee7b7 !important;
|
||||
}
|
||||
|
||||
/* —— 警告 · amber —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.bg-amber-50, .bg-amber-50\/60, .bg-amber-100, .bg-amber-100\/40, .bg-amber-200,
|
||||
.hover\:bg-amber-100:hover, .hover\:bg-amber-200:hover
|
||||
) {
|
||||
background-color: color-mix(in oklch, #f59e0b 20%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(
|
||||
.border-amber-100, .border-amber-200, .border-amber-200\/40, .border-amber-300,
|
||||
.border-amber-300\/50, .border-amber-500, .border-amber-700\/50
|
||||
) {
|
||||
border-color: color-mix(in oklch, #f59e0b 42%, var(--border)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.text-amber-900, .text-amber-800, .text-amber-700, .text-amber-600) {
|
||||
color: #fcd34d !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .focus\:ring-amber-200:focus {
|
||||
--tw-ring-color: color-mix(in oklch, #f59e0b 35%, transparent) !important;
|
||||
}
|
||||
|
||||
/* —— 错误 · red / rose —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.bg-red-50, .bg-red-200, .bg-rose-50, .hover\:bg-rose-50:hover) {
|
||||
background-color: color-mix(in oklch, #ef4444 18%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.text-red-700, .text-rose-600, .hover\:text-rose-600:hover) {
|
||||
color: #fca5a5 !important;
|
||||
}
|
||||
|
||||
/* —— 信息 · sky(部分组件已自带 dark: 变体,这里兜底无 dark: 的) —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .bg-sky-50 {
|
||||
background-color: color-mix(in oklch, #0ea5e9 18%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.border-sky-200, .border-sky-300\/50) {
|
||||
border-color: color-mix(in oklch, #0ea5e9 42%, var(--border)) !important;
|
||||
}
|
||||
|
||||
/* —— 装饰 · purple —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.bg-purple-50, .bg-purple-100\/40) {
|
||||
background-color: color-mix(in oklch, #a855f7 18%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .border-purple-200 {
|
||||
border-color: color-mix(in oklch, #a855f7 42%, var(--border)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark)
|
||||
:is(.text-purple-700, .text-purple-500) {
|
||||
color: #d8b4fe !important;
|
||||
}
|
||||
|
||||
/* —— 装饰 · orange / pink —— */
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .bg-orange-50 {
|
||||
background-color: color-mix(in oklch, #f97316 18%, var(--card)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .border-orange-200\/50 {
|
||||
border-color: color-mix(in oklch, #f97316 42%, var(--border)) !important;
|
||||
}
|
||||
:is(.dark .roundtable-planning, .roundtable-planning--dark) .bg-pink-100\/40 {
|
||||
background-color: color-mix(in oklch, #ec4899 18%, var(--card)) !important;
|
||||
}
|
||||
|
||||
/* =============================================================================
|
||||
* 结构件覆盖(顶栏 / 步骤条 / 次要按钮)—— 保留原有针对性规则。
|
||||
* ========================================================================== */
|
||||
|
||||
/* 顶栏 */
|
||||
.dark .roundtable-planning > header,
|
||||
.roundtable-planning--dark > header {
|
||||
@@ -161,29 +321,6 @@
|
||||
color: var(--foreground) !important;
|
||||
}
|
||||
|
||||
/* 输入区 focus ring */
|
||||
.dark .roundtable-planning .focus-within\:ring-\[var\(--brand-200\)\]\/50:focus-within,
|
||||
.roundtable-planning--dark .focus-within\:ring-\[var\(--brand-200\)\]\/50:focus-within {
|
||||
--tw-ring-color: color-mix(in oklch, var(--primary) 25%, transparent) !important;
|
||||
}
|
||||
|
||||
/* 渐变横幅 */
|
||||
.dark .roundtable-planning .from-\[var\(--brand-200\)\],
|
||||
.roundtable-planning--dark .from-\[var\(--brand-200\)\] {
|
||||
--tw-gradient-from: color-mix(in oklch, var(--accent) 40%, transparent) !important;
|
||||
}
|
||||
|
||||
.dark .roundtable-planning .border-primary,
|
||||
.roundtable-planning--dark .border-2.border-primary {
|
||||
border-color: color-mix(in oklch, var(--primary) 50%, var(--border)) !important;
|
||||
}
|
||||
|
||||
/* 分隔线 */
|
||||
.dark .roundtable-planning .bg-slate-200,
|
||||
.roundtable-planning--dark .bg-slate-200 {
|
||||
background-color: var(--border) !important;
|
||||
}
|
||||
|
||||
/* Custom elegant scrollbar styling */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
/**
|
||||
* Local-only draft storage for /page/roundtable/planning.
|
||||
*
|
||||
* One draft = one full roundtable session (Step 1 intent + Step 2 multi-agent
|
||||
* roundtable). Persisted in `localStorage` so refresh / browser-restart keeps
|
||||
* it; cross-device sync is out of scope (would need a backend). The Step 2
|
||||
* back-end LangGraph threads are reused on load, so list/preview/download of
|
||||
* artifacts in Step 3 continue to work as long as the user hasn't deleted the
|
||||
* threads server-side.
|
||||
*/
|
||||
|
||||
import type { IntentSummary } from "@/roundtable-planning/api/intent";
|
||||
import type { ThreadIdMap } from "@/roundtable-planning/api/multi-agent";
|
||||
|
||||
const STORAGE_KEY = "roundtable-planning:drafts:v1";
|
||||
|
||||
/**
|
||||
* Snapshot of every piece of UI state needed to resume a session. We capture
|
||||
* shapes loosely (`unknown[]`) for the chat / role lists because their inline
|
||||
* types in the page component are wide and would force a refactor we don't
|
||||
* want as part of the persistence feature.
|
||||
*/
|
||||
export interface DraftStep1Snapshot {
|
||||
intentThreadId: string | null;
|
||||
intentReady: IntentSummary | null;
|
||||
interactiveMessages: unknown[];
|
||||
timelineEntries: unknown[];
|
||||
}
|
||||
|
||||
export interface DraftStep2Snapshot {
|
||||
threadIds: ThreadIdMap | null;
|
||||
coordinatorName: string | null;
|
||||
step2RoundtableDialogues: unknown[];
|
||||
lastLeaderContent: string;
|
||||
hasConsensus: boolean;
|
||||
consensusPercentage: number;
|
||||
budgetLimit: number;
|
||||
/**
|
||||
* Per-seat stub AI messages used by the sandbox `write-file:` virtual URL
|
||||
* loader. Older drafts won't have this — callers should default to `{}`.
|
||||
*/
|
||||
seatStubMessages?: Record<string, unknown[]>;
|
||||
}
|
||||
|
||||
export interface DraftRecord {
|
||||
id: string;
|
||||
/** Auto-derived task summary (objective → first user message → timestamp). */
|
||||
name: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
/** Furthest step the user had reached when this snapshot was taken. */
|
||||
furthestStep: 1 | 2 | 3;
|
||||
step1: DraftStep1Snapshot;
|
||||
step2: DraftStep2Snapshot;
|
||||
}
|
||||
|
||||
function isBrowser(): boolean {
|
||||
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
||||
}
|
||||
|
||||
function readAll(): DraftRecord[] {
|
||||
if (!isBrowser()) return [];
|
||||
try {
|
||||
const raw = window.localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return [];
|
||||
const parsed = JSON.parse(raw);
|
||||
if (!Array.isArray(parsed)) return [];
|
||||
return parsed as DraftRecord[];
|
||||
} catch (err) {
|
||||
console.warn("[drafts] failed to parse localStorage payload:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function writeAll(records: DraftRecord[]): void {
|
||||
if (!isBrowser()) return;
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(records));
|
||||
} catch (err) {
|
||||
// Quota errors are the realistic failure mode — surface but don't throw,
|
||||
// since the user can keep working with their in-memory state.
|
||||
console.warn("[drafts] failed to write localStorage payload:", err);
|
||||
}
|
||||
}
|
||||
|
||||
function newId(): string {
|
||||
if (isBrowser() && typeof window.crypto !== "undefined" && typeof window.crypto.randomUUID === "function") {
|
||||
return window.crypto.randomUUID();
|
||||
}
|
||||
return `draft-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
}
|
||||
|
||||
/** List drafts newest first. */
|
||||
export function listDrafts(): DraftRecord[] {
|
||||
return readAll()
|
||||
.slice()
|
||||
.sort((a, b) => (a.updatedAt < b.updatedAt ? 1 : -1));
|
||||
}
|
||||
|
||||
export function getDraft(id: string): DraftRecord | null {
|
||||
return readAll().find((d) => d.id === id) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create-or-update a draft. If `id` is given and exists, that record is
|
||||
* overwritten (updatedAt refreshed). Otherwise a new record is inserted.
|
||||
* Returns the (re-)saved record so callers can read back the new id.
|
||||
*/
|
||||
export function upsertDraft(
|
||||
payload: Omit<DraftRecord, "createdAt" | "updatedAt" | "id"> & { id?: string },
|
||||
): DraftRecord {
|
||||
const records = readAll();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
if (payload.id) {
|
||||
const idx = records.findIndex((d) => d.id === payload.id);
|
||||
if (idx >= 0) {
|
||||
const existing = records[idx];
|
||||
const updated: DraftRecord = {
|
||||
...existing,
|
||||
name: payload.name,
|
||||
furthestStep: payload.furthestStep,
|
||||
step1: payload.step1,
|
||||
step2: payload.step2,
|
||||
updatedAt: now,
|
||||
};
|
||||
records[idx] = updated;
|
||||
writeAll(records);
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
|
||||
const created: DraftRecord = {
|
||||
id: payload.id ?? newId(),
|
||||
name: payload.name,
|
||||
furthestStep: payload.furthestStep,
|
||||
step1: payload.step1,
|
||||
step2: payload.step2,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
records.push(created);
|
||||
writeAll(records);
|
||||
return created;
|
||||
}
|
||||
|
||||
export function deleteDraft(id: string): void {
|
||||
const records = readAll();
|
||||
const next = records.filter((d) => d.id !== id);
|
||||
if (next.length !== records.length) writeAll(next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a draft. No-op when `id` isn't found or `name` is empty. Returns the
|
||||
* updated record so callers can refresh local UI state.
|
||||
*/
|
||||
export function renameDraft(id: string, name: string): DraftRecord | null {
|
||||
const trimmed = name.trim();
|
||||
if (!trimmed) return null;
|
||||
const records = readAll();
|
||||
const idx = records.findIndex((d) => d.id === id);
|
||||
if (idx < 0) return null;
|
||||
const updated: DraftRecord = {
|
||||
...records[idx],
|
||||
name: trimmed,
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
records[idx] = updated;
|
||||
writeAll(records);
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a short task-summary name from whatever the user has supplied so far.
|
||||
* Preference order: intent agent's structured objective → first user message
|
||||
* in Step 1 → ISO timestamp fallback. The result is trimmed to ~40 chars so
|
||||
* the dropdown rows stay scannable.
|
||||
*/
|
||||
export function deriveDraftName(args: {
|
||||
intentReady?: IntentSummary | null;
|
||||
interactiveMessages?: unknown[];
|
||||
}): string {
|
||||
const MAX = 40;
|
||||
const truncate = (s: string) => (s.length > MAX ? s.slice(0, MAX) + "…" : s);
|
||||
|
||||
const objective = args.intentReady?.objective?.trim();
|
||||
if (objective) return truncate(objective);
|
||||
|
||||
if (Array.isArray(args.interactiveMessages)) {
|
||||
for (const m of args.interactiveMessages) {
|
||||
if (!m || typeof m !== "object") continue;
|
||||
const obj = m as Record<string, unknown>;
|
||||
if (obj.sender === "user" && typeof obj.content === "string" && obj.content.trim()) {
|
||||
return truncate(obj.content.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return `未命名草稿 ${new Date().toLocaleString("zh-CN", { hour12: false })}`;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import service from "@/utils/request";
|
||||
export const requestCrudService = {
|
||||
get: async (endpoint, params = {}) => {
|
||||
try {
|
||||
const response = await service.get(endpoint, { params });
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`GET request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
post: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.post(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`POST request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
put: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.put(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`PUT request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
update: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.patch(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`patch request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
delete: async (endpoint) => {
|
||||
try {
|
||||
const response = await service.delete(endpoint);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`DELETE request failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import { environment } from '@/environments/environment';
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
|
||||
export interface GetOneParam {
|
||||
fields?: string[]; // 指定返回的字段 id,name
|
||||
join?: string[]; // 指定关联表,如 ['user||id,name', 'relation||id']
|
||||
cache?: 0 | 1; // 0直接DB,1缓存,默认1缓存
|
||||
}
|
||||
export interface GetAllParam {
|
||||
fields?: string[] | string; // 指定返回的字段: 多个字段如 'id', 'name'
|
||||
filter?: string[]; // 指定过滤条件,如 ['name||$eq||batman', 'id||$in||1,2,3', 'field||$isnull', 'relation.id||$eq||1']
|
||||
or?: string[]; // 同filter
|
||||
join?: string[]; // 指定关联表,如 ['user||id,name', 'relation||id']
|
||||
cache?: 0 | 1; // 0直接DB,1缓存,默认1缓存
|
||||
page?: number; // 页码(会被转换成offset)
|
||||
offset?: number; // 偏移量
|
||||
limit?: number; // 每页数量
|
||||
sort?: string[]; // 排序,如 '['name,ASC', 'id,DESC]'
|
||||
s?: string;
|
||||
joinTaskAction?: boolean; //是否连行动表查询
|
||||
joinTaskActionBoci?: boolean; //策略分析列表使用
|
||||
}
|
||||
|
||||
export interface GetAllResponse {
|
||||
data: any[];
|
||||
page: number;
|
||||
pageCount: number;
|
||||
count: number;
|
||||
total: number;
|
||||
errMsg?: string;
|
||||
}
|
||||
let deepCopy = (str: any) => {
|
||||
return JSON.parse(JSON.stringify(str));
|
||||
}
|
||||
export class RequestCrudService {
|
||||
|
||||
/**
|
||||
* 获取单个对象
|
||||
* @param url 地址
|
||||
* @param id ID
|
||||
* @param params 参数
|
||||
* @returns 单个对象
|
||||
*/
|
||||
async getOne(url: string, id: number, params?: GetOneParam): Promise<any> {
|
||||
const getUrl = `${url}/${id}`;
|
||||
const res = await requestCrudService.get(getUrl, params);
|
||||
if (res) return res;
|
||||
// this.notification.create('error', getUrl, `${res.data}`);
|
||||
return {};
|
||||
}
|
||||
/**
|
||||
* 获取多个对象
|
||||
* @param url 地址
|
||||
* @param params 参数
|
||||
* @returns 多个对象数组
|
||||
*/
|
||||
async getAll(url: string, params: GetAllParam | null = null): Promise<GetAllResponse> {
|
||||
const formattedParams = deepCopy(params || {});
|
||||
// 分页默认值
|
||||
if (!params || !params.limit) formattedParams.limit = 999;
|
||||
if (!params || !params.page) formattedParams.page = 1;
|
||||
// 计算offset
|
||||
if (params && formattedParams.page) {
|
||||
formattedParams.offset = (formattedParams.page - 1) * formattedParams.limit!;
|
||||
delete formattedParams.page;
|
||||
}
|
||||
const res = await requestCrudService.get(url, formattedParams);
|
||||
if (res.status === 200) return res.data;
|
||||
// this.notification.create('error', url, `${res.data}`);
|
||||
return {
|
||||
count: 0,
|
||||
data: [],
|
||||
page: 1,
|
||||
pageCount: 1,
|
||||
total: 0
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 创建单个对象
|
||||
* @param url 地址
|
||||
* @param data 单个对象
|
||||
* @returns 被创建的单个对象
|
||||
*/
|
||||
async createOne(url: string, data: any) {
|
||||
const res = await requestCrudService.post(url, data);
|
||||
if (res.status === 201) return res.data;
|
||||
// this.notification.create('error', url, `${res.data}`);
|
||||
return {};
|
||||
}
|
||||
/**
|
||||
* 创建多个对象
|
||||
* @param url 地址
|
||||
* @param data 多个对象
|
||||
* @returns 被创建的多个对象
|
||||
*/
|
||||
async createMulti(url: string, data: any[]) {
|
||||
const res = await requestCrudService.post(url, {
|
||||
bulk: data
|
||||
});
|
||||
if (res.status === 201) return res.data;
|
||||
// this.notification.create('error', url, `${res.data}`);
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* 更新单个对象
|
||||
* @param url 地址
|
||||
* @param id ID
|
||||
* @param data 单个对象部分键值对
|
||||
* @returns 被修改的单个对象
|
||||
*/
|
||||
async updateOne(url: string, id: number, data: any) {
|
||||
const res = await requestCrudService.update(`${url}/${id}`, data);
|
||||
if (res.status === 200) return res.data;
|
||||
// this.notification.create('error', url, `${res.data}`);
|
||||
return {};
|
||||
}
|
||||
/**
|
||||
* 删除单个对象
|
||||
* @param url 地址
|
||||
* @param id ID
|
||||
* @returns 操作结果
|
||||
*/
|
||||
async deleteOne(url: string, id: number) {
|
||||
const res = await requestCrudService.delete(`${url}/${id}`);
|
||||
if (res.status === 200) return res.data;
|
||||
// this.notification.create('error', url, `${res.data}`);
|
||||
return 'error';
|
||||
}
|
||||
// get 请求
|
||||
async simpleGet(url: string, params?: any): Promise<any> {
|
||||
const res = await requestCrudService.get(url, params);
|
||||
if (res.status === 200) return res.data;
|
||||
return res.data;
|
||||
}
|
||||
// post 请求
|
||||
async simplePost(url: string, data: any) {
|
||||
const res = await requestCrudService.post(url, data);
|
||||
if (res.status === 200) return res.data;
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import toolsService from "@/utils/tools-request";
|
||||
const service = toolsService;
|
||||
export const toolsCrudService = {
|
||||
get: async (endpoint, params = {}) => {
|
||||
try {
|
||||
const response = await service.get(endpoint, { params });
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`GET request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
post: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.post(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`POST request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
put: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.put(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`PUT request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
patch: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.patch(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`PATCH request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
update: async (endpoint, data = {}) => {
|
||||
try {
|
||||
const response = await service.patch(endpoint, data);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`patch request failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
delete: async (endpoint) => {
|
||||
try {
|
||||
const response = await service.delete(endpoint);
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new Error(`DELETE request failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
-190
@@ -88,6 +88,7 @@ export const createThinkingTrace = (mode: QAMode): QAThinkingTrace => {
|
||||
title: '理解问题并拆解检索方向', // 本轮主题:理解问题并确定检索方向
|
||||
thoughtMarkdown: '用户询问 **RAG 技术工作原理**。需要先明确核心链路:\n\n- 问题理解与向量化\n- 知识库召回\n- 上下文增强\n- 大模型生成\n\n第一轮优先检索基础定义和主流程。', // 模型思考过程,展示分析步骤
|
||||
query: 'RAG 检索增强生成 工作原理 基础流程', // 发送给检索系统的查询词
|
||||
queryShow: true,
|
||||
retrievals: [ // 第一轮检索返回的资料列表
|
||||
{
|
||||
id: 'r1-1',
|
||||
@@ -114,6 +115,7 @@ export const createThinkingTrace = (mode: QAMode): QAThinkingTrace => {
|
||||
thoughtMarkdown: '基础链路已经明确,继续检索 **多轮 RAG** 和 **深度检索** 的差异:\n\n1. 是否需要 Query 改写\n2. 是否需要对子问题分别召回\n3. 是否需要结果重排与证据融合',
|
||||
query: '多轮 RAG Query 改写 子问题检索 结果重排', // 本轮发送给检索系统的查询词
|
||||
// 本轮检索返回的资料列表
|
||||
queryShow: true,
|
||||
retrievals: [
|
||||
{
|
||||
id: 'r2-1',
|
||||
@@ -144,6 +146,7 @@ export const createThinkingTrace = (mode: QAMode): QAThinkingTrace => {
|
||||
title: '综合证据并形成回答结构', // 本轮的主题:整合前面检索到的所有证据,组织成完整的回答
|
||||
thoughtMarkdown: '当前证据已覆盖定义、流程和优化机制。最后需要组织成清晰结构:\n\n- 一句话定义\n- 分阶段流程\n- 技术价值\n- 适用场景与注意事项',
|
||||
query: 'RAG 技术价值 幻觉 时效性 可追溯性 应用场景', // 本轮查询:关于 RAG 价值和应用场景的信息
|
||||
queryShow: true,
|
||||
retrievals: [
|
||||
{
|
||||
id: 'r3-1',
|
||||
@@ -181,9 +184,11 @@ export const createMultiRoundStreamTrace = (): QAThinkingTrace => ({
|
||||
title: '正在准备检索',
|
||||
thoughtMarkdown: '',
|
||||
query: '',
|
||||
queryShow: true,
|
||||
queryLoading: true,
|
||||
retrievals: [],
|
||||
}],
|
||||
thinkingComplete: false,
|
||||
finalAnswerMarkdown: '',
|
||||
});
|
||||
|
||||
@@ -196,7 +201,7 @@ export const createMultiRoundStreamTrace = (): QAThinkingTrace => ({
|
||||
export const createComparePane = (mode: QAMode): ComparePane => ({
|
||||
mode,
|
||||
loading: true,
|
||||
singleRagTrace: mode === 'single-round'
|
||||
singleRagTrace: (mode === 'single-round' || mode === 'single-chat')
|
||||
? {
|
||||
title: '单轮 RAG 思考过程',
|
||||
thinkingMarkdown: '',
|
||||
@@ -204,7 +209,7 @@ export const createComparePane = (mode: QAMode): ComparePane => ({
|
||||
thinkingComplete: false,
|
||||
}
|
||||
: undefined,
|
||||
thinkingTrace: mode === 'single-round' ? undefined : createMultiRoundStreamTrace(),
|
||||
thinkingTrace: (mode === 'single-round' || mode === 'single-chat') ? undefined : createMultiRoundStreamTrace(),
|
||||
sources: [],
|
||||
});
|
||||
|
||||
@@ -215,88 +220,6 @@ export const createComparePane = (mode: QAMode): ComparePane => ({
|
||||
* 拆分时完整保留原始 mock 数据,确保首屏体验不变。
|
||||
*/
|
||||
export const createMockSingleRagMessages = (): Message[] => ([
|
||||
{
|
||||
id: 'mock-user-code-preview',
|
||||
role: 'user',
|
||||
content: '帮我看一下 Markdown 代码块的展示效果',
|
||||
timestamp: new Date(),
|
||||
},
|
||||
{
|
||||
id: 'mock-assistant-code-preview',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
timestamp: new Date(),
|
||||
singleRagTrace: {
|
||||
title: '代码块渲染预览',
|
||||
thinkingMarkdown: '这条模拟数据用于检查 MarkdownRenderer 的代码块样式:多行代码应该展示为带语言标签和复制按钮的彩色代码块,短单行代码例如 `const ok = true` 应该保持行内展示。',
|
||||
answerMarkdown: [
|
||||
'下面是几段模拟代码,用来预览不同语言的渲染效果。',
|
||||
'',
|
||||
'短单行代码:`const count = 1`,这一段应该显示为行内代码,而不是大代码块。',
|
||||
'',
|
||||
'### TSX 示例',
|
||||
'',
|
||||
'```tsx',
|
||||
'type UserCardProps = {',
|
||||
' name: string;',
|
||||
' role: string;',
|
||||
'};',
|
||||
'',
|
||||
'export function UserCard({ name, role }: UserCardProps) {',
|
||||
' return (',
|
||||
' <section className="rounded-lg border p-4">',
|
||||
' <h3>{name}</h3>',
|
||||
' <p>{role}</p>',
|
||||
' </section>',
|
||||
' );',
|
||||
'}',
|
||||
'```',
|
||||
'',
|
||||
'### Vue 示例',
|
||||
'',
|
||||
'```vue',
|
||||
'<script setup lang="ts">',
|
||||
'import { ref } from "vue";',
|
||||
'',
|
||||
'const keyword = ref("strategy");',
|
||||
'</script>',
|
||||
'',
|
||||
'<template>',
|
||||
' <button @click="keyword = keyword.toUpperCase()">',
|
||||
' {{ keyword }}',
|
||||
' </button>',
|
||||
'</template>',
|
||||
'```',
|
||||
'',
|
||||
'### Java 示例',
|
||||
'',
|
||||
'```java',
|
||||
'public class StrategyScore {',
|
||||
' public static int normalize(int value) {',
|
||||
' return Math.max(0, Math.min(100, value));',
|
||||
' }',
|
||||
'',
|
||||
' public static void main(String[] args) {',
|
||||
' System.out.println(normalize(128));',
|
||||
' }',
|
||||
'}',
|
||||
'```',
|
||||
'',
|
||||
'引用按钮也顺便保留测试:[[1]]',
|
||||
].join('\n'),
|
||||
thinkingComplete: true,
|
||||
},
|
||||
sources: [
|
||||
{
|
||||
title: 'MarkdownRenderer mock preview',
|
||||
type: '本地模拟数据',
|
||||
snippet: '用于预览 tsx、vue、java 代码块高亮,以及短单行代码的行内展示。',
|
||||
source: 'GeneralQA.mock.ts',
|
||||
time: '2026-04-30',
|
||||
content: '这是一条本地模拟引用数据,用于测试 [[1]] 引用按钮点击后的详情展示。',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'mock-user-1',
|
||||
role: 'user',
|
||||
@@ -382,111 +305,6 @@ export const createMockSingleRagMessages = (): Message[] => ([
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'mock-user-multi-1',
|
||||
role: 'user',
|
||||
content: '我想了解多轮检索的工作机制,以及它在大规模企业知识库中的实际表现如何?',
|
||||
timestamp: new Date(),
|
||||
},
|
||||
{
|
||||
id: 'mock-assistant-multi-1',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
timestamp: new Date(),
|
||||
thinkingTrace: createThinkingTrace('multi-round'),
|
||||
sources: [
|
||||
{
|
||||
title: '多轮RAG检索白皮书',
|
||||
type: '知识库',
|
||||
snippet: '多轮检索通过逐轮改写查询、逐步聚焦,能在复杂问题上比单轮检索提升30%以上的召回覆盖。',
|
||||
source: '内部架构组',
|
||||
time: '2026-04-15',
|
||||
content: '多轮检索的核心在于每轮检索后根据已召回内容改写查询,逐步缩小语义范围,最终实现精准覆盖。',
|
||||
},
|
||||
{
|
||||
title: '企业知识库检索时延对比',
|
||||
type: '技术报告',
|
||||
snippet: '两轮检索在10万级文档库中平均增加40%延迟,但答案完整度提升显著。',
|
||||
source: 'NLP团队',
|
||||
time: '2026-03-22',
|
||||
content: '实测数据:单轮检索平均时延1.2s,两轮检索平均时延1.7s,三轮检索平均时延2.3s。建议根据SLA选择合适轮次。',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'mock-user-multi-2',
|
||||
role: 'user',
|
||||
content: '企业知识问答系统的多轮检索需要做哪些工程化优化?',
|
||||
timestamp: new Date(),
|
||||
},
|
||||
{
|
||||
id: 'mock-assistant-multi-2',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
timestamp: new Date(),
|
||||
thinkingTrace: {
|
||||
title: '多轮检索工程化优化思考过程',
|
||||
rounds: [
|
||||
{
|
||||
id: 'round-opt-1',
|
||||
title: '分析工程化优化方向',
|
||||
thoughtMarkdown: '用户关心的是工程层面的优化,需要从以下几个维度回答:\n\n1. 查询改写策略的缓存与复用\n2. 检索结果去重与增量更新\n3. 并发检索与超时控制\n4. 检索质量的在线评估机制',
|
||||
query: '多轮检索 工程化优化 查询改写 缓存 去重 并发',
|
||||
retrievals: [
|
||||
{
|
||||
id: 'ro1-1',
|
||||
title: '查询改写缓存策略实践',
|
||||
content: '对于相似查询,可通过向量相似度匹配复用上一轮的改写结果,减少调用大模型的次数和延迟。',
|
||||
source: '知识库 / 查询优化实践指南.md',
|
||||
},
|
||||
{
|
||||
id: 'ro1-2',
|
||||
title: '检索结果去重方案',
|
||||
content: '多轮检索容易出现重复文档,需基于文档ID或内容哈希进行去重,并在每轮检索时排除已召回文档。',
|
||||
source: '知识库 / 检索去重技术方案.pdf',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'round-opt-2',
|
||||
title: '检索性能与质量保障',
|
||||
thoughtMarkdown: '第二轮聚焦性能优化:\n\n1. 并发检索多个知识库以降低延迟\n2. 设置合理的检索超时防止长尾请求\n3. 引入在线相关性评分作为质量护栏',
|
||||
query: '并发检索 超时控制 在线评估 知识库评分',
|
||||
retrievals: [
|
||||
{
|
||||
id: 'ro2-1',
|
||||
title: '知识库并发检索架构设计',
|
||||
content: '采用异步并发查询多个索引,配合全局超时(建议3-5s),保证用户体验的同时最大化召回。',
|
||||
source: '架构库 / 并发检索设计文档.docx',
|
||||
},
|
||||
{
|
||||
id: 'ro2-2',
|
||||
title: '检索质量在线评估方法',
|
||||
content: '通过小模型对每轮召回结果做相关性打分,低于阈值时自动触发查询改写或切换检索策略。',
|
||||
source: '评测库 / 在线质量评估方案.md',
|
||||
},
|
||||
{
|
||||
id: 'ro2-3',
|
||||
title: '多轮检索时延优化总结',
|
||||
content: '工程实践中建议两轮为上限,超过时需评估能否合并为单轮。首批结果可先展示,第二轮做增量补充。',
|
||||
source: '性能库 / 时延优化白皮书.pdf',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
finalAnswerMarkdown: '多轮检索的工程化优化主要围绕四个方向:\n\n### 1. 查询改写优化\n- 缓存相似查询的改写结果,通过向量相似度匹配复用\n- 降低大模型调用频次,减少时延和成本\n\n### 2. 结果去重与增量更新\n- 基于文档ID或内容哈希去重\n- 每轮检索时排除已召回文档,避免重复返回\n- 增量模式:先返回首批结果,后续轮次做补充\n\n### 3. 并发与超时控制\n- 异步并发查询多个知识库索引\n- 设置全局超时(建议3-5秒),避免长尾请求\n- 首批结果到达后立即展示,后续增量追加\n\n### 4. 在线质量评估\n- 用小模型对召回结果做相关性打分\n- 低于阈值时自动触发查询改写或切换策略\n- 持续监控命中率和引用准确率\n\n> 建议:实际工程中两轮检索已能覆盖大多数复杂场景,超过两轮应重新评估是否可以通过更好的查询改写来合并。',
|
||||
},
|
||||
sources: [
|
||||
{
|
||||
title: '多轮检索工程化最佳实践',
|
||||
type: '技术方案',
|
||||
snippet: '两轮检索配合增量更新,可在延迟和完整度之间取得最优平衡。',
|
||||
source: '工程团队',
|
||||
time: '2026-05-01',
|
||||
content: '总结了过去一年的多轮检索优化经验,涵盖查询改写缓存、结果去重、并发检索和在线评估四大方向。',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -506,9 +324,10 @@ export const mapDocsToSources = (docs: KnowledgeBaseChunk['docs']): SourceItem[]
|
||||
const normalizedDocs = Array.isArray(docs) ? docs : docs ? [docs] : [];
|
||||
|
||||
return normalizedDocs.map((item, idx) => {
|
||||
console.log(item,'检索资料')
|
||||
if (typeof item === 'string') {
|
||||
return {
|
||||
title: `参考资料 ${idx + 1}`,
|
||||
title: '',
|
||||
type: '知识库',
|
||||
snippet: item,
|
||||
source: '',
|
||||
@@ -529,6 +348,34 @@ export const mapDocsToSources = (docs: KnowledgeBaseChunk['docs']): SourceItem[]
|
||||
});
|
||||
};
|
||||
|
||||
export const chatDataJSON = (chatJSON: string) => {
|
||||
let chatJSONText = chatJSON.replace(/}{"/g, '},{"');
|
||||
chatJSONText = '[' + chatJSONText + ']';
|
||||
// console.log('解析chat',chatJSONText);
|
||||
let chatData = [];
|
||||
let chatTitle: any = '';
|
||||
const docsList: any[] = [];
|
||||
try {
|
||||
chatData = JSON.parse(chatJSONText);
|
||||
chatData.forEach((item: any) => {
|
||||
if (item['answer']) {
|
||||
chatTitle += item['answer'];
|
||||
} else if (item['docs']) {
|
||||
docsList.push(item);
|
||||
}
|
||||
});
|
||||
return {
|
||||
chatTitle,
|
||||
docsList,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
chatTitle,
|
||||
docsList,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 从流式文本中提取完整 JSON 对象。
|
||||
*
|
||||
@@ -582,3 +429,22 @@ export const extractJsonObjects = (raw: string): { objects: string[]; rest: stri
|
||||
|
||||
return { objects, rest: '' };
|
||||
};
|
||||
|
||||
// 处理平台数据
|
||||
export const platformTypeChange = (platform: string) => {
|
||||
let platformType: string = '';
|
||||
if (platform.includes('fb')) {
|
||||
platformType = 'facebook';
|
||||
} else if (platform.includes('x')) {
|
||||
platformType = 'x';
|
||||
} else if (platform.includes('in')) {
|
||||
platformType = 'instagram';
|
||||
} else if (platform.includes('re')) {
|
||||
platformType = 'reddit';
|
||||
} else if (platform.includes('th')) {
|
||||
platformType = 'threads';
|
||||
} else {
|
||||
platformType = 'facebook';
|
||||
}
|
||||
return platformType;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+27
-1
@@ -1,6 +1,7 @@
|
||||
import type { QASingleRagTrace, QAThinkingTrace } from './QACommon';
|
||||
import { LucideIcon } from 'lucide-react';
|
||||
|
||||
export type QAMode = 'single-round' | 'multi-round' | 'deep-search';
|
||||
export type QAMode = 'single-chat' | 'single-round' | 'multi-round' | 'deep-search' | 'hx-search' | 'news-report';
|
||||
export type ViewMode = 'single' | 'compare';
|
||||
export type KnowledgeScope = 'all' | 'specific-kb' | 'specific-domain';
|
||||
export type AnswerStyle = 'concise' | 'detailed';
|
||||
@@ -13,6 +14,8 @@ export interface SourceItem {
|
||||
source?: string;
|
||||
time?: string;
|
||||
url?: string;
|
||||
keywords?: string;
|
||||
taskDirection?: string;
|
||||
content?: string;
|
||||
}
|
||||
|
||||
@@ -30,7 +33,14 @@ export interface ToolCallData {
|
||||
tool_name: string;
|
||||
tool_input: {
|
||||
text?: string;
|
||||
query?: string;
|
||||
q?: string;
|
||||
keyword?: string;
|
||||
platform?: string;
|
||||
user_fig?: string;
|
||||
result?: string;
|
||||
s?: string;
|
||||
e?: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -56,6 +66,8 @@ export interface ComparePane {
|
||||
}
|
||||
|
||||
export interface CompareResult {
|
||||
id: string | number;
|
||||
compareUserInput: string;
|
||||
left: ComparePane;
|
||||
right: ComparePane;
|
||||
differences?: {
|
||||
@@ -72,3 +84,17 @@ export interface SearchProcessState {
|
||||
hits: number;
|
||||
queryRewrite: string;
|
||||
}
|
||||
|
||||
export interface stateItem {
|
||||
compareIndex: number;
|
||||
compareId: string;
|
||||
messageList: Message[],
|
||||
compareResult: CompareResult[];
|
||||
}
|
||||
|
||||
export interface qaModeItem {
|
||||
value: QAMode;
|
||||
label: string;
|
||||
icon: LucideIcon;
|
||||
desc: string;
|
||||
}
|
||||
+33
-20
@@ -1,5 +1,6 @@
|
||||
import { BookOpen, Brain, ChevronLeft, ChevronRight, Sparkles } from 'lucide-react';
|
||||
import type { AnswerStyle, CompareLayout, KnowledgeScope, QAMode, ViewMode } from './GeneralQA.types';
|
||||
import React from 'react';
|
||||
import { BookOpen, Bot, Brain, ChevronLeft, ChevronRight, Sparkles, User2Icon } from 'lucide-react';
|
||||
import type { AnswerStyle, CompareLayout, KnowledgeScope, QAMode, qaModeItem, ViewMode } from './GeneralQA.types';
|
||||
|
||||
/**
|
||||
* 左侧配置栏 Props。
|
||||
@@ -21,6 +22,7 @@ type Props = {
|
||||
autoSummarizeDiff: boolean; // 对比模式下是否自动总结左右差异
|
||||
recommendBetter: boolean; // 对比模式下是否推荐更好的回答方案
|
||||
isCollapsed: boolean; // 左侧配置面板是否折叠
|
||||
qaModeOptions?: qaModeItem[];
|
||||
setQaMode: (mode: QAMode) => void; // 设置单一模式的问答模式
|
||||
setCompareLeftMode: (mode: QAMode) => void; // 设置对比模式左侧的模式
|
||||
setCompareRightMode: (mode: QAMode) => void; // 设置对比模式右侧的模式
|
||||
@@ -39,10 +41,13 @@ type Props = {
|
||||
*
|
||||
* 每个选项同时提供展示文案、图标和简短说明,便于配置栏用统一结构渲染卡片。
|
||||
*/
|
||||
const qaModeOptions = [
|
||||
const qaModeList: qaModeItem[] = [
|
||||
{ value: 'single-chat' as const, label: '快速', icon: Bot, desc: '快速直接' },
|
||||
{ value: 'single-round' as const, label: '单轮RAG', icon: Sparkles, desc: '快速直接' },
|
||||
{ value: 'multi-round' as const, label: '多轮RAG', icon: Brain, desc: '深入理解' },
|
||||
{ value: 'deep-search' as const, label: '深度检索', icon: BookOpen, desc: '全面分析' },
|
||||
{ value: 'deep-search' as const, label: '任务检索', icon: BookOpen, desc: '检索相关任务' },
|
||||
{ value: 'hx-search' as const, label: '画像检索', icon: User2Icon, desc: '检索相关账号' },
|
||||
{ value: 'news-report' as const, label: '新闻报告生成', icon: User2Icon, desc: '检索相关新闻' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -77,6 +82,7 @@ export default function GeneralQAConfigSidebar({
|
||||
autoSummarizeDiff,
|
||||
recommendBetter,
|
||||
isCollapsed,
|
||||
qaModeOptions = qaModeList,
|
||||
setQaMode,
|
||||
setCompareLeftMode,
|
||||
setCompareRightMode,
|
||||
@@ -88,7 +94,7 @@ export default function GeneralQAConfigSidebar({
|
||||
setAutoSummarizeDiff,
|
||||
setRecommendBetter,
|
||||
setIsCollapsed,
|
||||
}: Props): JSX.Element {
|
||||
}: Props): React.JSX.Element {
|
||||
/**
|
||||
* 自定义勾选图标。
|
||||
*
|
||||
@@ -130,7 +136,9 @@ export default function GeneralQAConfigSidebar({
|
||||
<div className="mb-6">
|
||||
<h3 className={`text-sm font-medium mb-3 ${isDark ? 'text-slate-300' : 'text-gray-700'}`}>问答模式</h3>
|
||||
<div className="space-y-2">
|
||||
{qaModeOptions.map((mode) => (
|
||||
{qaModeOptions.map((mode) => {
|
||||
const Icon = mode.icon;
|
||||
return (
|
||||
<button
|
||||
key={mode.value}
|
||||
onClick={() => setQaMode(mode.value)}
|
||||
@@ -144,13 +152,14 @@ export default function GeneralQAConfigSidebar({
|
||||
: 'bg-white border border-gray-200 text-gray-600 hover:bg-gray-50'
|
||||
}`}
|
||||
>
|
||||
<mode.icon className="w-5 h-5" />
|
||||
<Icon className="w-5 h-5" />
|
||||
<div className="flex-1">
|
||||
<div className="text-sm font-medium">{mode.label}</div>
|
||||
<div className={`text-xs ${isDark ? 'text-slate-500' : 'text-gray-400'}`}>{mode.desc}</div>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
@@ -160,18 +169,22 @@ export default function GeneralQAConfigSidebar({
|
||||
<div className="mb-4">
|
||||
<label className={`text-xs mb-2 block ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>模式A</label>
|
||||
<select value={compareLeftMode} onChange={(e) => setCompareLeftMode(e.target.value as QAMode)} className={`w-full px-3 py-2 rounded-lg text-sm ${isDark ? 'bg-slate-700/50 border border-slate-600 text-white' : 'bg-white border border-gray-200 text-gray-700'}`}>
|
||||
<option value="single-round">单轮RAG</option>
|
||||
<option value="multi-round">多轮RAG</option>
|
||||
<option value="deep-search">深度检索</option>
|
||||
{
|
||||
qaModeOptions.filter(item => item.value !== compareRightMode).map(item => (
|
||||
<option value={item.value} key={item.value}>{item.label}</option>
|
||||
))
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div className={`text-center my-2 ${isDark ? 'text-slate-500' : 'text-gray-400'}`}><span className="text-lg">VS</span></div>
|
||||
<div className="mb-4">
|
||||
<label className={`text-xs mb-2 block ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>模式B</label>
|
||||
<select value={compareRightMode} onChange={(e) => setCompareRightMode(e.target.value as QAMode)} className={`w-full px-3 py-2 rounded-lg text-sm ${isDark ? 'bg-slate-700/50 border border-slate-600 text-white' : 'bg-white border border-gray-200 text-gray-700'}`}>
|
||||
<option value="single-round">单轮RAG</option>
|
||||
<option value="multi-round">多轮RAG</option>
|
||||
<option value="deep-search">深度检索</option>
|
||||
{
|
||||
qaModeOptions.filter(item => item.value !== compareLeftMode).map(item => (
|
||||
<option value={item.value} key={item.value}>{item.label}</option>
|
||||
))
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -189,7 +202,7 @@ export default function GeneralQAConfigSidebar({
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="mb-6">
|
||||
{/* <div className="mb-6">
|
||||
<h3 className={`text-sm font-medium mb-3 ${isDark ? 'text-slate-300' : 'text-gray-700'}`}>知识范围</h3>
|
||||
<div className="space-y-2">
|
||||
{knowledgeScopeOptions.map((option) => (
|
||||
@@ -202,9 +215,9 @@ export default function GeneralQAConfigSidebar({
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
<div className="mb-6">
|
||||
{/* <div className="mb-6">
|
||||
<h3 className={`text-sm font-medium mb-3 ${isDark ? 'text-slate-300' : 'text-gray-700'}`}>回答偏好</h3>
|
||||
<div className="space-y-3">
|
||||
<label className={`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-all ${isDark ? 'text-slate-400 hover:bg-slate-700/30' : 'text-gray-600 hover:bg-gray-50'}`}>
|
||||
@@ -223,9 +236,9 @@ export default function GeneralQAConfigSidebar({
|
||||
<span className="text-sm">展示检索过程</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
{viewMode === 'compare' && (
|
||||
{/* {viewMode === 'compare' && (
|
||||
<div className="mb-6">
|
||||
<h3 className={`text-sm font-medium mb-3 ${isDark ? 'text-slate-300' : 'text-gray-700'}`}>对比设置</h3>
|
||||
<div className="space-y-3">
|
||||
@@ -241,7 +254,7 @@ export default function GeneralQAConfigSidebar({
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
)} */}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -0,0 +1,87 @@
|
||||
import React from 'react';
|
||||
import { History } from 'lucide-react';
|
||||
import type { ViewMode } from './GeneralQA.types';
|
||||
|
||||
/**
|
||||
* 顶部栏 Props。
|
||||
*
|
||||
* `setViewMode` 由父组件传入,父组件会在生成中切换时做确认拦截;
|
||||
* Header 本身不直接感知 loading,保持纯展示和事件转发。
|
||||
*/
|
||||
type Props = {
|
||||
isDark: boolean; // 当前是否为暗黑主题,用于样式适配
|
||||
viewMode: ViewMode; // 当前视图模式:'single' 单一模式 或 'compare' 对比模式
|
||||
chatHeadTitle?: string;
|
||||
chatDesign?: string;
|
||||
compareShow?: boolean;
|
||||
setViewMode: (mode: ViewMode) => void; // 设置视图模式回调函数
|
||||
onNavigate?: (page: string) => void; // 页面导航回调函数
|
||||
};
|
||||
|
||||
/**
|
||||
* 通用问答页面顶部栏。
|
||||
*
|
||||
* 该组件只负责页面标题、模式切换和历史记录入口,所有业务状态仍由父组件维护。
|
||||
* 这样拆分后,顶部导航的样式和交互不会和中间问答流处理逻辑混在一起,后续如果要新增
|
||||
* "保存模板""导出记录"等入口,也可以只改这个文件。
|
||||
*/
|
||||
export default function GeneralQAHeader({ isDark, viewMode, chatHeadTitle = '通用问答', chatDesign = '支持单轮RAG、多轮RAG、深度检索及结果对比', compareShow = true, setViewMode, onNavigate }: Props): React.JSX.Element {
|
||||
return (
|
||||
<div className={`flex items-center justify-between px-6 py-4 border-b ${isDark ? 'border-slate-700/50' : 'border-red-100'}`}>
|
||||
<div className="flex items-center gap-4">
|
||||
<h1 className={`text-lg font-semibold ${isDark ? 'text-white' : 'text-gray-900'}`}>
|
||||
{chatHeadTitle}
|
||||
</h1>
|
||||
<span className={`text-sm ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
{chatDesign}
|
||||
</span>
|
||||
</div>
|
||||
{
|
||||
compareShow && <div className="flex items-center gap-2">
|
||||
<div className={`flex rounded-lg p-1 ${isDark ? 'bg-slate-700/50' : 'bg-red-50'}`}>
|
||||
<button
|
||||
onClick={() => setViewMode('single')}
|
||||
className={`px-4 py-2 rounded-md text-sm font-medium transition-all ${viewMode === 'single'
|
||||
? isDark
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-red-500 text-white'
|
||||
: isDark
|
||||
? 'text-slate-400 hover:text-white'
|
||||
: 'text-gray-600 hover:text-red-600'
|
||||
}`}
|
||||
>
|
||||
单一模式
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setViewMode('compare')}
|
||||
className={`px-4 py-2 rounded-md text-sm font-medium transition-all ${viewMode === 'compare'
|
||||
? isDark
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-red-500 text-white'
|
||||
: isDark
|
||||
? 'text-slate-400 hover:text-white'
|
||||
: 'text-gray-600 hover:text-red-600'
|
||||
}`}
|
||||
>
|
||||
对比模式
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{onNavigate && (
|
||||
<button
|
||||
onClick={() => onNavigate('qa-records')}
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all ${
|
||||
isDark
|
||||
? 'bg-slate-700/50 text-slate-300 hover:bg-slate-600/50'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
}`}
|
||||
>
|
||||
<History className="w-4 h-4" />
|
||||
历史记录
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,933 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Dialog, Textarea } from 'tdesign-react';
|
||||
import {
|
||||
Bookmark,
|
||||
BrainCircuit,
|
||||
Bot,
|
||||
ChevronDown,
|
||||
FileSearch,
|
||||
Loader2,
|
||||
RotateCcw,
|
||||
Search,
|
||||
Send,
|
||||
Settings,
|
||||
Sparkles,
|
||||
Square,
|
||||
Copy,
|
||||
Trash2,
|
||||
Edit3,
|
||||
Upload,
|
||||
UserRound,
|
||||
ExternalLink,
|
||||
} from 'lucide-react';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import MarkdownRenderer from '@/strategy-components/MarkdownRenderer';
|
||||
import { SourceItem } from './GeneralQA.types';
|
||||
import '../qa/qa-animations.css';
|
||||
|
||||
/**
|
||||
* 单条检索结果。
|
||||
*
|
||||
* 多轮检索过程中每一轮可能返回多条资料,这里只保留 UI 展示所需的标题、摘要和来源。
|
||||
*/
|
||||
export interface QARetrievalItem {
|
||||
id?: string;
|
||||
title: string;
|
||||
content: string;
|
||||
keywords?: string;
|
||||
taskDirection?: string;
|
||||
type?: string;
|
||||
time?: string;
|
||||
source?: string;
|
||||
recUuid?: string;
|
||||
platform?: string;
|
||||
fans?: number;
|
||||
comment_count?: number;
|
||||
message_id?: string;
|
||||
hot_num?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多轮检索中的单轮思考节点。
|
||||
*
|
||||
* `queryLoading` 控制该轮检索结果是否仍显示 loading;retrievals 到达后再渲染资料列表。
|
||||
*/
|
||||
export interface QAThinkingRound {
|
||||
id: string; // 唯一标识符,用于列表渲染时的 key
|
||||
title: string; // 该轮检索的标题,如"第1轮检索"或"背景资料收集"
|
||||
thoughtMarkdown: string; // 模型思考过程的 Markdown 内容,展示思考步骤和推理逻辑
|
||||
queryTitle?: string; // 检索内容
|
||||
query: string; // 该轮发送给检索系统的查询语句
|
||||
queryLoading?: boolean; // 该轮检索是否仍在进行中,true 时显示加载动画
|
||||
textidContent?: string; // 新闻详细内容
|
||||
retrievals: QARetrievalItem[]; // 该轮返回的检索结果列表
|
||||
queryShow: boolean; // 检索列表为空时是否显示
|
||||
}
|
||||
|
||||
/**
|
||||
* 多轮/深度检索的完整思考链。
|
||||
*
|
||||
* rounds 展示检索过程,finalAnswerMarkdown 展示最终回答;两者分开便于流式过程中逐步更新。
|
||||
*/
|
||||
export interface QAThinkingTrace {
|
||||
title?: string; // 整体思考链的标题
|
||||
rounds: QAThinkingRound[]; // 多轮检索过程中的所有轮次,每轮包含思考和检索结果
|
||||
finalAnswerMarkdown: string; // 基于多轮检索结果生成的最终回答内容
|
||||
thinkingComplete?: boolean; // 思考过程是否已完成,true 时思考区域可折叠
|
||||
}
|
||||
|
||||
/**
|
||||
* 单轮 RAG 的回答结构。
|
||||
*
|
||||
* 后端可能把 `<think>...</think>` 和答案混在同一个 answer 流中,解析后分别放到 thinkingMarkdown 与 answerMarkdown。
|
||||
*/
|
||||
export interface QASingleRagTrace {
|
||||
title?: string; // 思考过程的标题,如"单轮 RAG 思考过程"
|
||||
thinkingMarkdown: string; // 模型在生成回答前的思考过程内容,使用 Markdown 格式
|
||||
answerMarkdown: string; // 最终生成的回答内容,使用 Markdown 格式
|
||||
thinkingComplete?: boolean; // 思考过程是否已完成,true 时思考区域可折叠
|
||||
}
|
||||
|
||||
export interface QACommonMessage {
|
||||
id: string; // 消息唯一标识符
|
||||
role: 'user' | 'assistant'; // 消息发送者角色:user 为用户消息,assistant 为 AI 回复
|
||||
content: string; // 消息的纯文本内容(当使用 thinkingTrace 或 singleRagTrace 时为空)
|
||||
timestamp?: Date; // 消息发送时间
|
||||
thinkingTrace?: QAThinkingTrace; // 多轮/深度检索模式的思考链,包含多轮检索过程和最终回答
|
||||
sources?: { // 消息引用的参考资料列表
|
||||
title: string; // 参考资料标题
|
||||
type: string; // 资料类型,如"文档"、"网页"等
|
||||
snippet: string; // 资料摘要内容
|
||||
source?: string; // 来源名称或 URL
|
||||
time?: string; // 发布时间
|
||||
url?: string; // 资料链接
|
||||
content?: string; // 完整内容(可能用于详情弹窗)
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface QACommonMessage {
|
||||
singleRagTrace?: QASingleRagTrace; // 单轮 RAG 模式的思考过程和回答结构
|
||||
}
|
||||
|
||||
interface QAAvatarProps {
|
||||
role: 'user' | 'assistant';
|
||||
isActive?: boolean;
|
||||
label?: string;
|
||||
variant?: 'default' | 'blue' | 'purple';
|
||||
}
|
||||
|
||||
const getAssistantAvatarClass = (variant: QAAvatarProps['variant'], isDark: boolean) => {
|
||||
switch (variant) {
|
||||
case 'blue':
|
||||
return isDark
|
||||
? 'bg-gradient-to-br from-blue-400 via-blue-600 to-cyan-700 text-white'
|
||||
: 'bg-gradient-to-br from-blue-300 via-blue-500 to-cyan-500 text-white';
|
||||
case 'purple':
|
||||
return isDark
|
||||
? 'bg-gradient-to-br from-purple-400 via-violet-600 to-fuchsia-700 text-white'
|
||||
: 'bg-gradient-to-br from-purple-300 via-violet-500 to-fuchsia-500 text-white';
|
||||
default:
|
||||
return isDark
|
||||
? 'bg-gradient-to-br from-cyan-500 via-blue-600 to-violet-600 text-white'
|
||||
: 'bg-gradient-to-br from-red-400 via-rose-500 to-orange-400 text-white';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 统一头像组件。
|
||||
*
|
||||
* 单一模式使用默认助手色;对比模式可通过 variant 指定蓝/紫色系,让头像与左右面板标签保持一致。
|
||||
* `isActive` 会触发呼吸和星光动画,用来提示当前助手正在生成。
|
||||
*/
|
||||
export const QAAvatar: React.FC<QAAvatarProps> = ({ role, isActive = false, label, variant = 'default' }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const Icon = role === 'assistant' ? Bot : UserRound;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`relative w-9 h-9 rounded-2xl flex items-center justify-center flex-shrink-0 overflow-hidden shadow-sm ${role === 'assistant'
|
||||
? getAssistantAvatarClass(variant, isDark)
|
||||
: isDark
|
||||
? 'bg-gradient-to-br from-slate-500 via-slate-700 to-slate-900 text-white'
|
||||
: 'bg-gradient-to-br from-sky-400 via-indigo-500 to-violet-500 text-white'
|
||||
} ${isActive ? 'qa-avatar-active' : ''}`}
|
||||
title={label}
|
||||
>
|
||||
<div className="absolute inset-0 bg-white/20 opacity-0 qa-avatar-shine" />
|
||||
<Icon className={`w-5 h-5 relative z-10 ${isActive ? 'qa-avatar-icon-active' : ''}`} />
|
||||
{role === 'assistant' && isActive && (
|
||||
<Sparkles className="absolute -right-0.5 -top-0.5 w-3.5 h-3.5 text-yellow-200 qa-avatar-spark" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface TypingIndicatorProps {
|
||||
label?: string;
|
||||
assistantLabel?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 助手预连接/生成中的占位提示。
|
||||
*
|
||||
* 用于请求已经发出但还没有生成可展示消息时,给用户明确的等待反馈。
|
||||
*/
|
||||
export const TypingIndicator: React.FC<TypingIndicatorProps> = ({ label = '正在思考并生成回复', assistantLabel = 'AI 助手' }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
|
||||
return (
|
||||
<div className="flex gap-3">
|
||||
<QAAvatar role="assistant" isActive label={assistantLabel} />
|
||||
<div className={`max-w-[70%] rounded-2xl px-4 py-3 shadow-sm border ${isDark ? 'bg-slate-700/60 border-slate-600/50 text-slate-200' : 'bg-white border-red-100 text-gray-700'
|
||||
}`}>
|
||||
<div className="flex items-center gap-3">
|
||||
<Loader2 className={`w-4 h-4 animate-spin ${isDark ? 'text-blue-300' : 'text-red-500'}`} />
|
||||
<span
|
||||
className={`text-sm font-medium qa-generating-marquee ${isDark ? 'qa-generating-marquee-dark' : 'qa-generating-marquee-light'}`}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
{/* <div className="flex gap-1">
|
||||
{[0, 1, 2].map((idx) => (
|
||||
<span
|
||||
key={idx}
|
||||
className={`w-1.5 h-1.5 rounded-full qa-typing-dot ${isDark ? 'bg-blue-300' : 'bg-red-400'}`}
|
||||
style={{
|
||||
animationDelay: `${idx * 160}ms`,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface ChatMessageProps<T extends QACommonMessage> {
|
||||
message: T;
|
||||
showSources?: boolean;
|
||||
assistantLabel?: string;
|
||||
assistantActive?: boolean;
|
||||
onCitationClick?: (message: T, citationIndex: number) => void;
|
||||
onCopyAssistant?: (message: T) => void;
|
||||
onDeleteAssistant?: (message: T) => void;
|
||||
onEditAssistant?: (message: T) => void;
|
||||
onResendAssistant?: (message: T) => void;
|
||||
renderAssistantExtra?: (message: T) => React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天消息渲染器。
|
||||
*
|
||||
* 根据消息类型自动选择普通文本、单轮 RAG 回答或多轮检索思考链。
|
||||
* sources 区域独立折叠展示,避免引用资料过长时挤占主回答阅读空间。
|
||||
*/
|
||||
export function ChatMessage<T extends QACommonMessage>({
|
||||
message,
|
||||
showSources = true,
|
||||
assistantLabel = 'AI 助手',
|
||||
assistantActive = false,
|
||||
onCitationClick,
|
||||
onCopyAssistant,
|
||||
onDeleteAssistant,
|
||||
onEditAssistant,
|
||||
onResendAssistant,
|
||||
renderAssistantExtra,
|
||||
}: ChatMessageProps<T>) {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const isUser = message.role === 'user';
|
||||
const hasTrace = !isUser && !!(message.singleRagTrace || message.thinkingTrace);
|
||||
const knowledgeUrl = import.meta.env.VITE_AIPI_KNOWLEDGE_URL;
|
||||
const [visible, setVisible] = useState(false); // 打开详情对话框
|
||||
const [listData, setListData] = useState<SourceItem>({
|
||||
title: '',
|
||||
type: '',
|
||||
time: '',
|
||||
snippet: '',
|
||||
source: '',
|
||||
content: '',
|
||||
});
|
||||
const showDialog = (item: SourceItem) => {
|
||||
console.log('item', item)
|
||||
if (item.url) {
|
||||
window.open(`${knowledgeUrl}/#/knowledge/mid-detail?recUuid=${item.url}`);
|
||||
} else {
|
||||
setListData(item);
|
||||
setVisible(true);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className={`flex gap-3 ${isUser ? 'justify-end' : ''}`}>
|
||||
{!isUser && <QAAvatar role="assistant" isActive={assistantActive} label={assistantLabel} />}
|
||||
<div className={`${hasTrace ? 'max-w-[85%] flex-1' : 'max-w-[72%]'} rounded-2xl px-4 py-3 shadow-sm ${isUser
|
||||
? isDark
|
||||
? 'bg-blue-600/70 text-white'
|
||||
: 'bg-gradient-to-r from-red-500 to-rose-500 text-white'
|
||||
: message.singleRagTrace || message.thinkingTrace
|
||||
? isDark
|
||||
? 'bg-slate-800/40 text-slate-100 border border-slate-600/40'
|
||||
: 'bg-white text-gray-800 border border-transparent shadow-[0px_3px_12px_rgba(0, 0, 0, 0.12)] px-0 py-0'
|
||||
: isDark
|
||||
? 'bg-slate-700/60 text-slate-100 border border-slate-600/40'
|
||||
: 'bg-white text-gray-800 border border-gray-100'
|
||||
}`}>
|
||||
{message.singleRagTrace && !isUser ? (
|
||||
<SingleRagAnswer
|
||||
trace={message.singleRagTrace}
|
||||
onCitationClick={(citationIndex) => onCitationClick?.(message, citationIndex)}
|
||||
/>
|
||||
) : message.thinkingTrace && !isUser ? (
|
||||
<RetrievalThinkingTrace
|
||||
trace={message.thinkingTrace}
|
||||
onCitationClick={(citationIndex) => onCitationClick?.(message, citationIndex)}
|
||||
/>
|
||||
) : (
|
||||
<p className="whitespace-pre-wrap leading-relaxed">{message.content}</p>
|
||||
)}
|
||||
{!isUser && (onCopyAssistant || onDeleteAssistant || onEditAssistant || onResendAssistant) && (
|
||||
<div className={`mt-2 flex items-center justify-end gap-1.5 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
{onCopyAssistant && (
|
||||
<button type="button" onClick={() => onCopyAssistant(message)} className={`p-1.5 rounded-md transition-colors ${isDark ? 'hover:bg-slate-700 hover:text-slate-100' : 'hover:bg-gray-100 hover:text-gray-700'}`} title="复制回答">
|
||||
<Copy className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
{onDeleteAssistant && (
|
||||
<button type="button" onClick={() => onDeleteAssistant(message)} className={`p-1.5 rounded-md transition-colors ${isDark ? 'hover:bg-slate-700 hover:text-rose-300' : 'hover:bg-red-50 hover:text-red-600'}`} title="删除问答">
|
||||
<Trash2 className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
{onEditAssistant && (
|
||||
<button type="button" onClick={() => onEditAssistant(message)} className={`p-1.5 rounded-md transition-colors ${isDark ? 'hover:bg-slate-700 hover:text-blue-300' : 'hover:bg-blue-50 hover:text-blue-600'}`} title="编辑回答和思考过程">
|
||||
<Edit3 className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
{onResendAssistant && (
|
||||
<button type="button" onClick={() => onResendAssistant(message)} className={`p-1.5 rounded-md transition-colors ${isDark ? 'hover:bg-slate-700 hover:text-emerald-300' : 'hover:bg-emerald-50 hover:text-emerald-600'}`} title="重新发送">
|
||||
<RotateCcw className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{isUser && <QAAvatar role="user" label="用户" />}
|
||||
</div>
|
||||
|
||||
|
||||
{!isUser && message.sources && message.sources.length > 0 && showSources && (
|
||||
<CollapsibleSection
|
||||
defaultOpen={false}
|
||||
className={`ml-12 ${hasTrace ? 'max-w-[85%]' : 'max-w-[72%]'} ${isDark ? 'bg-slate-800/50 border-slate-700/50' : 'bg-gray-50 border-gray-200'}`}
|
||||
title={(
|
||||
<div className="flex items-center gap-2">
|
||||
<BrainCircuit className={`w-3.5 h-3.5 ${isDark ? 'text-blue-300' : 'text-red-500'}`} />
|
||||
<span className={`text-xs font-medium ${isDark ? 'text-slate-300' : 'text-gray-700'}`}>引用来源</span>
|
||||
<span className={`text-xs ${isDark ? 'text-slate-500' : 'text-gray-500'}`}>({message.sources.length})</span>
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
<div className="space-y-2 pt-[10px]">
|
||||
{message.sources.map((source, idx) => (
|
||||
<div key={idx} className={`text-xs p-2 rounded-[4px] border shadow-sm transition-all duration-200 ease-out cursor-pointer hover:-translate-y-0.5 hover:scale-[1.01] ${isDark ? 'bg-slate-700/50 border-slate-600/50 shadow-black/10 hover:bg-slate-700/80 hover:border-blue-400/40 hover:shadow-lg hover:shadow-blue-950/20' : 'bg-white border-gray-100 shadow-gray-200/60 hover:border-red-200 hover:shadow-md hover:shadow-red-100/70'}`} onClick={() => showDialog(source)}>
|
||||
<div className="flex items-center gap-2 mb-1 min-w-0">
|
||||
<BrainCircuit className={`w-3 h-3 shrink-0 ${isDark ? 'text-blue-400' : 'text-red-400'}`} />
|
||||
<span className={`font-medium truncate min-w-0 flex-1 ${isDark ? 'text-slate-300' : 'text-gray-700'}`} title={source.title}>{source.title}</span>
|
||||
<span className={`shrink-0 px-1.5 py-0.5 rounded text-xs ${isDark ? 'bg-slate-600 text-slate-300' : 'bg-gray-200 text-gray-500'}`}>
|
||||
{source.type}
|
||||
</span>
|
||||
</div>
|
||||
<p className={`line-clamp-3 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>{source.snippet}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CollapsibleSection>
|
||||
)}
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onClose={() => setVisible(false)}
|
||||
header="提示"
|
||||
footer={null}
|
||||
>
|
||||
<div>
|
||||
<div className="pr-9">
|
||||
<h3 className="text-base font-semibold">{listData.title || '引用内容'}</h3>
|
||||
<div className={`mt-2 text-xs space-y-1 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
<div>来源:{listData.source || '未知来源'}</div>
|
||||
<div>时间:{listData.time || '未知'}</div>
|
||||
</div>
|
||||
</div>
|
||||
{listData.url && (
|
||||
<div className="mt-4">
|
||||
<a
|
||||
href={`${knowledgeUrl}/#/knowledge/mid-detail?recUuid=${listData.url}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className={`inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border text-sm transition-all ${isDark
|
||||
? 'border-slate-600 text-slate-200 hover:bg-slate-800'
|
||||
: 'border-gray-300 text-gray-700 hover:bg-gray-50'
|
||||
}`}
|
||||
title="打开原始链接"
|
||||
>
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
查看原文链接
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
<div className={`mt-4 rounded-xl p-3 text-sm leading-relaxed whitespace-pre-wrap ${isDark ? 'bg-slate-800/70 text-slate-200' : 'bg-gray-50 text-gray-700'
|
||||
}`}>
|
||||
{listData.content || '暂无引用内容'}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
{!isUser && renderAssistantExtra?.(message)}
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface CollapsibleSectionProps {
|
||||
title: React.ReactNode;
|
||||
children: React.ReactNode;
|
||||
defaultOpen?: boolean;
|
||||
className?: string;
|
||||
headerClassName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用折叠面板。
|
||||
*
|
||||
* 思考过程、检索结果、引用来源都复用该组件,保证展开/收起动画和深浅色主题一致。
|
||||
*/
|
||||
const CollapsibleSection: React.FC<CollapsibleSectionProps> = ({
|
||||
title,
|
||||
children,
|
||||
defaultOpen = true,
|
||||
className = '',
|
||||
headerClassName = '',
|
||||
}) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const [open, setOpen] = useState(defaultOpen);
|
||||
// 当 defaultOpen 改变时,更新 open 状态
|
||||
useEffect(() => {
|
||||
setOpen(defaultOpen);
|
||||
}, [defaultOpen]);
|
||||
return (
|
||||
<div className={`rounded-2xl border overflow-hidden ${isDark ? 'border-slate-700/60 bg-slate-900/30' : 'border-red-100 bg-white'} ${className}`}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
className={`w-full flex items-center justify-between gap-3 px-4 py-3 text-left transition-colors ${isDark ? 'hover:bg-slate-800/70' : 'hover:bg-red-50/60'
|
||||
} ${headerClassName}`}
|
||||
>
|
||||
<div className="flex-1 min-w-0">{title}</div>
|
||||
<ChevronDown
|
||||
className={`w-4 h-4 flex-shrink-0 transition-transform duration-300 ease-out ${open ? 'rotate-0' : '-rotate-90'
|
||||
} ${isDark ? 'text-slate-400' : 'text-gray-500'}`}
|
||||
/>
|
||||
</button>
|
||||
<div className={`grid transition-[grid-template-rows,opacity] duration-300 ease-out ${open ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0'}`}>
|
||||
<div className="overflow-hidden">
|
||||
<div className={`px-4 pb-4 transition-transform duration-300 ease-out ${open ? 'translate-y-0' : '-translate-y-2'} ${isDark ? 'text-slate-200' : 'text-gray-700'}`}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface SingleRagAnswerProps {
|
||||
trace: QASingleRagTrace;
|
||||
onCitationClick?: (citationIndex: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单轮 RAG 回答展示。
|
||||
*
|
||||
* 思考内容和最终回答分成两个区域:思考区可折叠,回答区始终展示。
|
||||
* 这样既保留模型推理过程,也不会影响用户优先阅读最终答案。
|
||||
*/
|
||||
export const SingleRagAnswer: React.FC<SingleRagAnswerProps> = ({ trace, onCitationClick }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
|
||||
return (
|
||||
<div className="w-full min-w-0 max-w-5xl space-y-4 overflow-hidden">
|
||||
<CollapsibleSection
|
||||
defaultOpen={!trace.thinkingComplete}
|
||||
className={isDark ? 'bg-slate-800/60 shadow-lg shadow-black/10' : 'bg-white shadow-sm'}
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`w-9 h-9 rounded-2xl flex items-center justify-center ${isDark ? 'bg-violet-500/15 text-violet-300' : 'bg-orange-50 text-orange-500'
|
||||
}`}>
|
||||
<Sparkles className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<div className={`text-sm font-semibold ${isDark ? 'text-white' : 'text-gray-900'}`}>{trace.title || '思考过程'}</div>
|
||||
{trace.thinkingComplete ? (
|
||||
<div className={`text-xs ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
思考已完成,可展开查看
|
||||
</div>
|
||||
) : (
|
||||
<div className={`text-xs qa-generating-marquee ${isDark ? 'qa-generating-marquee-dark text-slate-300' : 'qa-generating-marquee-light text-gray-600'}`}>
|
||||
正在接收 <think> 流式思考内容
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{trace.thinkingMarkdown ? (
|
||||
<MarkdownRenderer
|
||||
content={trace.thinkingMarkdown}
|
||||
className={`text-sm ${isDark ? 'text-slate-300' : 'text-gray-700'}`}
|
||||
onCitationClick={onCitationClick}
|
||||
/>
|
||||
) : (
|
||||
<div className={`text-sm flex items-center gap-2 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
等待模型输出思考内容...
|
||||
</div>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
<div className={`rounded-2xl border p-4 ${isDark ? 'bg-slate-700/60 border-slate-600/40' : 'bg-white border-gray-100'}`}>
|
||||
{trace.answerMarkdown ? (
|
||||
<MarkdownRenderer
|
||||
content={trace.answerMarkdown}
|
||||
className={`text-sm ${isDark ? 'text-slate-200' : 'text-gray-700'}`}
|
||||
onCitationClick={onCitationClick}
|
||||
/>
|
||||
) : (
|
||||
<div className={`text-sm flex items-center gap-2 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
{trace.thinkingComplete ? '正在流式生成回答...' : '思考结束后开始生成回答...'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface RetrievalListProps {
|
||||
items: QARetrievalItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 检索结果列表。
|
||||
*
|
||||
* 每条资料默认折叠,首条默认展开,便于用户快速看到最相关资料,同时保留完整资料明细。
|
||||
*/
|
||||
const RetrievalList: React.FC<RetrievalListProps> = ({ items }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const [visible, setVisible] = useState(false); // 打开详情对话框
|
||||
const [listData, setListData] = useState<QARetrievalItem>({
|
||||
title: '',
|
||||
content: '',
|
||||
});
|
||||
const knowledgeUrl = import.meta.env.VITE_AIPI_KNOWLEDGE_URL;
|
||||
const b1SearchUrl = import.meta.env.VITE_AIPI_B1COH_URL;
|
||||
const b2SearchUrl = import.meta.env.VITE_AIPI_B2ACTOR_URL;
|
||||
const showDialog = (item: QARetrievalItem) => {
|
||||
console.log('item', item)
|
||||
if (item.type === 'more') {
|
||||
if (item.recUuid) {
|
||||
window.open(`${knowledgeUrl}/#/knowledge/mid-detail?recUuid=${item.recUuid}`);
|
||||
} else {
|
||||
setListData(item);
|
||||
setVisible(true);
|
||||
}
|
||||
} else if (item.type === 'task') {
|
||||
window.open(`${b1SearchUrl}/#/task/item-aicoh/step-info-search?id=${item.id}`)
|
||||
} else if (item.type === 'hx') {
|
||||
window.open(`${b2SearchUrl}/fromB/toDetail?user_id=${item.id}&platform=${item.platform}`);
|
||||
} else {
|
||||
setListData(item);
|
||||
setVisible(true);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{items.map((item, index) => (
|
||||
<div key={index}>
|
||||
{
|
||||
item.type !== 'user_behavior' ? <CollapsibleSection
|
||||
key={index}
|
||||
defaultOpen={index === 0}
|
||||
className={isDark ? 'bg-slate-800/40' : 'bg-gray-50/70'}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`w-6 h-6 rounded-lg flex items-center justify-center text-xs font-semibold ${isDark ? 'bg-blue-500/20 text-blue-300' : 'bg-red-100 text-red-600'
|
||||
}`}>{index + 1}</span>
|
||||
<div className="min-w-0">
|
||||
<div className={`text-sm font-medium truncate ${isDark ? 'text-slate-100' : 'text-gray-900'}`}>{item.title}</div>
|
||||
{
|
||||
item.type === 'more' && <div className={`text-xs truncate ${isDark ? 'text-slate-500' : 'text-gray-500'}`}>时间:{item.time || '-'}</div>
|
||||
}
|
||||
{
|
||||
item.type === 'task' && <div className={`text-xs truncate ${isDark ? 'text-slate-500' : 'text-gray-500'}`}>关键词:{item.keywords || '-'}</div>
|
||||
}
|
||||
{
|
||||
item.type === 'hx' && <div className={`text-xs truncate ${isDark ? 'text-slate-500' : 'text-gray-500'}`}><span>平台:{item.platform || '-'}</span><span className="ml-[10px]">粉丝数:{item.fans || '-'}</span></div>
|
||||
}
|
||||
{
|
||||
(item.type === 'taiwan_news' || item.type === 'world_news' || item.type === 'messaage_comment' || item.type === 'america_news') && <div className={`text-xs truncate ${isDark ? 'text-slate-500' : 'text-gray-500'}`}><span>平台:{item.platform || '-'}</span>{item.comment_count && <span className="ml-[10px]">评论数:{item.comment_count || '-'}</span>}</div>
|
||||
}
|
||||
{
|
||||
item.type === 'get_time_data' && <div className={`text-xs truncate ${isDark ? 'text-slate-500' : 'text-gray-500'}`}><span>时间:{item.time || '-'}</span><span className="ml-[10px]">热度:{item.hot_num || '-'}</span></div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<p className={`text-sm leading-relaxed cursor-progress line-clamp-3 hover:underline ${isDark ? 'text-slate-300' : 'text-gray-600'}`} onClick={() => showDialog(item)}>{item.content}</p>
|
||||
</CollapsibleSection>
|
||||
: <div className="rounded-[5px] border border-[#f5f5f5] p-[10px]" key={index + 10}>
|
||||
<span className="font-bold mr-[10px]">{index + 1}.</span>
|
||||
<span>{item.title}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onClose={() => setVisible(false)}
|
||||
header="提示"
|
||||
footer={null}
|
||||
>
|
||||
<div>
|
||||
<div className="pr-9">
|
||||
<h3 className="text-base font-semibold">{listData.title}</h3>
|
||||
<div className={`mt-2 text-xs space-y-1 ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
{listData.time && <span>时间:{listData.time || '未知'}</span>}
|
||||
{listData.platform && <span className="ml-[10px]">平台:{listData.platform || '未知'}</span>}
|
||||
{listData.comment_count && <span className="ml-[10px]">评论数:{listData.comment_count || '未知'}</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className={`mt-4 rounded-xl p-3 text-sm leading-relaxed whitespace-pre-wrap ${isDark ? 'bg-slate-800/70 text-slate-200' : 'bg-gray-50 text-gray-700'
|
||||
}`}>
|
||||
{listData.content || '暂无引用内容'}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface SearchQueryBadgeProps {
|
||||
query: string;
|
||||
loading?: boolean;
|
||||
queryTitle?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检索词徽标。
|
||||
*
|
||||
* 多轮检索每一轮都会产生一个 query;loading 状态下展示旋转图标,表示该 query 正在召回资料。
|
||||
*/
|
||||
const SearchQueryBadge: React.FC<SearchQueryBadgeProps> = ({ query, loading = false, queryTitle = '检索词' }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
|
||||
return (
|
||||
<div className={`inline-flex max-w-full items-center gap-2 rounded-full px-3 py-1.5 border ${isDark ? 'bg-blue-500/10 border-blue-400/20 text-blue-200' : 'bg-red-50 border-red-100 text-red-600'
|
||||
}`}>
|
||||
{loading ? <Loader2 className="w-3.5 h-3.5 animate-spin" /> : <Search className="w-3.5 h-3.5" />}
|
||||
<span className="text-xs flex-shrink-0">{queryTitle}</span>
|
||||
<span className={`text-xs font-medium truncate ${loading && 'qa-generating-marquee'} ${loading && (isDark ? 'qa-generating-marquee-dark' : 'qa-generating-marquee-light')}`}>
|
||||
{query}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface RetrievalThinkingTraceProps {
|
||||
trace: QAThinkingTrace;
|
||||
onCitationClick?: (citationIndex: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多轮/深度检索思考链展示。
|
||||
*
|
||||
* 组件按轮次渲染思考内容、检索词和检索结果,底部展示最终回答。
|
||||
* 它只消费已经整理好的 trace 数据,不关心数据来自真实 SSE 还是本地模拟。
|
||||
*/
|
||||
export const RetrievalThinkingTrace: React.FC<RetrievalThinkingTraceProps> = ({ trace, onCitationClick }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
|
||||
return (
|
||||
<div className="w-full min-w-0 max-w-5xl space-y-4 overflow-hidden">
|
||||
<CollapsibleSection
|
||||
defaultOpen={!trace.thinkingComplete}
|
||||
className={isDark ? 'bg-slate-800/60 shadow-lg shadow-black/10' : 'bg-white shadow-sm'}
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`w-9 h-9 rounded-2xl flex items-center justify-center ${isDark ? 'bg-cyan-500/15 text-cyan-300' : 'bg-red-50 text-red-500'
|
||||
}`}>
|
||||
<BrainCircuit className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<div className={`text-sm font-semibold ${isDark ? 'text-white' : 'text-gray-900'}`}>
|
||||
{trace.title || '思考过程'}
|
||||
</div>
|
||||
<div className={`text-xs ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
共 {trace.rounds.length} 轮推理与检索,可展开查看细节
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-3 pt-1">
|
||||
{trace.rounds.map((round, index) => (
|
||||
<div key={index} className={`relative pl-5 ${index < trace.rounds.length - 1 ? 'pb-2' : ''}`}>
|
||||
{index < trace.rounds.length - 1 && (
|
||||
<div className={`absolute left-[7px] top-8 bottom-0 w-px ${isDark ? 'bg-slate-700' : 'bg-red-100'}`} />
|
||||
)}
|
||||
<div className={`absolute left-0 top-4 w-3.5 h-3.5 rounded-full border-2 ${isDark ? 'bg-slate-900 border-cyan-400' : 'bg-white border-red-400'
|
||||
}`} />
|
||||
<CollapsibleSection
|
||||
defaultOpen
|
||||
className={isDark ? 'bg-slate-900/40' : 'bg-red-50/30'}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`px-2 py-0.5 rounded-full text-xs font-medium ${isDark ? 'bg-cyan-500/15 text-cyan-300' : 'bg-red-100 text-red-600'
|
||||
}`}>第 {index + 1} 轮</span>
|
||||
<span className={`text-sm font-medium ${round.queryLoading && 'qa-generating-marquee'} ${round.queryLoading && (isDark ? 'text-slate-100 qa-generating-marquee-dark' : 'text-gray-900 qa-generating-marquee-light')}`}>{round.title}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-3">
|
||||
<CollapsibleSection
|
||||
defaultOpen
|
||||
className={isDark ? 'bg-slate-800/50' : 'bg-white/80'}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<Sparkles className={`w-4 h-4 ${isDark ? 'text-violet-300' : 'text-orange-500'}`} />
|
||||
<span className={`text-sm font-medium ${isDark ? 'text-slate-100' : 'text-gray-800'}`}>思考内容</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<MarkdownRenderer
|
||||
content={round.thoughtMarkdown}
|
||||
className={`text-sm ${isDark ? 'text-slate-300' : 'text-gray-700'}`}
|
||||
onCitationClick={onCitationClick}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
{
|
||||
round.queryShow &&
|
||||
<div className="flex items-center">
|
||||
<SearchQueryBadge query={round.query} queryTitle={round.queryTitle} loading={round.queryLoading} />
|
||||
</div>
|
||||
}
|
||||
{
|
||||
round.queryShow &&
|
||||
<CollapsibleSection
|
||||
defaultOpen={!round.queryLoading}
|
||||
className={isDark ? 'bg-slate-800/50' : 'bg-white/80'}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<FileSearch className={`w-4 h-4 ${isDark ? 'text-blue-300' : 'text-red-500'}`} />
|
||||
<span className={`text-sm font-medium ${isDark ? 'text-slate-100' : 'text-gray-800'}`}>检索内容</span>
|
||||
<span className={`text-xs ${isDark ? 'text-slate-500' : 'text-gray-400'}`}>{round.retrievals.length} 条</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{round.queryLoading ? (
|
||||
<div className={`rounded-xl px-3 py-4 text-sm flex items-center gap-2 ${isDark ? 'bg-slate-900/60 text-slate-400' : 'bg-gray-50 text-gray-500'}`}>
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
正在召回相关内容...
|
||||
</div>
|
||||
) : (
|
||||
<RetrievalList items={round.retrievals} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
}
|
||||
{
|
||||
round.textidContent &&
|
||||
<div className="mt-[10px]">
|
||||
{round.textidContent}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</CollapsibleSection>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CollapsibleSection>
|
||||
|
||||
<div className={`rounded-2xl border p-4 ${isDark ? 'bg-slate-700/60 border-slate-600/40' : 'bg-white border-gray-100'}`}>
|
||||
<div className={`text-sm font-semibold mb-3 ${isDark ? 'text-white' : 'text-gray-900'}`}>最终回答</div>
|
||||
{
|
||||
!trace.finalAnswerMarkdown && <div className={`rounded-xl px-3 py-4 text-sm flex items-center gap-2 ${isDark ? 'bg-slate-900/60 text-slate-400' : 'bg-gray-50 text-gray-500'}`}>
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
正在生成思考过程与检索内容...
|
||||
</div>
|
||||
}
|
||||
<MarkdownRenderer
|
||||
content={trace.finalAnswerMarkdown}
|
||||
className={`text-sm ${isDark ? 'text-slate-200' : 'text-gray-700'}`}
|
||||
onCitationClick={onCitationClick}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface EmptyChatStateProps {
|
||||
icon?: React.ReactNode;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 空状态展示。
|
||||
*
|
||||
* 当当前模式没有任何消息时使用,提示用户可以开始输入问题。
|
||||
*/
|
||||
export const EmptyChatState: React.FC<EmptyChatStateProps> = ({ icon, title, description }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
|
||||
return (
|
||||
<div className={`h-full flex flex-col items-center justify-center ${isDark ? 'text-slate-500' : 'text-gray-400'}`}>
|
||||
<div className={`w-20 h-20 rounded-3xl mb-5 flex items-center justify-center ${isDark ? 'bg-slate-700/40' : 'bg-gradient-to-br from-red-50 to-orange-50'
|
||||
}`}>
|
||||
{icon ?? <Bot className="w-11 h-11 opacity-60" />}
|
||||
</div>
|
||||
<p className="text-lg font-medium">{title}</p>
|
||||
<p className="text-sm mt-2">{description}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface QAComposerProps {
|
||||
value: string;
|
||||
placeholder: string;
|
||||
isLoading: boolean;
|
||||
canSubmit?: boolean;
|
||||
onChange: (value: string) => void;
|
||||
onSubmit: () => void;
|
||||
onStop: () => void;
|
||||
onKeyDown?: (val: string) => void;
|
||||
onUpload?: () => void;
|
||||
onReset?: () => void;
|
||||
onSave?: () => void;
|
||||
onCollect?: () => void;
|
||||
onOpenSettings?: () => void;
|
||||
showUpload?: boolean;
|
||||
showReset?: boolean;
|
||||
showSave?: boolean;
|
||||
showCollect?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 问答输入区。
|
||||
*
|
||||
* 负责输入、发送/停止、附件、重置、保存、收藏和模型参数设置入口。
|
||||
* 具体业务动作通过 props 回调交给父组件处理,保证输入区本身不依赖某个问答模式。
|
||||
*/
|
||||
export const QAComposer: React.FC<QAComposerProps> = ({
|
||||
value,
|
||||
placeholder,
|
||||
isLoading,
|
||||
canSubmit,
|
||||
onChange,
|
||||
onSubmit,
|
||||
onStop,
|
||||
onKeyDown,
|
||||
onUpload,
|
||||
onReset,
|
||||
onSave,
|
||||
onCollect,
|
||||
onOpenSettings,
|
||||
showUpload = true,
|
||||
showReset = false,
|
||||
showSave = true,
|
||||
showCollect = true,
|
||||
}) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const submitEnabled = canSubmit ?? Boolean(value.trim());
|
||||
const iconButtonClass = `p-2 rounded-lg transition-colors ${isDark ? 'hover:bg-slate-600 text-slate-400' : 'hover:bg-gray-200 text-gray-500'}`;
|
||||
const handleKeyDown = (val: string, context: { e: React.KeyboardEvent }) => {
|
||||
if (context?.e?.key === 'Enter') {
|
||||
context.e.preventDefault();
|
||||
onKeyDown?.(val);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className={`border-t p-4 ${isDark ? 'border-slate-700/50' : 'border-red-100'}`}>
|
||||
<div className={`flex items-end gap-3 rounded-2xl p-3 shadow-inner ${isDark ? 'bg-slate-700/50' : 'bg-gray-100'}`}>
|
||||
<Textarea
|
||||
value={value}
|
||||
onChange={(nextValue) => onChange(String(nextValue))}
|
||||
onKeydown={handleKeyDown}
|
||||
placeholder={placeholder}
|
||||
autosize={{ minRows: 1, maxRows: 15 }}
|
||||
disabled={isLoading}
|
||||
className={`flex-1 !bg-transparent !border-0 !shadow-none qa-composer-textarea [&]:!border-0 [&]:!shadow-none [&]:!outline-none [&]:focus:!border-0 [&]:focus:!shadow-none [&]:focus:!outline-none [&_.t-textarea]:!border-0 [&_.t-textarea]:!shadow-none [&_.t-textarea]:!outline-none [&_.t-textarea:hover]:!border-0 [&_.t-textarea:hover]:!shadow-none [&_.t-textarea--focused]:!border-0 [&_.t-textarea--focused]:!shadow-none [&_.t-is-focused]:!border-0 [&_.t-is-focused]:!shadow-none [&_.t-textarea__inner]:!bg-transparent [&_.t-textarea__inner]:!border-0 [&_.t-textarea__inner]:!shadow-none [&_.t-textarea__inner]:!outline-none [&_.t-textarea__inner]:!resize-none [&_.t-textarea__inner]:!min-h-[40px] [&_.t-textarea__inner]:!p-0 [&_.t-textarea__inner:hover]:!border-0 [&_.t-textarea__inner:hover]:!shadow-none [&_.t-textarea__inner:focus]:!border-0 [&_.t-textarea__inner:focus]:!shadow-none [&_.t-textarea__inner:focus]:!outline-none [&_.t-textarea__inner]:disabled:!cursor-not-allowed ${isDark
|
||||
? '[&_.t-textarea__inner]:!text-white [&_.t-textarea__inner]:placeholder:!text-slate-500'
|
||||
: '[&_.t-textarea__inner]:!text-gray-800 [&_.t-textarea__inner]:placeholder:!text-gray-400'
|
||||
}`}
|
||||
/>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{/* {showUpload && (
|
||||
<button onClick={onUpload} className={iconButtonClass} title="上传附件" type="button">
|
||||
<Upload className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
{showReset && (
|
||||
<button onClick={onReset} className={iconButtonClass} title="重新提问" type="button">
|
||||
<RotateCcw className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
{showSave && (
|
||||
<button onClick={onSave} className={iconButtonClass} title="保存记录" type="button">
|
||||
<Bookmark className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
{showCollect && (
|
||||
<button onClick={onCollect} className={iconButtonClass} title="加入收藏" type="button">
|
||||
<Bookmark className="w-5 h-5" />
|
||||
</button>
|
||||
)} */}
|
||||
{onOpenSettings && (
|
||||
<button onClick={onOpenSettings} className={iconButtonClass} title="模型参数设置" type="button">
|
||||
<Settings className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
onClick={isLoading ? onStop : onSubmit}
|
||||
disabled={!isLoading && !submitEnabled}
|
||||
className={`px-4 py-2 rounded-xl font-medium transition-all flex items-center gap-2 shadow-sm ${isLoading
|
||||
? isDark
|
||||
? 'bg-rose-600 text-white qa-stop-breathing'
|
||||
: 'bg-red-600 text-white qa-stop-breathing'
|
||||
: submitEnabled
|
||||
? isDark
|
||||
? 'bg-blue-600 hover:bg-blue-700 text-white'
|
||||
: 'bg-red-500 hover:bg-red-600 text-white'
|
||||
: isDark
|
||||
? 'bg-slate-600 text-slate-400 cursor-not-allowed'
|
||||
: 'bg-gray-300 text-gray-500 cursor-not-allowed'
|
||||
}`}
|
||||
type="button"
|
||||
>
|
||||
{isLoading ? <Square className="w-4 h-4 fill-current" /> : <Send className="w-4 h-4" />}
|
||||
{isLoading ? '停止' : '发送'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,80 +0,0 @@
|
||||
import { History } from 'lucide-react';
|
||||
import type { ViewMode } from './GeneralQA.types';
|
||||
|
||||
/**
|
||||
* 顶部栏 Props。
|
||||
*
|
||||
* `setViewMode` 由父组件传入,父组件会在生成中切换时做确认拦截;
|
||||
* Header 本身不直接感知 loading,保持纯展示和事件转发。
|
||||
*/
|
||||
type Props = {
|
||||
isDark: boolean; // 当前是否为暗黑主题,用于样式适配
|
||||
viewMode: ViewMode; // 当前视图模式:'single' 单一模式 或 'compare' 对比模式
|
||||
setViewMode: (mode: ViewMode) => void; // 设置视图模式回调函数
|
||||
};
|
||||
|
||||
/**
|
||||
* 通用问答页面顶部栏。
|
||||
*
|
||||
* 该组件只负责页面标题、模式切换和历史记录入口,所有业务状态仍由父组件维护。
|
||||
* 这样拆分后,顶部导航的样式和交互不会和中间问答流处理逻辑混在一起,后续如果要新增
|
||||
* “保存模板”“导出记录”等入口,也可以只改这个文件。
|
||||
*/
|
||||
export default function GeneralQAHeader({ isDark, viewMode, setViewMode }: Props): JSX.Element {
|
||||
return (
|
||||
<div className={`flex items-center justify-between px-6 py-4 border-b ${isDark ? 'border-slate-700/50' : 'border-red-100'}`}>
|
||||
<div className="flex items-center gap-4">
|
||||
<h1 className={`text-lg font-semibold ${isDark ? 'text-white' : 'text-gray-900'}`}>
|
||||
通用问答
|
||||
</h1>
|
||||
<span className={`text-sm ${isDark ? 'text-slate-400' : 'text-gray-500'}`}>
|
||||
支持单轮RAG、多轮RAG、深度检索及结果对比
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<div className={`flex rounded-lg p-1 ${isDark ? 'bg-slate-700/50' : 'bg-red-50'}`}>
|
||||
<button
|
||||
onClick={() => setViewMode('single')}
|
||||
className={`px-4 py-2 rounded-md text-sm font-medium transition-all ${
|
||||
viewMode === 'single'
|
||||
? isDark
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-red-500 text-white'
|
||||
: isDark
|
||||
? 'text-slate-400 hover:text-white'
|
||||
: 'text-gray-600 hover:text-red-600'
|
||||
}`}
|
||||
>
|
||||
单一模式
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setViewMode('compare')}
|
||||
className={`px-4 py-2 rounded-md text-sm font-medium transition-all ${
|
||||
viewMode === 'compare'
|
||||
? isDark
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-red-500 text-white'
|
||||
: isDark
|
||||
? 'text-slate-400 hover:text-white'
|
||||
: 'text-gray-600 hover:text-red-600'
|
||||
}`}
|
||||
>
|
||||
对比模式
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all ${
|
||||
isDark
|
||||
? 'bg-slate-700/50 text-slate-300 hover:bg-slate-600/50'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
}`}
|
||||
>
|
||||
<History className="w-4 h-4" />
|
||||
历史记录
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useTheme } from '../../../contexts/ThemeContext';
|
||||
import MarkdownRenderer from '../../MarkdownRenderer';
|
||||
import './qa-animations.css';
|
||||
|
||||
/**
|
||||
* 单条检索结果。
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* QA 系列共享动画与样式
|
||||
*
|
||||
* 这些类被 QACommon.tsx(以及通过它的 GeneralQA / AgentQA / CollaborativeQA)使用。
|
||||
* 全部样式从 web-code/theme.css、web-code/App.css 和 web-code/index.css 迁移而来,
|
||||
* 仅保留 QA 系列实际使用的部分。
|
||||
*/
|
||||
|
||||
/* ── 头像扫光(生成中沿头像横扫的高光条) ───────────────────────────── */
|
||||
@keyframes qa-avatar-shine {
|
||||
0% {
|
||||
transform: translateX(-120%) skewX(-18deg);
|
||||
opacity: 0;
|
||||
}
|
||||
45% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
100% {
|
||||
transform: translateX(120%) skewX(-18deg);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 头像整体微旋转(generating 状态) ─────────────────────────────── */
|
||||
@keyframes qa-avatar-orbit {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0deg) scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotate(4deg) scale(1.06);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 头像图标脉冲 ────────────────────────────────────────────────── */
|
||||
@keyframes qa-avatar-icon-pulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.12);
|
||||
opacity: 0.82;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 右上角 Sparkles 闪烁 ───────────────────────────────────────── */
|
||||
@keyframes qa-spark-twinkle {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(0.85) rotate(0deg);
|
||||
opacity: 0.65;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.15) rotate(18deg);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 停止按钮呼吸 ─────────────────────────────────────────────── */
|
||||
@keyframes qa-stop-breathing {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.04);
|
||||
box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── “正在生成” 跑马灯(文字渐变流动) ─────────────────────────── */
|
||||
@keyframes qa-generating-marquee {
|
||||
0% {
|
||||
background-position: 180% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: -80% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 输入中三个圆点跳动 ───────────────────────────────────────── */
|
||||
@keyframes qa-typing-dot {
|
||||
0%,
|
||||
80%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
opacity: 0.35;
|
||||
}
|
||||
40% {
|
||||
transform: translateY(-5px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 类绑定 ───────────────────────────────────────────────────── */
|
||||
.qa-avatar-active {
|
||||
animation: qa-avatar-orbit 1.8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-avatar-icon-active {
|
||||
animation: qa-avatar-icon-pulse 1.1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-avatar-active .qa-avatar-shine {
|
||||
animation: qa-avatar-shine 1.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-avatar-spark {
|
||||
animation: qa-spark-twinkle 1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-stop-breathing {
|
||||
animation: qa-stop-breathing 1.25s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-typing-dot {
|
||||
animation: qa-typing-dot 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.qa-generating-marquee {
|
||||
display: inline-block;
|
||||
background-size: 220% 100%;
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
-webkit-text-fill-color: transparent;
|
||||
animation: qa-generating-marquee 1.45s linear infinite;
|
||||
}
|
||||
|
||||
.qa-generating-marquee-light {
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
#4b5563 0%,
|
||||
#4b5563 34%,
|
||||
#ef4444 48%,
|
||||
#fb923c 55%,
|
||||
#4b5563 68%,
|
||||
#4b5563 100%
|
||||
);
|
||||
}
|
||||
|
||||
.qa-generating-marquee-dark {
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
#cbd5e1 0%,
|
||||
#cbd5e1 34%,
|
||||
#67e8f9 48%,
|
||||
#a78bfa 55%,
|
||||
#cbd5e1 68%,
|
||||
#cbd5e1 100%
|
||||
);
|
||||
}
|
||||
|
||||
/* ── 兜底:清掉 TDesign textarea 的边框/阴影/背景 ─────────────── */
|
||||
.qa-composer-textarea,
|
||||
.qa-composer-textarea .t-textarea,
|
||||
.qa-composer-textarea .t-textarea__inner {
|
||||
background: transparent !important;
|
||||
border: 0 !important;
|
||||
box-shadow: none !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.qa-composer-textarea .t-textarea__inner {
|
||||
resize: none !important;
|
||||
min-height: 40px !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import {
|
||||
getKnowledgeIframeApiUrl,
|
||||
getKnowledgeIframeSkin,
|
||||
} from "@/core/strategy/external-links";
|
||||
import { requestCrudService } from "@/service/request-axios-service";
|
||||
import "@/strategy-components/components/task-components/css/strategy-data.css";
|
||||
|
||||
const service = requestCrudService;
|
||||
|
||||
const KnowledgeBaseResourceManagement: React.FC = () => {
|
||||
const [iframeUrl, setIframeUrl] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const initIframeUrl = async () => {
|
||||
const apiUrl = getKnowledgeIframeApiUrl();
|
||||
if (!apiUrl) return;
|
||||
|
||||
const jsonStr = localStorage.getItem("userInfo");
|
||||
if (!jsonStr) return;
|
||||
|
||||
try {
|
||||
const userInfo = JSON.parse(jsonStr);
|
||||
const token = userInfo.accessToken;
|
||||
if (!token) return;
|
||||
|
||||
const res = (await service.post(apiUrl, {
|
||||
token,
|
||||
skin: getKnowledgeIframeSkin(),
|
||||
})) as { iframeUrl?: string };
|
||||
if (res?.iframeUrl) {
|
||||
setIframeUrl(res.iframeUrl);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to load knowledge iframe url:", error);
|
||||
}
|
||||
};
|
||||
|
||||
void initIframeUrl();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="strategy-data iframe-container">
|
||||
<iframe src={iframeUrl} className="full-size-iframe" title="知识库资源管理" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default KnowledgeBaseResourceManagement;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { getNetworkActorIframeUrl } from "@/core/strategy/external-links";
|
||||
import "@/strategy-components/components/task-components/css/strategy-data.css";
|
||||
|
||||
const NetworkActorResourceManagement: React.FC = () => {
|
||||
const [iframeUrl, setIframeUrl] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
setIframeUrl(getNetworkActorIframeUrl());
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="strategy-data iframe-container">
|
||||
<iframe src={iframeUrl} className="full-size-iframe" title="网络xwt资源管理" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NetworkActorResourceManagement;
|
||||
@@ -0,0 +1,207 @@
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { actionColumnItem, ActionListItem, TaskListItem, taskStatusList } from './TaskManagement';
|
||||
import { Bot, ChevronRight, Download, Edit, Eye, FileText, Layers, MoreHorizontal, Play, Search, User, Users, Workflow } from 'lucide-react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { format } from 'date-fns';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Col, Empty, Loading, Pagination, Progress, Row } from 'tdesign-react';
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
import { ActionColumn } from './ActionColumn';
|
||||
|
||||
interface ActionAnalyzesProps {
|
||||
TaskType?: string;
|
||||
title: string;
|
||||
category: string;
|
||||
subCategory: string;
|
||||
}
|
||||
|
||||
const service = requestCrudService;
|
||||
const zncmUrl = import.meta.env.VITE_API_BASE_URL || '';
|
||||
export const ActionAnalyzes: React.FC<ActionAnalyzesProps> = ({ title, category, subCategory}) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
// 主题颜色变量
|
||||
const cardBg = isDark ? 'bg-slate-800/30' : 'bg-white';
|
||||
const cardBorder = isDark ? 'border-blue-800/30' : 'border-red-100';
|
||||
const textPrimary = isDark ? 'text-white' : 'text-gray-900';
|
||||
const textSecondary = isDark ? 'text-slate-400' : 'text-gray-600';
|
||||
const textMuted = isDark ? 'text-slate-500' : 'text-gray-400';
|
||||
const inputBg = isDark ? 'bg-slate-900/50' : 'bg-white';
|
||||
const navigate = useNavigate();
|
||||
const [searchQuery, setSearchQuery] = useState<string>('');
|
||||
const [taskList, setTaskList] = useState<TaskListItem[]>([]); // 任务列表
|
||||
const [taskId, setTaskId] = useState<number>(0); // 任务
|
||||
const [actionColumnList, setActionColumnList] = useState<actionColumnItem[]>([]);
|
||||
const [taskLoading, setTaskLoading] = useState<boolean>(false);
|
||||
const [actionLoading, setActionLoading] = useState<boolean>(false);
|
||||
// 当前页码,默认为第 1 页
|
||||
const [pageNum, setPageNum] = useState<number>(1);
|
||||
// 每页显示数量,默认为 10 条
|
||||
const [pageSize, setPageSize] = useState<number>(10); // 每页显示 10 条
|
||||
const [total, setTotal] = useState<number>(0); // 查询任务总数
|
||||
const state = useRef({
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
// 回车处理
|
||||
const handleKeyDown = async (e) => {
|
||||
if ((e.metaKey || e.ctrlKey || e.shiftKey) && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode === 13) {
|
||||
e.preventDefault();
|
||||
await taskListSearch()
|
||||
} else if (e.key === "/") {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 页码变化时的回调函数
|
||||
* 当用户切换页码时触发,更新页码并重新获取数据
|
||||
* @param value - 新的页码值
|
||||
*/
|
||||
const pageIndexChange = async (value: number) => {
|
||||
// 更新 ref 中存储的页码值
|
||||
// 更新页码状态,触发组件重新渲染
|
||||
setPageNum(value);
|
||||
state.current.pageIndex = value;
|
||||
await taskListSearch();
|
||||
}
|
||||
|
||||
// 任务查询
|
||||
const taskListSearch = async () => {
|
||||
const param = {
|
||||
keyword: '',
|
||||
pageNum: state.current.pageIndex,
|
||||
pageSize: state.current.pageSize
|
||||
}
|
||||
setTaskLoading(true);
|
||||
const res = await service.post(`${zncmUrl}/action/cop-action-tasks`, param);
|
||||
setTaskLoading(false);
|
||||
console.log('任务搜索', res);
|
||||
const result = res.data;
|
||||
result.forEach((item: TaskListItem) => {
|
||||
item.progress = item.endCount / item.sumAll || 0; // 获取已完成和未完成的占比
|
||||
item.taskStatusData = taskStatusList[item.taskStatus] // 根据任务状态码获取相关信息
|
||||
})
|
||||
setTaskList(result || []); // 设置任务列表页
|
||||
const totalRes = await service.post(`${zncmUrl}/action/cop-action-tasks-count`, param); // 查询任务总数
|
||||
console.log('totalRes', totalRes)
|
||||
setTotal(totalRes.data || 0); // 设置总数
|
||||
if (result.length > 0) {
|
||||
setTaskId(result[0].id);
|
||||
await actionListSearch(result[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
// 行动查询
|
||||
const actionListSearch = async (taskId: number) => {
|
||||
const param = {
|
||||
taskId: taskId,
|
||||
}
|
||||
setActionLoading(true);
|
||||
const res = await service.get(`${zncmUrl}/action/cop-task-actions`, param);
|
||||
console.log('行动查询', res);
|
||||
setActionLoading(false);
|
||||
const result = res.data;
|
||||
setActionColumnList([
|
||||
{ columnName: '待分析', icon: '待CEH.svg', actionList: result.collect || [] },
|
||||
{ columnName: 'CEH中', icon: '进行中.svg', actionList: result.collect1 || [] },
|
||||
{ columnName: 'CEH完成', icon: '完成.svg', actionList: result.collect2 || [] },
|
||||
{ columnName: '已终止', icon: '已终止.svg', actionList: result.endDate || [] },
|
||||
]);
|
||||
}
|
||||
|
||||
const taskDataChange = async (taskId: number) => {
|
||||
setTaskId(taskId);
|
||||
await actionListSearch(taskId);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
taskListSearch();
|
||||
}, [])
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
<Row className="h-full flex flex-col">
|
||||
<Col span={2} className="h-full">
|
||||
<div className={`h-[calc(100vh-100px)] p-[10px] ${isDark ? 'bg-[rgba(3,38,80,0.6)]' : 'bg-white'} shadow-[2px_0px_6px_rgba(0,0,0,0.12)]`} >
|
||||
{/* <div className="flex justify-between">
|
||||
<span>筛选</span>
|
||||
<span className="flex items-center">
|
||||
<span>下发时间排序</span>
|
||||
</span>
|
||||
</div> */}
|
||||
<div className="relative flex-1 max-w-md">
|
||||
<Search className={`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 ${textMuted}`} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索任务名称"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
onKeyDown={(e) => handleKeyDown(e)}
|
||||
className={`w-full pl-10 pr-4 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-red-500/20 transition-colors ${inputBg} ${cardBorder} ${textPrimary} placeholder:${textMuted}`}
|
||||
/>
|
||||
</div>
|
||||
{/* 任务列表 */}
|
||||
<Loading loading={taskLoading}>
|
||||
<div className="h-[calc(100vh-200px)] overflow-y-auto pr-[10px]">
|
||||
{
|
||||
taskList.map((item: TaskListItem, index: number) => (
|
||||
<div key={index} className={`${isDark ? 'bg-[#0062d91a] border-[#55a6fe1a] shadow-[0_3px_4px_#8b8b8b0f] dark-theme' : 'bg-white border-[#f5f5f5] shadow-[2px_0px_6px_rgba(0,0,0,0.08)] task-item-active'} p-[10px] mt-[10px] mb-[10px] rounded-[4px] border ${taskId === item.id && 'task-active'} cursor-pointer`} onClick={() => taskDataChange(item.id)}>
|
||||
<div className="text-[var(--text-color)] text-[17px] mb-[5px] font-[500]">{item.taskName}</div>
|
||||
<div className="text-[#7f7f7f] mb-[5px]">{format(new Date(item.taskStartDate), 'yyyy-MM-dd HH:mm:ss')}</div>
|
||||
<div className="flex items-center mb-[8px]">
|
||||
<img src={`/icon/${item?.taskStatusData?.icon}`} alt="" />
|
||||
<span className="ml-[5px] leading-[16px]">{item?.taskStatusData?.label}</span>
|
||||
</div>
|
||||
<div className="pb-[10px] pt-[10px]">
|
||||
<div className="border-b border-[#e8e8e8]"></div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="h-[24px] item-active pl-[10px] pr-[10px] task-tab-color leading-[24px] rounded-[50px] bg-[var(--bg-color)]">
|
||||
完成{item.endCount}/{item.sumAll}
|
||||
</div>
|
||||
<div className="pl-[20px] flex-1">
|
||||
<Progress percentage={item.progress} label={false} color={item?.taskStatusData?.color} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</Loading>
|
||||
{/* 分页 */}
|
||||
<div>
|
||||
<Pagination
|
||||
total={total}
|
||||
size="small"
|
||||
theme="simple"
|
||||
current={pageNum}
|
||||
pageSize={pageSize}
|
||||
showPageSize={false}
|
||||
onCurrentChange={(page) => pageIndexChange(Number(page))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col span={10} className="h-full">
|
||||
<div className="h-full flex flex-col p-[0_10px]">
|
||||
<Loading loading={actionLoading}>
|
||||
<div className="flex grid grid-cols-4 gap-[10px] pl-[10px]">
|
||||
{
|
||||
actionColumnList.map((item: actionColumnItem, index: number) => (
|
||||
<ActionColumn key={index} icon={item.icon} columnIndex={index} columnName={item.columnName} actionCount={item.actionList.length} actionList={item.actionList} title={title} category={category} subCategory={subCategory} />
|
||||
))
|
||||
}
|
||||
{
|
||||
actionColumnList.length === 0 && <Empty/>
|
||||
}
|
||||
</div>
|
||||
</Loading>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { ActionListItem, TaskListItem, taskStatusList } from './TaskManagement';
|
||||
import { Bot, ChevronRight, Download, Edit, Eye, FileText, Layers, MoreHorizontal, Play, Search, User, Users, Workflow } from 'lucide-react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { format } from 'date-fns';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Col, Empty, Pagination, Progress, Row } from 'tdesign-react';
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
|
||||
interface ActionColumnProps {
|
||||
TaskType?: string;
|
||||
title: string;
|
||||
category: string;
|
||||
subCategory: string;
|
||||
icon: string;
|
||||
columnIndex: number;
|
||||
columnName: string;
|
||||
actionCount: number;
|
||||
actionList: ActionListItem[];
|
||||
}
|
||||
|
||||
const service = requestCrudService;
|
||||
const zncmUrl = import.meta.env.VITE_API_BASE_URL || '';
|
||||
export const ActionColumn: React.FC<ActionColumnProps> = ({ title, category, subCategory, icon, columnName, columnIndex, actionCount, actionList }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
// 主题颜色变量
|
||||
const cardBg = isDark ? 'bg-slate-800/30' : 'bg-white';
|
||||
const cardBorder = isDark ? 'border-blue-800/30' : 'border-red-100';
|
||||
const textPrimary = isDark ? 'text-white' : 'text-gray-900';
|
||||
const textSecondary = isDark ? 'text-slate-400' : 'text-gray-600';
|
||||
const textMuted = isDark ? 'text-slate-500' : 'text-gray-400';
|
||||
const inputBg = isDark ? 'bg-slate-900/50' : 'bg-white';
|
||||
const navigate = useNavigate();
|
||||
const [searchQuery, setSearchQuery] = useState<string>('');
|
||||
// 当前页码,默认为第 1 页
|
||||
const [pageNum, setPageNum] = useState<number>(1);
|
||||
// 每页显示数量,默认为 10 条
|
||||
const [pageSize, setPageSize] = useState<number>(10); // 每页显示 10 条
|
||||
const [total, setTotal] = useState<number>(0); // 查询任务总数
|
||||
const state = useRef({
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
/**
|
||||
* 页码变化时的回调函数
|
||||
* 当用户切换页码时触发,更新页码并重新获取数据
|
||||
* @param value - 新的页码值
|
||||
*/
|
||||
const pageIndexChange = async (value: number) => {
|
||||
// 更新 ref 中存储的页码值
|
||||
// 更新页码状态,触发组件重新渲染
|
||||
setPageNum(value);
|
||||
state.current.pageIndex = value;
|
||||
}
|
||||
|
||||
const actionRouterChange = (item: ActionListItem) => {
|
||||
if (item.actionStatus !== 0) {
|
||||
window.open(`https://ch1.b.uat.4.cn/web/#/action/item-aiceh/step-analysis-three?id=${item.id}`);
|
||||
} else {
|
||||
window.open(`https://ch1.b.uat.4.cn/web/#/action/item-aiceh/step-action-topic?id=${item.id}&isPassApply=false`);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`h-[calc(100vh-100px)] p-[10px] flex-1 ${isDark? 'dark-action-bg' : `bg-white action-bg${columnIndex} shadow-[2px_0px_6px_rgba(0,0,0,0.12)]`} rounded-[4px]`}>
|
||||
<div className="mb-[10px]">
|
||||
<div className="flex items-center mb-[20px]">
|
||||
<img src={`/icon/${icon}`} className="w-[24px] mr-[10px]" alt="" />
|
||||
<span className="text-[#222222] text-[18px] font-bold mr-[20px]">{columnName}</span>
|
||||
<span className="text-[#222222] text-[18px] font-bold mr-[20px]">{actionCount}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="h-[calc(100vh-200px)] overflow-y-auto pr-[10px]">
|
||||
{
|
||||
actionList.map((item: ActionListItem, index: number) => (
|
||||
<div key={index} className={`${isDark? 'dark-action-item' : 'bg-white border border-[#f5f5f5] shadow-[0_1px_16px_#0000000f] action-item'} rounded-md px-4 py-2.5 mb-[10px] hover:border-[var(--card-border)] cursor-pointer`} onClick={() => actionRouterChange(item)}>
|
||||
<div className="line-clamp-4 overflow-hidden mb-[10px]">
|
||||
{
|
||||
item.actionName
|
||||
}
|
||||
</div>
|
||||
<div className="flex items-center mb-[10px]">
|
||||
<span className={`${isDark? 'bg-[#0062d94d] text-[#aaceff]' :'bg-[#f5f5f5]'} leading-[16px] p-[5px_10px] rounded-[2px]`}>
|
||||
{item.level === 1 ? '主要行动' : '次要行动'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className={`${isDark? 'bg-[#0062d94d] text-[#aaceff]' :'bg-[#f5f5f5]'} leading-[16px] p-[5px_10px] rounded-[2px]`}>
|
||||
{item.deptName}
|
||||
</span>
|
||||
<span className="border border-[var(--color-main)] text-[var(--color-main)] cursor-pointer leading-[16px] ml-[10px] p-[5px_10px] rounded-[2px]">
|
||||
{
|
||||
item.actionStatus === 0 ? <span>XD签收</span> : <span>开始CEH</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
{
|
||||
actionList.length === 0 && <Empty image={
|
||||
<img
|
||||
src="/icon/empty-list.png"
|
||||
alt="empty"
|
||||
className="w-[135px]"
|
||||
/>
|
||||
} />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import "./css/iframe.css";
|
||||
|
||||
import { useTheme } from "@/contexts/ThemeContext";
|
||||
|
||||
const TYURL = import.meta.env.VITE_AIPI_B2ACTOR_URL || "";
|
||||
|
||||
const FanganTyPage: React.FC = () => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === "dark";
|
||||
const [iframeUrl, setIframeUrl] = useState("");
|
||||
useEffect(() => {
|
||||
initIframeUrl();
|
||||
}, []);
|
||||
const initIframeUrl = () => {
|
||||
const url = `${TYURL}/fromB/toPage?defaultPage=iframeFaty`;
|
||||
console.log({ iframeUrl: url });
|
||||
setIframeUrl(url);
|
||||
};
|
||||
return (
|
||||
<div className="iframe-container">
|
||||
<iframe src={iframeUrl} className="full-size-iframe"></iframe>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FanganTyPage;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { TaskListItem } from './TaskManagement';
|
||||
import { ChevronRight, FileText } from 'lucide-react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { TaskCard } from './TaskCard';
|
||||
import { Pagination } from 'tdesign-react';
|
||||
|
||||
interface KanbanColumnProps {
|
||||
title: string;
|
||||
count: number;
|
||||
color: string;
|
||||
tasks: TaskListItem[];
|
||||
taskType: string;
|
||||
TaskDataType?: string; // 区分来源类型
|
||||
pageIndexSearch: (taskType: string, pageIndex: number) => void;
|
||||
handleStartAnalysis: (task: TaskListItem) => void
|
||||
}
|
||||
|
||||
export const KanbanColumn: React.FC<KanbanColumnProps> = ({ title, count, color, tasks,taskType, TaskDataType = 'task' , pageIndexSearch, handleStartAnalysis }) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === 'dark';
|
||||
const textPrimary = isDark ? 'text-white' : 'text-gray-900';
|
||||
const textMuted = isDark ? 'text-slate-500' : 'text-gray-400';
|
||||
// 当前页码,默认为第 1 页
|
||||
const [pageNum, setPageNum] = useState<number>(1);
|
||||
// 每页显示数量,默认为 10 条
|
||||
const [pageSize, setPageSize] = useState<number>(10); // 每页显示 10 条
|
||||
/**
|
||||
* 页码变化时的回调函数
|
||||
* 当用户切换页码时触发,更新页码并重新获取数据
|
||||
* @param value - 新的页码值
|
||||
*/
|
||||
const pageIndexChange = async (value: number) => {
|
||||
// 更新 ref 中存储的页码值
|
||||
// 更新页码状态,触发组件重新渲染
|
||||
console.log('taskType', taskType)
|
||||
setPageNum(value);
|
||||
await pageIndexSearch(taskType, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每页显示数量变化时的回调函数
|
||||
* 当用户切换每页显示条数时触发,更新每页数量并重新获取数据
|
||||
* @param value - 新的每页显示数量
|
||||
*/
|
||||
const pageSizeChange = async (value: number) => {
|
||||
// 更新 ref 中存储的每页显示数量
|
||||
// 更新每页显示数量状态,触发组件重新渲染
|
||||
setPageSize(value);
|
||||
}
|
||||
return (
|
||||
<div className="flex flex-col min-h-0 flex-1">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className={`w-2 h-2 rounded-full ${color}`} />
|
||||
<h2 className={`font-semibold text-sm ${textPrimary}`}>{title}</h2>
|
||||
<span className={`px-2 py-0.5 rounded-full text-xs ${isDark ? 'bg-slate-700/50 text-slate-400' : 'bg-red-50 text-red-500'
|
||||
}`}>{count}</span>
|
||||
</div>
|
||||
{/* <button className={`p-1 rounded transition-colors ${isDark ? 'hover:bg-slate-700/50' : 'hover:bg-red-50'
|
||||
}`}>
|
||||
<ChevronRight className={`w-4 h-4 ${textMuted}`} />
|
||||
</button> */}
|
||||
<div>
|
||||
<Pagination
|
||||
total={count}
|
||||
size="small"
|
||||
theme="simple"
|
||||
current={pageNum}
|
||||
pageSize={pageSize}
|
||||
maxPageBtn={3}
|
||||
showPageSize={false}
|
||||
totalContent={false}
|
||||
onCurrentChange={(page) => pageIndexChange(Number(page))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 overflow-y-auto space-y-3 pr-1 scrollbar-thin">
|
||||
{tasks.length === 0 ? (
|
||||
<div className={`flex flex-col items-center justify-center py-8 ${textMuted}`}>
|
||||
<FileText className="w-8 h-8 mb-2 opacity-50" />
|
||||
<p className="text-sm">暂无任务</p>
|
||||
</div>
|
||||
) : (
|
||||
tasks.map(task => <TaskCard key={task.id} task={task} TaskType={TaskDataType} handleStartAnalysis={handleStartAnalysis}/>)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loaded 100 of 549 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user