@leatop/ai-agent-iframe 3.0.0 → 3.0.2

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Lollipope
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lollipope
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @leatop/ai-agent-iframe
2
+
3
+ Leatop CDP AI Agent 的 **iframe 轻量版**悬浮入口组件。
4
+ 只负责「悬浮机器人图标 + 全屏/半屏 iframe 容器 + 与子应用 postMessage 通信」,不含本地对话渲染逻辑,包体很小。
5
+
6
+ ## 1. 安装
7
+
8
+ ```bash
9
+ pnpm add @leatop/ai-agent-iframe
10
+ ```
11
+
12
+
13
+
14
+ - `vue` `^3.5`
15
+ - `element-plus` `^2.11`(组件内部使用了 `el-icon` / `el-tag`,**需宿主全局注册 Element Plus**:`app.use(ElementPlus)`)
16
+ - `axios` `^1.6`、`qs` `^6.12`(内部请求封装使用)
17
+
18
+ ## 2. 运行时配置
19
+
20
+ 组件初始化时读取 `window.globalConfig`,请在被引入前注入(例如 `public/config.js`):
21
+
22
+ ```js
23
+ window.globalConfig = {
24
+ // 生成 ticket 的接口前缀(不配则默认 '/api/')
25
+ AiAgentApi: '/api/',
26
+ // true:从 cookie 取 token;false/不配:从 localStorage 取 'cdp-token'
27
+ sessionCookie: true,
28
+ AiAgentIframeSrc: 'https://172.17.2.56:30090',
29
+ };
30
+ ```
31
+
32
+ ## 3. 在页面中使用
33
+
34
+
35
+
36
+ ```vue
37
+ <script setup>
38
+ // 推荐:局部注册(与 @leatop/ai-agent 的用法一致)
39
+ import '@leatop/ai-agent-iframe/style.css';
40
+ import AIagent from '@leatop/ai-agent-iframe';
41
+ import aes from "@/cdp-common/utils/aes";
42
+
43
+ const aiIframeSrc = window.globalConfig?.AiAgentIframeSrc || ''
44
+ const userStore = useUserStore();
45
+ const userInfo = userStore.userInfo;
46
+ const loginKey = aes.encrypt(userInfo?.account)
47
+ </script>
48
+
49
+ <template>
50
+ <!-- 建议放在 NavBar 右侧,父容器 z-index 需高于导航 -->
51
+ <AIagent
52
+ v-if="!!userInfo.account && showAiagent" :userInfo="userInfo" :loginKey="loginKey" :aiIframeSrc="aiIframeSrc"
53
+ />
54
+ </template>
55
+ ```
56
+
57
+