|
|
@@ -6,6 +6,74 @@
|
|
|
|
|
|
## 开发与运行
|
|
|
|
|
|
+路由映射: /knowledgeChat 路径直接映射到 <Chat /> 组件
|
|
|
+
|
|
|
+URL参数处理
|
|
|
+1. showMenu=false
|
|
|
+处理位置:
|
|
|
+sidebar.tsx#361
|
|
|
+!location.search.includes('showMenu=false') &&
|
|
|
+作用: 控制侧边栏是否显示,showMenu=false 时隐藏侧边栏
|
|
|
+2. chatMode=LOCAL
|
|
|
+处理位置:
|
|
|
+chat.tsx
|
|
|
+ 主要在两个地方处理
|
|
|
+Chat组件初始化时:
|
|
|
+```
|
|
|
+const search = location.search;
|
|
|
+const params = new URLSearchParams(search);
|
|
|
+const chatMode = params.get('chatMode');
|
|
|
+
|
|
|
+if (chatMode) {
|
|
|
+ chatStore.setChatMode(chatMode as "ONLINE" | "LOCAL");
|
|
|
+}
|
|
|
+```
|
|
|
+作用: 控制聊天模式,chatMode=LOCAL 时使用本地大模型
|
|
|
+
|
|
|
+Chat组件内部:
|
|
|
+```
|
|
|
+const search = location.search;
|
|
|
+const params = new URLSearchParams(search);
|
|
|
+const chatMode = params.get('chatMode');
|
|
|
+
|
|
|
+if (chatMode) {
|
|
|
+ setSelectedFruit(chatMode as "ONLINE" | "LOCAL");
|
|
|
+ const appId = params.get('appId');
|
|
|
+ if (appId) {
|
|
|
+ setAppValue(appId);
|
|
|
+ globalStore.setSelectedAppId(appId);
|
|
|
+ chatStore.updateCurrentSession((session) => {
|
|
|
+ session.appId = appId;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ init(chatMode);
|
|
|
+}
|
|
|
+```
|
|
|
+作用: 初始化聊天模式和应用ID
|
|
|
+
|
|
|
+3. appId=2937075690977497088
|
|
|
+处理位置: 同上,在_Chat组件中处理
|
|
|
+作用:
|
|
|
+设置应用ID到全局状态 globalStore.setSelectedAppId(appId)
|
|
|
+更新当前会话的appId session.appId = appId
|
|
|
+用于获取应用列表和预设问题
|
|
|
+
|
|
|
+组件调用关系:
|
|
|
+```
|
|
|
+URL: /#/knowledgeChat?showMenu=false&chatMode=LOCAL&appId=xxx
|
|
|
+ ↓
|
|
|
+React Router 路由匹配
|
|
|
+ ↓
|
|
|
+home.tsx Screen组件 renderContent()
|
|
|
+ ↓
|
|
|
+<Route path='/knowledgeChat' element={<Chat />} />
|
|
|
+ ↓
|
|
|
+Chat组件 (chat.tsx#2305)
|
|
|
+ ↓
|
|
|
+_Chat组件 (chat.tsx#952)
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
### 安装依赖
|
|
|
```bash
|
|
|
npm ci
|