左侧菜单配置
左侧菜单(NavigationRail)是场景 UI 的核心导航区域,用户通过点击图标切换不同的功能面板。
工作原理
sidebarItems 配置 → NavigationRail 渲染图标 → 用户点击 → 侧边栏显示对应面板1
- 场景激活时,客户端读取
ui.sidebarItems渲染左侧菜单图标 - 用户点击图标,客户端设置
activeSidePanel为该菜单项的id - 侧边栏根据
id查找面板组件并渲染
声明式场景菜单
在 scenario.json 的 ui.sidebarItems 中配置,仅支持内置面板:
json
{
"ui": {
"layout": "chat-centric",
"sidebarItems": [
{
"id": "explorer",
"icon": "Files",
"label": "Workspace",
"labelZh": "工作区",
"component": "ExplorerView",
"position": 0
},
{
"id": "knowledge",
"icon": "BookOpen",
"label": "Knowledge",
"labelZh": "知识库",
"component": "KnowledgeView",
"position": 1,
"wideMode": true
},
{
"id": "tasks",
"icon": "CheckSquare",
"label": "Tasks",
"labelZh": "任务",
"component": "TaskWorkspace",
"position": 2,
"wideMode": true
},
{
"id": "projects",
"icon": "FolderKanban",
"label": "Projects",
"labelZh": "项目",
"component": "ProjectsView",
"position": 3,
"wideMode": true
},
{
"id": "automation",
"icon": "Zap",
"label": "Automation",
"labelZh": "自动化",
"component": "AutomationView",
"position": 4,
"wideMode": true
}
]
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
宽屏模式 (wideMode)
wideMode 是 SidebarItem 的可选字段,当设为 true 时,该菜单项对应的面板将占据主内容区域(而非侧边栏),同时侧边栏自动收起。
使用场景
- 设置面板:场景专属设置需要一个宽大的操作区域,不适合在狭窄侧边栏中展示
- 知识库:需要全屏展示的复杂面板
- 任务/项目/自动化:生产力面板内容密集(看板、表格、配置表单),需要宽屏空间
- 仪表盘:数据密集的统计面板
配置示例:场景专属设置
第一步:声明菜单项 + wideMode
typescript
getPlugin() {
return {
ui: {
sidebarItems: [
// ... 其他侧边栏项
{
id: 'settings',
icon: 'Settings',
label: 'Settings',
labelZh: '场景设置',
component: 'MySettingsView',
position: 8,
wideMode: true, // 宽屏模式
},
],
},
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
第二步:创建设置视图组件
tsx
// components/settings/MySettingsView.tsx
import { useCallback } from 'react'
import { useStore } from '@store'
import { MySettingsDialog } from './MySettingsDialog'
export default function MySettingsView() {
const closePanel = useCallback(() => {
// 关闭设置时回到文件管理器
useStore.getState().setActiveSidePanel('explorer')
}, [])
return <MySettingsDialog embedded onClose={closePanel} />
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
第三步:创建设置对话框组件
tsx
// components/settings/MySettingsDialog.tsx
export function MySettingsDialog({
embedded = false,
onClose,
}: {
embedded?: boolean
onClose?: () => void
}) {
const content = (
<div className={`flex h-full ${embedded ? '' : 'max-h-[800px]'}`}>
{/* 左侧导航 */}
<div className="w-56 bg-surface/30 backdrop-blur-xl pt-8 pb-6">
{/* 标签页导航 */}
</div>
{/* 右侧内容 */}
<div className="flex-1 overflow-auto">
{/* 设置表单 */}
</div>
</div>
)
if (embedded) {
return content // wideMode 下直接渲染,无弹窗遮罩
}
return (
<OverlayDialog onClose={onClose}>
{content}
</OverlayDialog>
)
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
关键点:
embedded模式下移除弹窗遮罩,onClose回调切换侧边栏面板回到 explorer。
工作原理
用户点击 wideMode 菜单项
→ 侧边栏收起 (sidebar hidden)
→ 面板组件渲染到 FullPageSlot(主内容区)
→ 用户点击关闭按钮 → setActiveSidePanel('explorer')
→ 侧边栏恢复,面板回到 explorer1
2
3
4
5
2
3
4
5
内置面板组件
内置面板是客户端预置的公共组件,声明式和编程式场景均可直接通过 component 字段引用,无需自行实现。
基础面板
| component 值 | 说明 | 推荐布局 |
|---|---|---|
ExplorerView | 文件浏览器(工作区文件树) | 侧边栏 |
SearchView | 全局搜索 | 侧边栏 |
GitView | Git 源码管理 | 侧边栏 |
ProblemsView | 问题诊断 | 侧边栏 |
OutlineView | 符号大纲 | 侧边栏 |
ShellView | Shell 终端 | 侧边栏 |
KnowledgeView | 知识库(文档/资料管理) | wideMode |
NotesView | 笔记 | 侧边栏 |
BookmarksView | 书签 | 侧边栏 |
PromptsView | 提示词库 | 侧边栏 |
生产力面板(公共可用)
以下三个面板构成完整的「任务 → 项目 → 自动化」生产力套件,数据通过后端 API 统一存储,所有场景共享同一份数据,可直接复用:
| component 值 | 说明 | 推荐布局 | 图标 |
|---|---|---|---|
TaskWorkspace | 任务工作台(看板/列表双视图、子任务、拖拽排序、AI 接力) | wideMode | CheckSquare |
ProjectsView | 项目管理(概览/任务/设置多 Tab、模板创建、统计仪表) | wideMode | FolderKanban |
AutomationView | 自动化规则引擎(触发器+动作、模板库、运行历史) | wideMode | Zap |
📖 这三个面板的详细功能、数据模型和接入方式见 公共可用页面。
在场景中接入生产力面板
只需在 sidebarItems 中声明即可,无需编写任何组件代码:
typescript
sidebarItems: [
{ id: 'explorer', icon: 'Files', label: 'Workspace', labelZh: '工作区', component: 'ExplorerView', position: 0 },
{ id: 'knowledge', icon: 'BookOpen', label: 'Knowledge', labelZh: '知识库', component: 'KnowledgeView', position: 1, wideMode: true },
{ id: 'tasks', icon: 'CheckSquare', label: 'Tasks', labelZh: '任务', component: 'TaskWorkspace', position: 2, wideMode: true },
{ id: 'projects', icon: 'FolderKanban', label: 'Projects', labelZh: '项目', component: 'ProjectsView', position: 3, wideMode: true },
{ id: 'automation', icon: 'Zap', label: 'Automation', labelZh: '自动化', component: 'AutomationView', position: 4, wideMode: true },
]1
2
3
4
5
6
7
2
3
4
5
6
7
注意:这三个面板均需配合
wideMode: true使用,它们会占据主内容区域以提供足够的操作空间。
编程式场景菜单
编程式场景支持自定义面板组件,分两步:
第一步:声明菜单项
在 getPlugin() 的 ui.sidebarItems 中声明:
typescript
getPlugin() {
return {
ui: {
sidebarItems: [
// 自定义面板:component 对应 getComponents() 返回的 key
{
id: 'tasks',
icon: 'CheckSquare',
label: 'Tasks',
labelZh: '任务',
component: 'TaskListPanel',
position: 0,
},
{
id: 'stats',
icon: 'BarChart3',
label: 'Stats',
labelZh: '统计',
component: 'StatsPanel',
position: 1,
},
// 内置面板:直接引用内置组件名
{
id: 'explorer',
icon: 'Files',
label: 'Workspace',
labelZh: '工作区',
component: 'ExplorerView',
position: 2,
},
{
id: 'knowledge',
icon: 'BookOpen',
label: 'Knowledge',
labelZh: '知识库',
component: 'KnowledgeView',
position: 3,
},
],
defaultSidePanel: 'tasks',
},
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
第二步:注册自定义组件
在 getComponents() 中注册:
typescript
import { TaskListPanel } from './components/TaskListPanel.js'
import { StatsPanel } from './components/StatsPanel.js'
getComponents() {
return {
TaskListPanel,
StatsPanel,
}
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
关键:
sidebarItems中的component值必须与getComponents()返回的 key 一致。
字段说明
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 菜单项唯一标识,同时作为面板 ID |
icon | string | 是 | 图标名称,使用 lucide-react 图标名 |
label | string | 是 | 英文标签 |
labelZh | string | 是 | 中文标签 |
component | string | 是 | 面板组件名 |
position | number | 否 | 排序位置,从小到大 |
wideMode | boolean | 否 | 宽屏模式下是否作为主面板显示 |
常用图标参考
| 图标名 | 适用场景 |
|---|---|
Files | 文件/工作区 |
Search | 搜索 |
GitBranch | Git 管理 |
BookOpen | 知识库 |
Terminal | 终端 |
CheckSquare | 任务 |
FolderKanban | 项目管理 |
Zap | 自动化/快速操作 |
BarChart3 | 统计/图表 |
Database | 数据源 |
Settings | 设置 |
Map | 地图/行程 |
Wallet | 预算/财务 |
Stethoscope | 诊断 |
Brain | AI/深度思考 |
FolderTree | 目录树 |
ListTree | 大纲 |
AlertCircle | 问题/告警 |
Workflow | 工作流 |
ClipboardList | 清单/待办 |
完整图标列表参考 lucide.dev
布局与菜单的关系
不同 layout 值对左侧菜单的显示策略不同:
| 布局 | 菜单显示 | 说明 |
|---|---|---|
chat-centric | 有 sidebarItems 时显示 | 无菜单项时隐藏侧边栏 |
editor-centric | 始终显示 | 左侧菜单 + 中间编辑器 + 右侧聊天 |
dashboard-centric | 始终显示 | 左侧菜单 + 中间仪表盘 + 右侧聊天 |
analytics-centric | 始终显示 | 左侧菜单 + 中间分析面板 + 右侧聊天 |
canvas-centric | 始终显示 | 左侧菜单 + 中间画布 + 右侧聊天 |
minimal | 不显示 | 仅聊天界面 |
focus-centric | 不显示 | 编辑器 + 聊天 |
research-centric | 有 sidebarItems 时显示 | 编辑器 + 聊天 + 可选菜单 |

