Skip to content

Commit e1537aa

Browse files
committed
添加Mermaid支持,为websocket流程绘制时序图
1 parent 1bfeb75 commit e1537aa

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

docs/.vitepress/config.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { defineConfig } from "vitepress";
1+
// import { defineConfig } from "vitepress";
2+
import { withMermaid } from "vitepress-plugin-mermaid";
23
import { Chapters, getChapterItems } from "./theme/constrants/route";
34
import autoH1 from "./plugins/autoH1";
45

56
// 限制sidebar最多深入两层章节
67
const sidebarItems = getChapterItems(1, 2);
78

89
// https://vitepress.dev/reference/site-config
9-
export default defineConfig({
10+
export default withMermaid({
1011
lang: "zh",
1112
title: "灵矽文档中心",
1213
description: "A 灵矽 Documentation Project",

docs/xrobot/platform/websocket.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@ WebSocket 协议的主要特点包括:
4343
- 接收 TTS 音频
4444
4. 结束会话时关闭连接
4545

46+
```mermaid
47+
sequenceDiagram
48+
participant Client
49+
participant Server
50+
51+
Client->>Server: 建立 WebSocket 连接 (wss://xrobo-io.qiniuapi.com/v1/ws/)
52+
Note right of Client: 携带 headers: Authorization, Protocol-Version, Device-Id, Client-Id
53+
Server-->>Client: 连接成功
54+
55+
Client->>Server: 发送 hello 消息
56+
Note right of Client: JSON: {type: "hello", version: 1, transport: "websocket", audio_params: {...}}
57+
Server-->>Client: 响应 hello 消息
58+
Note left of Server: JSON: {type: "hello", transport: "websocket", audio_params: {...}}
59+
60+
Client->>Server: 发送开始监听消息
61+
Note right of Client: JSON: {session_id: "<ID>", type: "listen", state: "start", mode: "<auto/manual/realtime>"}
62+
63+
Client->>Server: 发送 OPUS 音频数据 (二进制)
64+
Server-->>Client: 返回语音识别结果
65+
Server-->>Client: 发送 TTS 音频数据 (OPUS)
66+
Note left of Server: JSON: {type: "tts", state: "<start/stop/sentence_start>", text: "<文本>"}
67+
68+
Client->>Server: 发送停止监听消息
69+
Note right of Client: JSON: {session_id: "<ID>", type: "listen", state: "stop"}
70+
71+
Client->>Server: 关闭 WebSocket 连接
72+
```
73+
4674
### 连接建立
4775

4876
1. 客户端连接 WebSocket 服务器时需要携带以下 headers:

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"devDependencies": {
3+
"medium-zoom": "^1.0.6",
4+
"mermaid": "^11.9.0",
35
"vitepress": "^1.6.3",
4-
"medium-zoom": "^1.0.6"
6+
"vitepress-plugin-mermaid": "^2.0.17"
57
},
68
"scripts": {
79
"docs:dev": "vitepress dev docs",

0 commit comments

Comments
 (0)