neo-cmp-cli 1.12.8 → 1.12.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -6
- package/dist/index2.js +1 -1
- package/dist/module/neoInitByCopy.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +4 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/asset-manage-template/README.md +154 -0
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/asset-manage-template/package.json +74 -0
- package/template/asset-manage-template/src/assets/img/chart.svg +1 -0
- package/template/asset-manage-template/src/components/README.md +3 -0
- package/template/asset-manage-template/src/components/assetManage__c/assetApi.ts +70 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetCreateModal.tsx +260 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetGrid.tsx +48 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetSidebar.tsx +74 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetToolbar.tsx +79 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/assetDisplay.tsx +72 -0
- package/template/asset-manage-template/src/components/assetManage__c/constants.ts +28 -0
- package/template/asset-manage-template/src/components/assetManage__c/index.tsx +258 -0
- package/template/asset-manage-template/src/components/assetManage__c/model.ts +75 -0
- package/template/asset-manage-template/src/components/assetManage__c/style.scss +425 -0
- package/template/asset-manage-template/src/components/assetManage__c/types.ts +60 -0
- package/template/asset-manage-template/src/components/bidList__c/cmps/BidCard.tsx +47 -0
- package/template/asset-manage-template/src/components/bidList__c/constants.ts +6 -0
- package/template/asset-manage-template/src/components/bidList__c/formatUtils.ts +14 -0
- package/template/asset-manage-template/src/components/bidList__c/index.tsx +194 -0
- package/template/asset-manage-template/src/components/bidList__c/model.ts +57 -0
- package/template/asset-manage-template/src/components/bidList__c/style.scss +179 -0
- package/template/asset-manage-template/src/components/bidList__c/types.ts +10 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/BidPackageHeader.tsx +140 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/PackageItemTable.tsx +148 -0
- package/template/asset-manage-template/src/components/bidPackage__c/index.tsx +394 -0
- package/template/asset-manage-template/src/components/bidPackage__c/mainTableColumns.tsx +57 -0
- package/template/asset-manage-template/src/components/bidPackage__c/model.ts +86 -0
- package/template/asset-manage-template/src/components/bidPackage__c/style.scss +256 -0
- package/template/asset-manage-template/src/components/bidPackage__c/types.ts +35 -0
- package/template/asset-manage-template/src/components/bidPackage__c/utils.ts +19 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/axiosFetcher.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/queryObjectData.ts +36 -0
- package/template/asset-manage-template/src/utils/url.ts +82 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/xobjects.ts +0 -0
- package/template/asset-manage-template/tsconfig.json +40 -0
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/package.json +5 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-custom-cmp-template/src/utils/queryObjectData.ts +36 -0
- package/template/neo-custom-cmp-template/tsconfig.json +1 -2
- package/template/neo-h5-cmps/neo.config.js +1 -6
- package/template/neo-h5-cmps/package.json +7 -4
- package/template/neo-h5-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-h5-cmps/tsconfig.json +3 -4
- package/template/neo-order-cmps/package.json +2 -2
- package/template/neo-order-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-web-cmps/@types/neo-ui-common.d.ts +36 -0
- package/template/neo-web-cmps/neo.config.js +53 -0
- package/template/{neo-bi-cmps → neo-web-cmps}/package.json +10 -7
- package/template/neo-web-cmps/src/assets/img/AIBtn.gif +0 -0
- package/template/neo-web-cmps/src/assets/img/aiLogo.png +0 -0
- package/template/neo-web-cmps/src/assets/img/card-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/contact-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/custom-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/data-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/detail.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/map.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/search.svg +1 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/index.tsx +72 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/style.scss +13 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/index.tsx +52 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/style.scss +13 -0
- package/template/neo-web-cmps/src/utils/axiosFetcher.ts +37 -0
- package/template/neo-web-cmps/src/utils/queryObjectData.ts +112 -0
- package/template/{develop/neo-custom-cmp-template → neo-web-cmps}/src/utils/xobjects.ts +28 -64
- package/template/{neo-bi-cmps → neo-web-cmps}/tsconfig.json +2 -3
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/develop/BI /351/241/271/347/233/256/345/210/206/346/236/220/346/212/245/345/221/212.md" +0 -562
- package/template/develop/ChatPage /347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216/346/226/207/346/241/243.md" +0 -507
- package/template/develop/EntityGrid Web /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -868
- package/template/develop/EntityList H5 /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -1386
- package/template/develop/GlobalSearch/347/273/204/344/273/266/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -866
- package/template/develop/Neo /344/270/255/345/217/257/347/224/250 amis /347/273/204/344/273/266.md" +0 -1490
- package/template/develop/cmpEventFunctions.ts +0 -257
- package/template/develop/cmpEvents.ts +0 -864
- package/template/develop/comTree/347/224/237/346/210/220/350/277/207/347/250/213/345/210/206/346/236/220.md +0 -469
- package/template/develop/commonModules.js +0 -55
- package/template/develop/components-table.md +0 -50
- package/template/develop/neo-custom-cmp-template/README.md +0 -48
- package/template/develop/neo-custom-cmp-template/docs/README.md +0 -13
- package/template/develop/neo-custom-cmp-template/neo.config.js +0 -121
- package/template/develop/neo-custom-cmp-template/package.json +0 -63
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/README.md +0 -65
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/index.tsx +0 -180
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +0 -50
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/style.scss +0 -260
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/README.md +0 -94
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/index.tsx +0 -252
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +0 -56
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/style.scss +0 -120
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/README.md +0 -115
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/index.tsx +0 -304
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +0 -87
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/style.scss +0 -127
- package/template/develop/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -29
- package/template/develop/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -39
- package/template/develop/neo-custom-cmp-template/tsconfig.json +0 -68
- package/template/develop/neo-ui-component-h5.md +0 -105
- package/template/develop/neo-ui-component-web-xregister.md +0 -31
- package/template/develop/neo-ui-component-web.md +0 -292
- package/template/develop/neoCmps.ts +0 -7508
- package/template/develop/neoGlobalSearchInput /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -497
- package/template/develop/pageSchema1.json +0 -744
- package/template/develop//344/272/213/344/273/266/345/212/250/344/275/234/344/277/235/345/255/230/346/265/201/347/250/213/345/210/206/346/236/220.md +0 -390
- package/template/develop//345/215/225/345/205/203/346/265/213/350/257/225/344/275/277/347/224/250/350/257/264/346/230/216.md +0 -1139
- package/template/develop//345/261/236/346/200/247/351/205/215/347/275/256/351/241/271/347/261/273/345/236/213/346/261/207/346/200/273.md +0 -558
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/src/components/targetNumber__c/README.md +0 -100
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +0 -253
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.scss +0 -76
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.tsx +0 -148
- package/template/neo-bi-cmps/src/components/targetNumber__c/index.tsx +0 -440
- package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +0 -128
- package/template/neo-bi-cmps/src/components/targetNumber__c/style.scss +0 -173
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/@types/neo-ui-common.d.ts +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/commitlint.config.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/css/base.css +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/scripts/app/bluebird.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/template.html +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/common.scss +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/AIBtn.gif +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/aiLogo.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/card-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/contact-form.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/custom-form.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/data-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/detail.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/map.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/search.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/table.svg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/README.md +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/commitlint.config.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/css/base.css +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/scripts/app/bluebird.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/template.html +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/common.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/table.svg +0 -0
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
# ChatPage 组件使用说明文档
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
`ChatPage` 是 neo-ai-copilot-fe-h5 项目中的核心聊天页面组件,用于在移动端 H5 环境中提供完整的 AI 智能体对话功能。该组件集成了智能体管理、历史会话管理、消息发送、录音功能等核心能力。
|
|
6
|
-
|
|
7
|
-
## 组件架构
|
|
8
|
-
|
|
9
|
-
### 文件结构
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
chatPage/
|
|
13
|
-
├── component.tsx # 主组件文件
|
|
14
|
-
├── store.tsx # MobX 状态管理
|
|
15
|
-
├── styled.tsx # 样式组件
|
|
16
|
-
├── style.scss # 样式文件
|
|
17
|
-
├── interface/
|
|
18
|
-
│ └── props.tsx # Props 类型定义
|
|
19
|
-
└── index.tsx # 组件注册入口
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### 组件层次结构
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
ChatPage (Class Component)
|
|
26
|
-
└── AppCenter (缓存管理)
|
|
27
|
-
└── CopilotKit (上下文提供)
|
|
28
|
-
└── ChatPageView (功能组件)
|
|
29
|
-
├── TitleBar (标题栏)
|
|
30
|
-
├── ChatBox (聊天框)
|
|
31
|
-
└── SlideMenu (侧边栏菜单)
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## 核心功能
|
|
35
|
-
|
|
36
|
-
### 1. 智能体管理
|
|
37
|
-
|
|
38
|
-
- **智能体列表加载**:自动获取可用的智能体列表
|
|
39
|
-
- **智能体切换**:支持在不同智能体间切换
|
|
40
|
-
- **智能体详情**:获取并缓存智能体的详细信息
|
|
41
|
-
- **智能体图标映射**:自动映射智能体图标和颜色
|
|
42
|
-
|
|
43
|
-
### 2. 会话管理
|
|
44
|
-
|
|
45
|
-
- **新对话创建**:创建新的对话会话
|
|
46
|
-
- **历史会话加载**:加载并显示历史对话记录
|
|
47
|
-
- **会话切换**:在不同历史会话间切换
|
|
48
|
-
- **会话状态同步**:与全局会话状态管理系统同步
|
|
49
|
-
|
|
50
|
-
### 3. 消息交互
|
|
51
|
-
|
|
52
|
-
- **消息发送**:支持文本、文件等多种消息类型
|
|
53
|
-
- **流式响应**:支持流式消息接收和显示
|
|
54
|
-
- **消息状态管理**:跟踪消息的发送和处理状态
|
|
55
|
-
|
|
56
|
-
### 4. 录音功能
|
|
57
|
-
|
|
58
|
-
- **录音按钮集成**:在标题栏集成录音按钮
|
|
59
|
-
- **录音状态检查**:检查是否有正在进行的录音
|
|
60
|
-
- **录音提示**:退出页面时提示录音状态
|
|
61
|
-
|
|
62
|
-
### 5. UI 功能
|
|
63
|
-
|
|
64
|
-
- **加载状态**:显示加载动画
|
|
65
|
-
- **错误处理**:显示网络错误提示
|
|
66
|
-
- **侧边栏菜单**:智能体和历史会话选择菜单
|
|
67
|
-
- **标题栏**:显示当前会话信息和操作按钮
|
|
68
|
-
|
|
69
|
-
## Props 接口
|
|
70
|
-
|
|
71
|
-
### IProps
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
interface IProps {
|
|
75
|
-
// 浮动配置(可选)
|
|
76
|
-
floatConfig?: {
|
|
77
|
-
onMinimize?: Function // 最小化回调
|
|
78
|
-
onFullScreen?: Function // 全屏回调
|
|
79
|
-
setExtWidth?: Function // 设置扩展宽度
|
|
80
|
-
isExpanded?: boolean // 是否展开
|
|
81
|
-
isFullWidth?: boolean // 是否全屏
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// 是否创建新对话
|
|
85
|
-
newChat?: boolean
|
|
86
|
-
|
|
87
|
-
// 初始化指令配置
|
|
88
|
-
instructionConfig?: {
|
|
89
|
-
query?: string // 初始查询内容
|
|
90
|
-
extend_params?: any // 扩展参数
|
|
91
|
-
agentApiKey?: string // 智能体 API Key
|
|
92
|
-
threadId?: string // 会话 ID
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Amis 上下文
|
|
96
|
-
context: any
|
|
97
|
-
|
|
98
|
-
// 渲染函数
|
|
99
|
-
render: (type: string, props: any) => React.ReactNode
|
|
100
|
-
|
|
101
|
-
// 文件路径(Amis 属性)
|
|
102
|
-
file: string
|
|
103
|
-
|
|
104
|
-
// 主题 API Key
|
|
105
|
-
topicApiKey: string
|
|
106
|
-
|
|
107
|
-
// 消息状态
|
|
108
|
-
messageStatus: Record<string, string>
|
|
109
|
-
|
|
110
|
-
// 更新消息状态
|
|
111
|
-
updateMessageStatus: (conversation_id: string) => void
|
|
112
|
-
|
|
113
|
-
// 设置智能体列表回调(可选)
|
|
114
|
-
setAgentList?: (agentList: any[]) => void
|
|
115
|
-
|
|
116
|
-
// 注册 API 回调(可选)
|
|
117
|
-
registerAPIs?: (apis: Record<string, Function>) => () => void
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## 使用示例
|
|
122
|
-
|
|
123
|
-
### 基础使用
|
|
124
|
-
|
|
125
|
-
```tsx
|
|
126
|
-
import ChatPage from '@/components/chatPage'
|
|
127
|
-
|
|
128
|
-
// 在 Amis 页面中使用
|
|
129
|
-
{
|
|
130
|
-
"type": "chatPage",
|
|
131
|
-
"newChat": false,
|
|
132
|
-
"instructionConfig": {
|
|
133
|
-
"agentApiKey": "your_agent_api_key",
|
|
134
|
-
"threadId": "123"
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### 创建新对话
|
|
140
|
-
|
|
141
|
-
```tsx
|
|
142
|
-
{
|
|
143
|
-
"type": "chatPage",
|
|
144
|
-
"newChat": true,
|
|
145
|
-
"instructionConfig": {
|
|
146
|
-
"agentApiKey": "your_agent_api_key",
|
|
147
|
-
"query": "你好,我想了解一下..."
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### 加载历史会话
|
|
153
|
-
|
|
154
|
-
```tsx
|
|
155
|
-
{
|
|
156
|
-
"type": "chatPage",
|
|
157
|
-
"newChat": false,
|
|
158
|
-
"instructionConfig": {
|
|
159
|
-
"threadId": "456"
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## 注册的 API
|
|
165
|
-
|
|
166
|
-
组件通过 `registerAPIs` 回调注册了以下 API,供外部调用:
|
|
167
|
-
|
|
168
|
-
### 1. createNewChat
|
|
169
|
-
|
|
170
|
-
创建新对话(向后兼容的旧 API)
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
createNewChat(initInstruction: string, agentApiKey?: string)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**参数:**
|
|
177
|
-
- `initInstruction`: 初始指令内容
|
|
178
|
-
- `agentApiKey`: 可选,智能体 API Key
|
|
179
|
-
|
|
180
|
-
### 2. getCurrentAgent
|
|
181
|
-
|
|
182
|
-
获取当前智能体信息
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
getCurrentAgent(): IAgentItem
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
**返回:** 当前智能体信息对象
|
|
189
|
-
|
|
190
|
-
### 3. getCurrentHistoryChat
|
|
191
|
-
|
|
192
|
-
获取当前历史会话信息
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
getCurrentHistoryChat(): IHistoryItem | null
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
**返回:** 当前历史会话信息对象或 null
|
|
199
|
-
|
|
200
|
-
### 4. newSession
|
|
201
|
-
|
|
202
|
-
创建新会话(新 API,异步)
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
newSession(agentApiKey?: string): Promise<void>
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**参数:**
|
|
209
|
-
- `agentApiKey`: 可选,智能体 API Key
|
|
210
|
-
|
|
211
|
-
**说明:** 异步函数,保证操作完成后才返回
|
|
212
|
-
|
|
213
|
-
### 5. switchToHistoryChat
|
|
214
|
-
|
|
215
|
-
切换到指定历史会话(新 API,异步)
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
switchToHistoryChat(threadId: number): Promise<void>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**参数:**
|
|
222
|
-
- `threadId`: 会话 ID
|
|
223
|
-
|
|
224
|
-
**说明:** 异步函数,切换失败会抛出错误
|
|
225
|
-
|
|
226
|
-
### 6. sendPrompt
|
|
227
|
-
|
|
228
|
-
发送消息(标准 API,异步)
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
sendPrompt(props: SendPromptProps): Promise<void>
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
**参数:**
|
|
235
|
-
```typescript
|
|
236
|
-
interface SendPromptProps {
|
|
237
|
-
sources: {
|
|
238
|
-
inputStr: string // 输入文本
|
|
239
|
-
files?: File[] // 附件文件
|
|
240
|
-
}
|
|
241
|
-
extendParams?: any // 扩展参数
|
|
242
|
-
meta: {
|
|
243
|
-
topicApiKey?: string // 主题 API Key
|
|
244
|
-
usage?: any // 使用情况
|
|
245
|
-
}
|
|
246
|
-
options?: {
|
|
247
|
-
persistence?: boolean // 是否持久化
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
**说明:**
|
|
253
|
-
- 支持主题 API Key 的临时设置和恢复
|
|
254
|
-
- 异步函数,确保消息发送完成
|
|
255
|
-
|
|
256
|
-
## 状态管理
|
|
257
|
-
|
|
258
|
-
组件使用 MobX 进行状态管理,通过 `ChatPageStore` 类管理以下状态:
|
|
259
|
-
|
|
260
|
-
### 状态属性
|
|
261
|
-
|
|
262
|
-
- `agentDetailMap`: 智能体详情缓存
|
|
263
|
-
- `agentDetailInfo`: 当前选中的智能体详情
|
|
264
|
-
- `agentInfo`: 当前选中的智能体信息
|
|
265
|
-
- `historyChatInfo`: 历史聊天信息
|
|
266
|
-
- `agentList`: 智能体列表
|
|
267
|
-
- `loading`: 加载状态
|
|
268
|
-
- `error`: 错误状态
|
|
269
|
-
- `instructionConfig`: 初始化指令配置
|
|
270
|
-
- `showNewChat`: 是否显示新建对话按钮
|
|
271
|
-
- `loaded`: 是否加载完成
|
|
272
|
-
|
|
273
|
-
### 计算属性
|
|
274
|
-
|
|
275
|
-
- `agentInited`: 智能体是否初始化完成
|
|
276
|
-
- `historyChatData`: 历史聊天数据(转换为普通对象)
|
|
277
|
-
- `agentDetailData`: 智能体详情数据(转换为普通对象)
|
|
278
|
-
- `titleLabel`: 标题标签文本
|
|
279
|
-
- `historyChatId`: 历史聊天 ID
|
|
280
|
-
- `agentId`: 智能体 ID
|
|
281
|
-
- `agentIcon`: 智能体图标
|
|
282
|
-
|
|
283
|
-
### 主要方法
|
|
284
|
-
|
|
285
|
-
- `getChatPage(newChat?, instructionConfig?)`: 获取聊天页面数据
|
|
286
|
-
- `createNewChat(instructionConfig, agentApiKey?)`: 创建新对话
|
|
287
|
-
- `switchToHistoryChat(threadId)`: 切换到历史会话
|
|
288
|
-
- `setAgentInfo(agentInfo)`: 设置智能体信息
|
|
289
|
-
- `setHistoryChatInfo(agentInfo, historyChatInfo)`: 设置历史聊天信息
|
|
290
|
-
- `updateShowNewChatStatus(show)`: 更新显示新建对话按钮状态
|
|
291
|
-
- `updateHistoryName(name)`: 更新历史会话名称
|
|
292
|
-
|
|
293
|
-
## 生命周期
|
|
294
|
-
|
|
295
|
-
### 初始化流程
|
|
296
|
-
|
|
297
|
-
1. **组件挂载**
|
|
298
|
-
- 注册到 Amis ScopedContext
|
|
299
|
-
- 初始化 ChatPageStore
|
|
300
|
-
- 设置 AppCenter 缓存
|
|
301
|
-
|
|
302
|
-
2. **数据加载**
|
|
303
|
-
- 调用 `getChatPage()` 获取初始数据
|
|
304
|
-
- 并行请求智能体列表和历史会话
|
|
305
|
-
- 根据配置选择默认智能体或历史会话
|
|
306
|
-
|
|
307
|
-
3. **API 注册**
|
|
308
|
-
- 注册 AudioAgentController API
|
|
309
|
-
- 注册 CopilotKit API
|
|
310
|
-
- 设置状态栏样式
|
|
311
|
-
|
|
312
|
-
4. **监听更新**
|
|
313
|
-
- 监听智能体列表变化
|
|
314
|
-
- 监听历史会话变化
|
|
315
|
-
- 监听共享文件引擎初始化
|
|
316
|
-
|
|
317
|
-
### 清理流程
|
|
318
|
-
|
|
319
|
-
1. **组件卸载**
|
|
320
|
-
- 取消注册 ScopedContext
|
|
321
|
-
- 注销所有注册的 API
|
|
322
|
-
- 恢复状态栏样式
|
|
323
|
-
|
|
324
|
-
## 依赖关系
|
|
325
|
-
|
|
326
|
-
### 外部依赖
|
|
327
|
-
|
|
328
|
-
- `react`: React 框架
|
|
329
|
-
- `amis`: Amis 低代码框架
|
|
330
|
-
- `mobx` / `mobx-react`: 状态管理
|
|
331
|
-
- `antd-mobile`: 移动端 UI 组件库
|
|
332
|
-
- `dsbridge`: 原生桥接库
|
|
333
|
-
- `lodash`: 工具函数库
|
|
334
|
-
|
|
335
|
-
### 内部依赖
|
|
336
|
-
|
|
337
|
-
- `neo-ai-common`: 公共库(组件、Hooks、工具函数)
|
|
338
|
-
- `neo-ui-component-h5`: H5 UI 组件库
|
|
339
|
-
- `@/hooks`: 项目 Hooks
|
|
340
|
-
- `@/controllers`: 控制器
|
|
341
|
-
- `@/baseElement`: 基础元素组件
|
|
342
|
-
|
|
343
|
-
### 关键依赖组件
|
|
344
|
-
|
|
345
|
-
- `CopilotKit`: 提供 Copilot 上下文
|
|
346
|
-
- `AppCenter`: 提供缓存管理
|
|
347
|
-
- `ChatBox`: 聊天框组件
|
|
348
|
-
- `AgentsMenu`: 智能体菜单组件
|
|
349
|
-
- `AudioRecordButton`: 录音按钮组件
|
|
350
|
-
|
|
351
|
-
## 特殊功能说明
|
|
352
|
-
|
|
353
|
-
### 1. 录音功能集成
|
|
354
|
-
|
|
355
|
-
组件集成了录音功能,通过 `AudioAgentController` 管理:
|
|
356
|
-
|
|
357
|
-
- 检查录音状态:在退出页面时检查是否有正在进行的录音
|
|
358
|
-
- 录音提示:如果有录音,显示提示框
|
|
359
|
-
- 录音 API:注册录音相关的 API 供外部调用
|
|
360
|
-
|
|
361
|
-
### 2. 共享文件引擎
|
|
362
|
-
|
|
363
|
-
组件支持通过共享文件选择智能体:
|
|
364
|
-
|
|
365
|
-
- 监听 `selectAgentApiKeyBySharedFiles` 变化
|
|
366
|
-
- 自动切换到文件中选择的智能体
|
|
367
|
-
- 创建新对话时使用选中的智能体
|
|
368
|
-
|
|
369
|
-
### 3. 会话状态同步
|
|
370
|
-
|
|
371
|
-
组件与全局会话状态管理系统集成:
|
|
372
|
-
|
|
373
|
-
- 使用 `useCopilotMessageStatus` 获取会话状态
|
|
374
|
-
- 使用 `useCopilotKit` 更新会话 ID
|
|
375
|
-
- 自动同步会话状态变化
|
|
376
|
-
|
|
377
|
-
### 4. 特殊智能体支持
|
|
378
|
-
|
|
379
|
-
组件对特定智能体有特殊处理:
|
|
380
|
-
|
|
381
|
-
- `analyst_agent`: 使用 `chatBI` 组件渲染
|
|
382
|
-
- 其他智能体:使用 `chatBox` 组件渲染
|
|
383
|
-
|
|
384
|
-
## 样式定制
|
|
385
|
-
|
|
386
|
-
组件使用 `styled-components` 和 SCSS 进行样式管理:
|
|
387
|
-
|
|
388
|
-
- `PageContainer`: 页面容器样式
|
|
389
|
-
- `ChatContainer`: 聊天容器样式
|
|
390
|
-
- `.slide-menu-container`: 侧边栏菜单样式
|
|
391
|
-
- `.loading-container`: 加载状态样式
|
|
392
|
-
- `.error-container`: 错误状态样式
|
|
393
|
-
|
|
394
|
-
可以通过修改 `styled.tsx` 和 `style.scss` 文件进行样式定制。
|
|
395
|
-
|
|
396
|
-
## 错误处理
|
|
397
|
-
|
|
398
|
-
组件包含完善的错误处理机制:
|
|
399
|
-
|
|
400
|
-
1. **网络错误**
|
|
401
|
-
- 显示错误图标和提示信息
|
|
402
|
-
- 提供重新加载按钮
|
|
403
|
-
- 提供返回首页按钮
|
|
404
|
-
|
|
405
|
-
2. **加载错误**
|
|
406
|
-
- 显示加载失败状态
|
|
407
|
-
- 记录错误信息到控制台
|
|
408
|
-
|
|
409
|
-
3. **API 调用错误**
|
|
410
|
-
- 捕获并记录错误
|
|
411
|
-
- 不影响其他功能正常运行
|
|
412
|
-
|
|
413
|
-
## 性能优化
|
|
414
|
-
|
|
415
|
-
1. **缓存管理**
|
|
416
|
-
- 使用 AppCenter 缓存组件实例
|
|
417
|
-
- 缓存智能体详情信息
|
|
418
|
-
|
|
419
|
-
2. **懒加载**
|
|
420
|
-
- 组件通过动态导入注册
|
|
421
|
-
- 按需加载子组件
|
|
422
|
-
|
|
423
|
-
3. **状态优化**
|
|
424
|
-
- 使用 MobX 进行响应式状态管理
|
|
425
|
-
- 避免不必要的重新渲染
|
|
426
|
-
|
|
427
|
-
## 注意事项
|
|
428
|
-
|
|
429
|
-
1. **必须提供 Props**
|
|
430
|
-
- `context`: Amis 上下文(必需)
|
|
431
|
-
- `render`: 渲染函数(必需)
|
|
432
|
-
- `fetcher`: 数据获取函数(通过 env.fetcher 传递)
|
|
433
|
-
|
|
434
|
-
2. **API 调用时机**
|
|
435
|
-
- 所有注册的 API 都是异步的
|
|
436
|
-
- 需要等待初始化完成后再调用
|
|
437
|
-
- 使用 Promise 处理异步操作
|
|
438
|
-
|
|
439
|
-
3. **状态同步**
|
|
440
|
-
- 组件状态与全局状态需要同步
|
|
441
|
-
- 使用 Hooks 进行状态管理
|
|
442
|
-
- 注意避免状态冲突
|
|
443
|
-
|
|
444
|
-
4. **录音功能**
|
|
445
|
-
- 退出页面时需要检查录音状态
|
|
446
|
-
- 录音过程中退出会显示提示
|
|
447
|
-
- 录音功能依赖 AudioAgentController
|
|
448
|
-
|
|
449
|
-
## 常见问题
|
|
450
|
-
|
|
451
|
-
### Q1: 如何切换智能体?
|
|
452
|
-
|
|
453
|
-
A: 可以通过以下方式切换智能体:
|
|
454
|
-
- 点击标题栏左侧的智能体列表图标
|
|
455
|
-
- 调用 `newSession(agentApiKey)` API
|
|
456
|
-
- 通过共享文件选择智能体
|
|
457
|
-
|
|
458
|
-
### Q2: 如何创建新对话?
|
|
459
|
-
|
|
460
|
-
A: 可以通过以下方式创建新对话:
|
|
461
|
-
- 点击标题栏的新建对话按钮
|
|
462
|
-
- 调用 `createNewChat()` 或 `newSession()` API
|
|
463
|
-
- 设置 `newChat` prop 为 true
|
|
464
|
-
|
|
465
|
-
### Q3: 如何发送消息?
|
|
466
|
-
|
|
467
|
-
A: 可以通过以下方式发送消息:
|
|
468
|
-
- 在聊天框中输入并发送
|
|
469
|
-
- 调用 `sendPrompt()` API
|
|
470
|
-
- 通过 AudioAgentController 发送录音消息
|
|
471
|
-
|
|
472
|
-
### Q4: 如何获取当前会话信息?
|
|
473
|
-
|
|
474
|
-
A: 可以通过以下 API 获取:
|
|
475
|
-
- `getCurrentAgent()`: 获取当前智能体
|
|
476
|
-
- `getCurrentHistoryChat()`: 获取当前历史会话
|
|
477
|
-
|
|
478
|
-
### Q5: 组件加载失败怎么办?
|
|
479
|
-
|
|
480
|
-
A: 组件会显示错误页面,提供以下选项:
|
|
481
|
-
- 点击"重新加载"按钮重试
|
|
482
|
-
- 点击"返回首页"按钮返回
|
|
483
|
-
- 检查网络连接和 API 配置
|
|
484
|
-
|
|
485
|
-
## 更新日志
|
|
486
|
-
|
|
487
|
-
### 版本历史
|
|
488
|
-
|
|
489
|
-
- **最新版本**: 支持完整的智能体对话功能
|
|
490
|
-
- **主要特性**:
|
|
491
|
-
- 智能体管理和切换
|
|
492
|
-
- 历史会话管理
|
|
493
|
-
- 录音功能集成
|
|
494
|
-
- 会话状态同步
|
|
495
|
-
- API 注册机制
|
|
496
|
-
|
|
497
|
-
## 相关文档
|
|
498
|
-
|
|
499
|
-
- [ChatPageStore 文档](./store.tsx)
|
|
500
|
-
- [Props 接口文档](./interface/props.tsx)
|
|
501
|
-
- [AgentsMenu 组件文档](../AgentsMenu/README.md)
|
|
502
|
-
- [ChatBox 组件文档](../ChatBox/README.md)
|
|
503
|
-
|
|
504
|
-
## 联系方式
|
|
505
|
-
|
|
506
|
-
如有问题或建议,请联系开发团队。
|
|
507
|
-
|