@legendzd/ai-agent-vue 1.0.1 → 1.0.6
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 +38 -6
- package/dist/index.cjs +50 -50
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +7943 -7430
- package/dist/src/api/agent.d.ts +9 -2
- package/dist/src/components/AgentButton.vue.d.ts +12 -1
- package/dist/src/components/ChatMessage.vue.d.ts +4 -0
- package/dist/src/directives/vDrag.d.ts +39 -0
- package/dist/src/plugin/index.d.ts +34 -1
- package/dist/src/stores/chat.d.ts +65 -53
- package/dist/src/types/agent.d.ts +56 -13
- package/dist/src/views/AgentChat.vue.d.ts +3 -3
- package/dist/src/views/AgentChatFull.vue.d.ts +3 -3
- package/dist/src/views/AgentChatMobile.vue.d.ts +3 -3
- package/dist/style.css +2 -0
- package/package.json +3 -3
- package/dist/ai-agent-vue.css +0 -2
package/README.md
CHANGED
|
@@ -42,15 +42,18 @@ app.use(AgentPlugin, {
|
|
|
42
42
|
app.mount('#app')
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
在模板中直接使用(插件注册后组件全局可用,自动继承全局配置):
|
|
46
46
|
|
|
47
47
|
```vue
|
|
48
48
|
<template>
|
|
49
|
-
<!--
|
|
49
|
+
<!-- 按钮弹窗布局(默认),自动继承全局注册的 apiUrl/userId -->
|
|
50
50
|
<AgentChat />
|
|
51
51
|
|
|
52
52
|
<!-- 等价于 -->
|
|
53
53
|
<AgentChatPopup />
|
|
54
|
+
|
|
55
|
+
<!-- 如需覆盖某项配置,只需传递对应字段即可 -->
|
|
56
|
+
<AgentChat :config="{ headerTitle: 'AI 助手' }" />
|
|
54
57
|
</template>
|
|
55
58
|
```
|
|
56
59
|
|
|
@@ -80,6 +83,15 @@ import '@legendzd/ai-agent-vue/dist/style.css'
|
|
|
80
83
|
右下角浮动按钮 + 弹出式聊天窗口,适合嵌入任意页面。
|
|
81
84
|
|
|
82
85
|
```vue
|
|
86
|
+
<!-- 已全局注册过配置时,直接使用即可 -->
|
|
87
|
+
<AgentChatPopup />
|
|
88
|
+
|
|
89
|
+
<!-- 或覆盖特定配置 -->
|
|
90
|
+
<AgentChatPopup :config="{
|
|
91
|
+
userId: 'user456',
|
|
92
|
+
}" />
|
|
93
|
+
|
|
94
|
+
<!-- 未全局注册时,需通过 config 传入必要配置 -->
|
|
83
95
|
<AgentChatPopup :config="{
|
|
84
96
|
apiUrl: 'http://your-server/api/v2',
|
|
85
97
|
userId: 'user123',
|
|
@@ -96,6 +108,14 @@ import '@legendzd/ai-agent-vue/dist/style.css'
|
|
|
96
108
|
左侧历史侧栏 + 右侧聊天窗口,适合作为独立聊天页面使用。
|
|
97
109
|
|
|
98
110
|
```vue
|
|
111
|
+
<!-- 已全局注册过配置时 -->
|
|
112
|
+
<AgentChatFull
|
|
113
|
+
:show-sidebar="true"
|
|
114
|
+
sidebar-width="280px"
|
|
115
|
+
sidebar-position="left"
|
|
116
|
+
/>
|
|
117
|
+
|
|
118
|
+
<!-- 未全局注册时 -->
|
|
99
119
|
<AgentChatFull
|
|
100
120
|
:config="{ apiUrl: 'http://your-server/api/v2', userId: 'user123' }"
|
|
101
121
|
:show-sidebar="true"
|
|
@@ -122,6 +142,13 @@ import '@legendzd/ai-agent-vue/dist/style.css'
|
|
|
122
142
|
全屏聊天 + 底部抽屉式历史面板,适配移动端安全区域。
|
|
123
143
|
|
|
124
144
|
```vue
|
|
145
|
+
<!-- 已全局注册过配置时 -->
|
|
146
|
+
<AgentChatMobile
|
|
147
|
+
safe-area-top="env(safe-area-inset-top, 0px)"
|
|
148
|
+
safe-area-bottom="env(safe-area-inset-bottom, 0px)"
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
<!-- 未全局注册时 -->
|
|
125
152
|
<AgentChatMobile
|
|
126
153
|
:config="{ apiUrl: 'http://your-server/api/v2', userId: 'user123' }"
|
|
127
154
|
safe-area-top="env(safe-area-inset-top, 0px)"
|
|
@@ -368,7 +395,7 @@ API 层优先使用 `getUserId()`,若未提供则 fallback 到 `userId` 静态
|
|
|
368
395
|
|
|
369
396
|
### config prop 合并规则
|
|
370
397
|
|
|
371
|
-
|
|
398
|
+
配置按优先级从高到低合并:**组件 config prop > 组件顶层 props > 全局插件注册 > 默认值**
|
|
372
399
|
|
|
373
400
|
```vue
|
|
374
401
|
<!-- 两种写法等价 -->
|
|
@@ -380,6 +407,11 @@ API 层优先使用 `getUserId()`,若未提供则 fallback 到 `userId` 静态
|
|
|
380
407
|
user-id="fallback"
|
|
381
408
|
:config="{ userId: 'priority' }"
|
|
382
409
|
/>
|
|
410
|
+
|
|
411
|
+
<!-- 全局注册的配置自动继承,组件只需覆盖差异项 -->
|
|
412
|
+
<!-- 假设 app.use(AgentPlugin, { apiUrl: 'http://...', userId: 'user123' }) -->
|
|
413
|
+
<AgentChat :config="{ headerTitle: 'AI 助手' }" />
|
|
414
|
+
<!-- 等价于 { apiUrl: 'http://...', userId: 'user123', headerTitle: 'AI 助手' } -->
|
|
383
415
|
```
|
|
384
416
|
|
|
385
417
|
## 组件实例 API
|
|
@@ -541,9 +573,9 @@ const chatRef = ref()
|
|
|
541
573
|
|
|
542
574
|
| 功能 | 方法 | 完整路径 |
|
|
543
575
|
|---|---|---|
|
|
544
|
-
| 创建会话 | POST | `${apiUrl}/
|
|
545
|
-
| 流式对话 | POST | `${apiUrl}/
|
|
546
|
-
| 获取历史 | GET | `${apiUrl}/
|
|
576
|
+
| 创建会话 | POST | `${apiUrl}/external/chat/session` |
|
|
577
|
+
| 流式对话 | POST | `${apiUrl}/external/query-data/stream` |
|
|
578
|
+
| 获取历史 | GET | `${apiUrl}/external/chat/sessions?userId=xxx` |
|
|
547
579
|
|
|
548
580
|
### SSE 事件类型
|
|
549
581
|
|