byt-lingxiao-ai 0.1.0
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 +24 -0
- package/components/ChatWindow.vue +395 -0
- package/components/assets/normal.png +0 -0
- package/components/assets/output.png +0 -0
- package/components/assets/thinking.png +0 -0
- package/components/index.js +28 -0
- package/dist/demo.html +1 -0
- package/dist/img/normal.13f08ecb.png +0 -0
- package/dist/index.common.js +2691 -0
- package/dist/index.common.js.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.umd.js +2702 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/index.umd.min.js +2 -0
- package/dist/index.umd.min.js.map +1 -0
- package/jsconfig.json +19 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# byt-lingxiao-test
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
yarn install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and hot-reloads for development
|
|
9
|
+
```
|
|
10
|
+
yarn serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Compiles and minifies for production
|
|
14
|
+
```
|
|
15
|
+
yarn build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Lints and fixes files
|
|
19
|
+
```
|
|
20
|
+
yarn lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Customize configuration
|
|
24
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chat">
|
|
3
|
+
<div class="chat-ai" @click="toggleWindow">
|
|
4
|
+
<div class="chat-ai-avater"></div>
|
|
5
|
+
<div class="chat-ai-text">凌霄AI</div>
|
|
6
|
+
</div>
|
|
7
|
+
<!-- 添加一个遮罩层,用于捕获点击外部事件 -->
|
|
8
|
+
<div class="chat-overlay" v-show="visible" @click="handleOverlayClick">
|
|
9
|
+
<div class="chat-window" @click.stop>
|
|
10
|
+
<div class="chat-window-header">
|
|
11
|
+
<div class="chat-window-header-title">凌霄大模型AI对话</div>
|
|
12
|
+
<div class="chat-window-header-close" @click="visible = false">
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
width="24"
|
|
16
|
+
height="24"
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
fill="none"
|
|
19
|
+
>
|
|
20
|
+
<path
|
|
21
|
+
d="M5.50002 5.5L18.5 18.5"
|
|
22
|
+
stroke="#4E5969"
|
|
23
|
+
stroke-width="1.89404"
|
|
24
|
+
stroke-linecap="round"
|
|
25
|
+
stroke-linejoin="round"
|
|
26
|
+
/>
|
|
27
|
+
<path
|
|
28
|
+
d="M5.50002 18.5L18.5 5.5"
|
|
29
|
+
stroke="#4E5969"
|
|
30
|
+
stroke-width="1.89404"
|
|
31
|
+
stroke-linecap="round"
|
|
32
|
+
stroke-linejoin="round"
|
|
33
|
+
/>
|
|
34
|
+
</svg>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<div ref="chatArea" class="chat-window-content scrollbar-hide">
|
|
38
|
+
<div
|
|
39
|
+
class="chat-window-message"
|
|
40
|
+
v-for="message in messages"
|
|
41
|
+
:key="message.id"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
class="chat-window-message-user"
|
|
45
|
+
v-if="message.type === 'user'"
|
|
46
|
+
>
|
|
47
|
+
<div class="user-message">{{ message.content }}</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="chat-window-message-ai" v-else>
|
|
50
|
+
<div class="ai-message">{{ message.content }}</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="chat-window-footer">
|
|
55
|
+
<div class="chat-window-textarea">
|
|
56
|
+
<el-input
|
|
57
|
+
type="textarea"
|
|
58
|
+
class="chat-window-input"
|
|
59
|
+
placeholder="有什么我能帮您的吗?"
|
|
60
|
+
rows="2"
|
|
61
|
+
resize="none"
|
|
62
|
+
v-model="inputMessage"
|
|
63
|
+
@keydown="handleKeyDown"
|
|
64
|
+
></el-input>
|
|
65
|
+
<div class="chat-window-bar">
|
|
66
|
+
<div class="chat-window-send">
|
|
67
|
+
<svg
|
|
68
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
69
|
+
width="20"
|
|
70
|
+
height="20"
|
|
71
|
+
viewBox="0 0 20 20"
|
|
72
|
+
fill="none"
|
|
73
|
+
>
|
|
74
|
+
<g clip-path="url(#clip0_640_2107)">
|
|
75
|
+
<path
|
|
76
|
+
d="M18.6427 2.37822C19.3253 2.47432 19.8025 3.10738 19.7065 3.79002C19.6871 3.97072 19.5381 4.41327 19.5403 4.41161L14.9673 17.8079L14.9632 17.8093C14.7858 18.3838 14.212 18.7607 13.5971 18.6744C13.4173 18.6492 13.2504 18.5862 13.1055 18.4949L13.0973 18.4977L9.83449 16.3686C9.58371 16.2584 9.4276 15.9939 9.46729 15.7115C9.5154 15.3691 9.83278 15.1317 10.1751 15.1798C10.293 15.1964 10.3988 15.2448 10.4853 15.3161L13.4054 17.2314L13.4073 17.2317C13.4452 17.2566 13.4882 17.2746 13.5364 17.2814C13.6911 17.3029 13.8371 17.2052 13.8793 17.0593L18.0469 4.89796L8.27396 14.3367L7.77435 17.8916C7.72706 18.2281 7.41369 18.464 7.07727 18.4169C6.74073 18.3696 6.50469 18.0564 6.55198 17.7198L7.07633 13.9889C7.08231 13.9464 7.09382 13.9066 7.10727 13.867C7.13549 13.7645 7.19079 13.6657 7.27291 13.5866L17.0754 4.12041L2.68514 8.17767L2.68487 8.1796C2.58481 8.21873 2.50686 8.31058 2.49042 8.42643C2.47412 8.5424 2.52417 8.65007 2.6093 8.71729L2.60903 8.71922L3.28261 9.16101L3.28013 9.16461C3.47505 9.29254 3.58819 9.52563 3.55386 9.77111C3.50575 10.1134 3.18836 10.3509 2.84602 10.3028C2.75512 10.29 2.6708 10.2584 2.59833 10.2127L2.59806 10.2147L1.37843 9.42001L1.37951 9.41227C1.02215 9.14901 0.816644 8.70195 0.882687 8.23203C0.951867 7.74096 1.29791 7.35545 1.73968 7.21445L1.73995 7.21251L17.7833 2.57104C18.0287 2.41036 18.3294 2.3342 18.6427 2.37822Z"
|
|
77
|
+
fill="#013378"
|
|
78
|
+
/>
|
|
79
|
+
<path
|
|
80
|
+
d="M3.1309 10.9936C3.2178 10.5684 3.82528 10.5684 3.91218 10.9936C4.10411 11.9326 4.83794 12.6664 5.77697 12.8584C6.20213 12.9453 6.20213 13.5527 5.77697 13.6397C4.83794 13.8316 4.10411 14.5654 3.91218 15.5044C3.82528 15.9296 3.2178 15.9296 3.1309 15.5044C2.93897 14.5654 2.20513 13.8316 1.26611 13.6397C0.840944 13.5527 0.840944 12.9453 1.26611 12.8584C2.20513 12.6664 2.93897 11.9326 3.1309 10.9936Z"
|
|
81
|
+
fill="#2B80F6"
|
|
82
|
+
/>
|
|
83
|
+
<path
|
|
84
|
+
d="M6.20382 8.56242C6.25596 8.30732 6.62045 8.30732 6.67259 8.56242C6.78775 9.12583 7.22805 9.56613 7.79146 9.68129C8.04656 9.73343 8.04656 10.0979 7.79146 10.1501C7.22805 10.2652 6.78775 10.7055 6.67259 11.2689C6.62045 11.524 6.25596 11.524 6.20382 11.2689C6.08866 10.7055 5.64836 10.2652 5.08495 10.1501C4.82985 10.0979 4.82985 9.73343 5.08495 9.68129C5.64836 9.56613 6.08866 9.12583 6.20382 8.56242Z"
|
|
85
|
+
fill="#2B80F6"
|
|
86
|
+
/>
|
|
87
|
+
</g>
|
|
88
|
+
<defs>
|
|
89
|
+
<clipPath id="clip0_640_2107">
|
|
90
|
+
<rect width="20" height="20" fill="white" />
|
|
91
|
+
</clipPath>
|
|
92
|
+
</defs>
|
|
93
|
+
</svg>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
102
|
+
<script>
|
|
103
|
+
export default {
|
|
104
|
+
name: 'ChatWindow',
|
|
105
|
+
props: {
|
|
106
|
+
appendToBody: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: true,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
data() {
|
|
112
|
+
return {
|
|
113
|
+
wsUrl: '',
|
|
114
|
+
inputMessage: '',
|
|
115
|
+
visible: false,
|
|
116
|
+
messages: [
|
|
117
|
+
{
|
|
118
|
+
id: 1,
|
|
119
|
+
type: 'user',
|
|
120
|
+
sender: '',
|
|
121
|
+
time: '',
|
|
122
|
+
content: '你好,欢迎来到凌霄大模型AI对话。',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 2,
|
|
126
|
+
type: 'ai',
|
|
127
|
+
sender: 'AI',
|
|
128
|
+
time: '',
|
|
129
|
+
content: '欢迎来到凌霄大模型AI对话。',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 3,
|
|
133
|
+
type: 'ai',
|
|
134
|
+
sender: 'AI',
|
|
135
|
+
time: '',
|
|
136
|
+
content: '请输入您的问题。',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 4,
|
|
140
|
+
type: 'user',
|
|
141
|
+
sender: '用户',
|
|
142
|
+
time: '',
|
|
143
|
+
content: '你好,欢迎来到凌霄大模型AI对话。',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
mounted() {
|
|
149
|
+
this.scrollToBottom()
|
|
150
|
+
|
|
151
|
+
// 处理append-to-body逻辑
|
|
152
|
+
if (this.appendToBody) {
|
|
153
|
+
this.appendToBodyHandler()
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
beforeDestroy() {
|
|
157
|
+
// 组件销毁前,如果元素被移动到body中,需要移除
|
|
158
|
+
if (this.appendToBody && this.$el.parentElement === document.body) {
|
|
159
|
+
document.body.removeChild(this.$el)
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
methods: {
|
|
163
|
+
initWebSocket() {},
|
|
164
|
+
initAudio() {},
|
|
165
|
+
handleSend() {},
|
|
166
|
+
toggleWindow() {
|
|
167
|
+
this.visible = !this.visible
|
|
168
|
+
},
|
|
169
|
+
showWindow() {
|
|
170
|
+
this.visible = true
|
|
171
|
+
},
|
|
172
|
+
hideWindow() {
|
|
173
|
+
this.visible = false
|
|
174
|
+
},
|
|
175
|
+
scrollToBottom() {
|
|
176
|
+
this.$nextTick(() => {
|
|
177
|
+
const chatArea = this.$refs.chatArea
|
|
178
|
+
if (chatArea) {
|
|
179
|
+
chatArea.scrollTop = chatArea.scrollHeight
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
handleKeyDown(e) {
|
|
184
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
185
|
+
e.preventDefault()
|
|
186
|
+
this.handleSend()
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
// 添加到body的处理函数
|
|
190
|
+
appendToBodyHandler() {
|
|
191
|
+
// 确保DOM已经渲染完成
|
|
192
|
+
this.$nextTick(() => {
|
|
193
|
+
// 检查元素是否已经在body中
|
|
194
|
+
if (this.$el.parentElement !== document.body) {
|
|
195
|
+
// 将组件的根元素移动到body中
|
|
196
|
+
document.body.appendChild(this.$el)
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
// 处理点击遮罩层事件
|
|
201
|
+
handleOverlayClick() {
|
|
202
|
+
this.visible = false
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
watch: {
|
|
206
|
+
messages: {
|
|
207
|
+
handler() {
|
|
208
|
+
this.scrollToBottom()
|
|
209
|
+
},
|
|
210
|
+
deep: true,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
215
|
+
<style scoped>
|
|
216
|
+
.chat-overlay {
|
|
217
|
+
position: fixed;
|
|
218
|
+
top: 0;
|
|
219
|
+
left: 0;
|
|
220
|
+
width: 100%;
|
|
221
|
+
height: 100%;
|
|
222
|
+
background: transparent;
|
|
223
|
+
z-index: 10000;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
::v-deep .el-textarea__inner {
|
|
227
|
+
border: none !important;
|
|
228
|
+
padding: 0 5px;
|
|
229
|
+
font-family: 'PingFang SC' !important;
|
|
230
|
+
}
|
|
231
|
+
::v-deep .el-textarea__inner::-webkit-scrollbar {
|
|
232
|
+
width: 6px;
|
|
233
|
+
height: 6px;
|
|
234
|
+
}
|
|
235
|
+
::v-deep .el-textarea__inner::-webkit-scrollbar-thumb {
|
|
236
|
+
background: rgba(0, 0, 0, 0.1);
|
|
237
|
+
border-radius: 3px;
|
|
238
|
+
}
|
|
239
|
+
::v-deep .el-textarea__inner::-webkit-scrollbar-track {
|
|
240
|
+
background: transparent;
|
|
241
|
+
}
|
|
242
|
+
.scrollbar-hide::-webkit-scrollbar {
|
|
243
|
+
display: none;
|
|
244
|
+
}
|
|
245
|
+
.scrollbar-hide {
|
|
246
|
+
-ms-overflow-style: none;
|
|
247
|
+
scrollbar-width: none;
|
|
248
|
+
}
|
|
249
|
+
.chat {
|
|
250
|
+
position: fixed;
|
|
251
|
+
bottom: 20px;
|
|
252
|
+
right: 10px;
|
|
253
|
+
z-index: 10001;
|
|
254
|
+
}
|
|
255
|
+
.chat-ai {
|
|
256
|
+
display: flex;
|
|
257
|
+
width: 38px;
|
|
258
|
+
padding: 2px 2px 9px 2px;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
align-items: center;
|
|
261
|
+
gap: 6px;
|
|
262
|
+
border-radius: 40px;
|
|
263
|
+
background: linear-gradient(180deg, #3e5beb 0%, #5ca5f9 100%);
|
|
264
|
+
box-shadow: 0 2px 11.6px 0 rgba(0, 0, 0, 0.1);
|
|
265
|
+
cursor: pointer;
|
|
266
|
+
user-select: none;
|
|
267
|
+
}
|
|
268
|
+
.chat-ai-avater {
|
|
269
|
+
border-radius: 67px;
|
|
270
|
+
border: 1px solid #0f66e4;
|
|
271
|
+
background: #124087;
|
|
272
|
+
display: flex;
|
|
273
|
+
width: 34px;
|
|
274
|
+
height: 33px;
|
|
275
|
+
padding: 2px 2px 1px 2px;
|
|
276
|
+
justify-content: center;
|
|
277
|
+
align-items: center;
|
|
278
|
+
background-size: cover;
|
|
279
|
+
background-position: center;
|
|
280
|
+
background-image: url('./assets/normal.png');
|
|
281
|
+
}
|
|
282
|
+
.chat-ai-text {
|
|
283
|
+
color: #fff;
|
|
284
|
+
font-family: 'PingFang SC';
|
|
285
|
+
font-size: 16px;
|
|
286
|
+
font-style: normal;
|
|
287
|
+
font-weight: 500;
|
|
288
|
+
line-height: 20px;
|
|
289
|
+
align-self: stretch;
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
width: 20px;
|
|
293
|
+
margin: 0 auto;
|
|
294
|
+
text-align: center;
|
|
295
|
+
}
|
|
296
|
+
.chat-window-message-user {
|
|
297
|
+
display: flex;
|
|
298
|
+
justify-content: flex-end;
|
|
299
|
+
}
|
|
300
|
+
.user-message {
|
|
301
|
+
max-width: 80%;
|
|
302
|
+
display: flex;
|
|
303
|
+
padding: 8px 12px;
|
|
304
|
+
justify-content: center;
|
|
305
|
+
align-items: center;
|
|
306
|
+
gap: 10px;
|
|
307
|
+
border-radius: 12px;
|
|
308
|
+
background: #e3ecff;
|
|
309
|
+
}
|
|
310
|
+
.chat-window-bar {
|
|
311
|
+
display: flex;
|
|
312
|
+
justify-content: flex-end;
|
|
313
|
+
padding: 8px;
|
|
314
|
+
}
|
|
315
|
+
.chat-window-message-ai {
|
|
316
|
+
display: flex;
|
|
317
|
+
gap: 12px;
|
|
318
|
+
align-items: flex-start;
|
|
319
|
+
}
|
|
320
|
+
.ai-message {
|
|
321
|
+
max-width: 80%;
|
|
322
|
+
border-radius: 12px;
|
|
323
|
+
background: #f6f8fc;
|
|
324
|
+
padding: 8px 12px;
|
|
325
|
+
}
|
|
326
|
+
.chat-window {
|
|
327
|
+
width: 480px;
|
|
328
|
+
height: 740px;
|
|
329
|
+
border-radius: 14px;
|
|
330
|
+
background: #fff;
|
|
331
|
+
box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.16);
|
|
332
|
+
position: absolute;
|
|
333
|
+
bottom: 0;
|
|
334
|
+
right: 50px;
|
|
335
|
+
overflow: hidden;
|
|
336
|
+
display: flex;
|
|
337
|
+
flex-direction: column;
|
|
338
|
+
}
|
|
339
|
+
.chat-window-header {
|
|
340
|
+
display: flex;
|
|
341
|
+
justify-content: space-between;
|
|
342
|
+
align-items: center;
|
|
343
|
+
border-bottom: 1px solid #eaeaea;
|
|
344
|
+
background: #fff;
|
|
345
|
+
padding: 16px;
|
|
346
|
+
flex-shrink: 0;
|
|
347
|
+
}
|
|
348
|
+
.chat-window-content {
|
|
349
|
+
flex: 1;
|
|
350
|
+
padding: 16px;
|
|
351
|
+
overflow-y: auto;
|
|
352
|
+
display: flex;
|
|
353
|
+
flex-direction: column;
|
|
354
|
+
gap: 8px;
|
|
355
|
+
}
|
|
356
|
+
.chat-window-header-title {
|
|
357
|
+
color: #29414e;
|
|
358
|
+
font-size: 18px;
|
|
359
|
+
font-weight: 900;
|
|
360
|
+
}
|
|
361
|
+
.chat-window-header-close {
|
|
362
|
+
width: 24px;
|
|
363
|
+
height: 24px;
|
|
364
|
+
overflow: hidden;
|
|
365
|
+
cursor: pointer;
|
|
366
|
+
}
|
|
367
|
+
.chat-window-footer {
|
|
368
|
+
padding: 16px;
|
|
369
|
+
}
|
|
370
|
+
.chat-window-textarea {
|
|
371
|
+
min-height: 99px;
|
|
372
|
+
max-height: 180px;
|
|
373
|
+
border-radius: 8px;
|
|
374
|
+
border: 1px solid #f2f2f2;
|
|
375
|
+
background: #fff;
|
|
376
|
+
display: flex;
|
|
377
|
+
flex-direction: column;
|
|
378
|
+
}
|
|
379
|
+
.chat-window-input {
|
|
380
|
+
padding: 10px 12px;
|
|
381
|
+
font-size: 16px;
|
|
382
|
+
font-family: 'PingFang SC';
|
|
383
|
+
}
|
|
384
|
+
.chat-window-send {
|
|
385
|
+
width: 70px;
|
|
386
|
+
height: 36px;
|
|
387
|
+
flex-shrink: 0;
|
|
388
|
+
border-radius: 6px;
|
|
389
|
+
background: rgba(43, 128, 246, 0.1);
|
|
390
|
+
display: flex;
|
|
391
|
+
align-items: center;
|
|
392
|
+
justify-content: center;
|
|
393
|
+
cursor: pointer;
|
|
394
|
+
}
|
|
395
|
+
</style>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ChatWindow from './ChatWindow.vue';
|
|
2
|
+
|
|
3
|
+
const components = {
|
|
4
|
+
ChatWindow,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const install = function(Vue) {
|
|
8
|
+
if (install.installed) return;
|
|
9
|
+
install.installed = true;
|
|
10
|
+
|
|
11
|
+
Object.keys(components).forEach(name => {
|
|
12
|
+
Vue.component(name, components[name]);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// 自动注册
|
|
17
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
18
|
+
install(window.Vue);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
install,
|
|
23
|
+
...components
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
ChatWindow
|
|
28
|
+
}
|
package/dist/demo.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset="utf-8"><title>index demo</title><script src="./index.umd.js"></script><link rel="stylesheet" href="./index.css"><script>console.log(index)</script>
|
|
Binary file
|