Files
wecom_it_smart_desk/docs/02-技术文档/技术架构/sequence-diagram.mermaid
T
Simon facc04aa65 chore: docs 结构整改 + compose 双目录对齐(合并重建提交)
本提交为 .git 对象库损坏后的重建提交,内容等价于原先三个本地提交
(5e2fd4c2 / 57a53c98 / 5d7e1873)的累积结果,未做任何额外改动。

一、docs 结构整改(整改 #14)
根因:重构时新结构为 untracked 文件,执行 git stash(未带 -u)未纳入,
随后 git reset 拉回 HEAD 旧 tracked 树,导致旧树复活、新旧两棵目录
树并存于 docs/,共 791 文件、双分类体系冲突。

修复动作:
- b2 同名异主题文件改名迁移保全 9 个
- C 类 39 个孤立文件按主题正确归类
- A/B1 类 222 个重复文件删除(新结构已有内容副本)
- 9 个旧独有空目录删除
- 270 处内部引用按 verified 映射改写
- 整改记录 #14 登记于 04-运维文档/部署运维

结果:docs 791 → 569 文件,顶层仅规范 8 类 + 治理文件,单树恢复。
残留:约 20 处指向从未存在文件的陈旧死链,归入独立文档卫生任务。

二、compose 双目录对齐(消除踩坑 A)
- docker-compose.yml:nginx 前端挂载全部由根目录 frontend-*/dist
  改为 src/frontend-*/dist(h5 / agent / admin / terminal)
- docker-compose.dev.yml:dev 服务 build context 与卷同步改 src/
- 效果:本地 docker compose up 不再把根目录 stale dist 挂回,
  与线上一致,分叉隐患消除(已 docker compose config 校验通过)

防复发铁律:
- 重构须提交;仓库修复须 git stash -u 或先 commit
- 新结构须 git add 并提交,避免再次 untracked 复活
- H5 改动只动 src/frontend-h5/,禁改根目录遗留 frontend-*/
2026-08-07 22:31:32 +08:00

82 lines
3.9 KiB
Plaintext

sequenceDiagram
participant U as 坐席用户
participant UI as UserInfoBar.vue
participant CA as ChatArea.vue
participant Store as ConversationStore
participant API as message.ts API
participant BE as Backend API
participant DB as Database
Note over U,DB: ========== 阶段1:打开历史模式 ==========
U->>UI: 点击"历史会话"开关按钮
UI->>CA: $emit('toggle-history')
CA->>Store: enableHistoryMode()
Store->>Store: historyMode = true, historyLoading = true
Store->>API: getHistoryMessages(employeeId, {limit:50, current_conversation_id})
API->>BE: GET /api/employees/{employee_id}/history-messages?limit=50
BE->>DB: SELECT conversations WHERE employee_id=?
DB-->>BE: 会话ID列表 [conv1, conv2, conv3...]
BE->>DB: SELECT messages WHERE conversation_id IN (...) ORDER BY created_at DESC LIMIT 51
DB-->>BE: 消息列表 (50条 + 1条判断has_more)
BE->>DB: 对每个会话查首条employee消息, 取前20字
DB-->>BE: conversation_summaries {conv1:"摘要1", conv2:"摘要2"...}
BE-->>API: {items:[...], has_more:true, conversation_summaries:{...}}
API-->>Store: HistoryMessageListData
Store->>Store: historyMessages = items.reverse() (ASC排序)
Store->>Store: historyHasMore = has_more
Store->>Store: historyCursor = historyMessages[0].id
Store->>Store: historyConversationSummaries = conversation_summaries
Store->>Store: historyLoading = false
Store-->>CA: displayMessages 响应更新 (返回historyMessages)
CA->>CA: 渲染消息列表 + 插入ConversationSeparator
CA->>CA: 隐藏 ReplyBox + ReplySuggestArea (只读模式)
CA-->>U: 显示合并历史时间线
Note over U,DB: ========== 阶段2:向上滚动加载更多 ==========
U->>CA: 向上滚动到顶部
CA->>Store: loadMoreHistory()
Store->>Store: historyLoading = true
Store->>API: getHistoryMessages(employeeId, {limit:50, before:historyCursor})
API->>BE: GET /api/employees/{employee_id}/history-messages?limit=50&before={msgId}
BE->>DB: 获取before消息的created_at
BE->>DB: SELECT messages WHERE conv IN (...) AND created_at < before_time ORDER BY DESC LIMIT 51
DB-->>BE: 更旧的消息列表
BE->>DB: 对新涉及的会话查首条employee消息摘要
DB-->>BE: 补充 conversation_summaries
BE-->>API: {items:[...], has_more:false, conversation_summaries:{...}}
API-->>Store: HistoryMessageListData
Store->>Store: historyMessages = newItems.reverse() + historyMessages (前插)
Store->>Store: historyCursor = historyMessages[0].id (更新游标)
Store->>Store: historyHasMore = has_more
Store->>Store: merge conversation_summaries
Store->>Store: historyLoading = false
Store-->>CA: displayMessages 更新
CA-->>U: 显示更多历史消息 + 新分隔条
Note over U,DB: ========== 阶段3:关闭历史模式 ==========
U->>UI: 再次点击"历史会话"开关
UI->>CA: $emit('toggle-history')
CA->>Store: disableHistoryMode()
Store->>Store: historyMode = false
Store->>Store: 清空 historyMessages, historyCursor, historyConversationSummaries
Store-->>CA: displayMessages 返回 messages (正常数据源)
CA->>CA: 恢复 ReplyBox + ReplySuggestArea
CA-->>U: 显示当前会话正常消息
Note over U,DB: ========== 阶段4:切换会话自动重置 ==========
U->>CA: 点击左栏其他会话
CA->>Store: selectConversation(newConvId)
Store->>Store: resetHistoryState() — historyMode=false, 清空历史状态
Store->>Store: currentConversationId = newConvId
Store->>API: getMessages(newConvId, {limit:50})
API->>BE: GET /api/conversations/{newConvId}/messages?limit=50
BE-->>API: 正常消息列表
API-->>Store: MessageListData
Store->>Store: messages = data.items
Store-->>CA: displayMessages 返回 messages
CA-->>U: 显示新会话消息 (历史模式已关闭)