ai-chat-bot-interface 1.2.0 → 1.2.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/package.json +1 -1
- package/src/App.vue +1 -1
- package/src/ChatUi.vue +19 -1
- package/src/components/OperateModule.less +14 -0
- package/src/components/OperateModule.vue +71 -42
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -4,7 +4,7 @@ import ChatUi from './ChatUi.vue';
|
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
6
|
<div style="width: 100vw; height: 100vh">
|
|
7
|
-
<chat-ui bot-id="000" token="
|
|
7
|
+
<chat-ui bot-id="000" token="pat_88888" uid="262598" :show-header="true" />
|
|
8
8
|
</div>
|
|
9
9
|
</template>
|
|
10
10
|
<style></style>
|
package/src/ChatUi.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="cui_box">
|
|
3
3
|
<div class="cui_wrap">
|
|
4
|
-
<div class="cui_header">
|
|
4
|
+
<div v-if="showHeader" class="cui_header">
|
|
5
5
|
<div class="title" @click.stop="queryHistoryList">
|
|
6
6
|
<div class="back" @click.stop="handleBack">
|
|
7
7
|
<back-icon />
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<div class="btn_group">
|
|
15
15
|
<button class="btn" @click.stop="createConv">
|
|
16
16
|
<new-chat class="icon" />
|
|
17
|
+
<span style="font-size: 14px">新對話</span>
|
|
17
18
|
</button>
|
|
18
19
|
<template v-show="false">
|
|
19
20
|
<button class="btn">
|
|
@@ -119,10 +120,12 @@
|
|
|
119
120
|
</div>
|
|
120
121
|
<operate-module
|
|
121
122
|
v-model="inputText"
|
|
123
|
+
:new-chat="!showHeader"
|
|
122
124
|
:token="token"
|
|
123
125
|
:tag-list="tagList"
|
|
124
126
|
@send="chatConv"
|
|
125
127
|
@tag="handleTagSel"
|
|
128
|
+
@call="handleCall"
|
|
126
129
|
/>
|
|
127
130
|
</div>
|
|
128
131
|
</div>
|
|
@@ -183,6 +186,10 @@ const props = defineProps({
|
|
|
183
186
|
type: String,
|
|
184
187
|
required: true,
|
|
185
188
|
},
|
|
189
|
+
showHeader: {
|
|
190
|
+
type: Boolean,
|
|
191
|
+
default: true,
|
|
192
|
+
},
|
|
186
193
|
tagList: {
|
|
187
194
|
type: Array,
|
|
188
195
|
default: () => [
|
|
@@ -568,6 +575,17 @@ const handleCardTap = ({ type }, info) => {
|
|
|
568
575
|
Emits('call', { type, info });
|
|
569
576
|
}
|
|
570
577
|
};
|
|
578
|
+
const handleCall = (data) => {
|
|
579
|
+
switch (data.type) {
|
|
580
|
+
case 'new_chat':
|
|
581
|
+
createConv();
|
|
582
|
+
break;
|
|
583
|
+
default:
|
|
584
|
+
Emits('call', data);
|
|
585
|
+
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
571
589
|
|
|
572
590
|
const handlePlanParse = (list) => {
|
|
573
591
|
const pIdx = list.findIndex((p) => p.showType === 'plan');
|
|
@@ -42,6 +42,20 @@
|
|
|
42
42
|
grid-template-columns: 1fr auto;
|
|
43
43
|
background: #fff;
|
|
44
44
|
align-items: center;
|
|
45
|
+
&_box {
|
|
46
|
+
.flexrsc();
|
|
47
|
+
gap: 10px;
|
|
48
|
+
.new_chat {
|
|
49
|
+
.flexrcc();
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
width: 46px;
|
|
52
|
+
height: 46px;
|
|
53
|
+
font-size: 30px;
|
|
54
|
+
border-radius: 23px;
|
|
55
|
+
background: #ffffff;
|
|
56
|
+
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
45
59
|
&_wrap {
|
|
46
60
|
margin: 10px 0;
|
|
47
61
|
width: 100%;
|
|
@@ -11,54 +11,60 @@
|
|
|
11
11
|
{{ item.name }}
|
|
12
12
|
</div>
|
|
13
13
|
</div>
|
|
14
|
-
<div class="
|
|
15
|
-
<div
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
<div class="om_operate_box">
|
|
15
|
+
<div v-if="newChat" class="new_chat" @click.stop="newChatFunc">
|
|
16
|
+
<new-chat />
|
|
17
|
+
</div>
|
|
18
|
+
<div class="om_operate_wrap">
|
|
19
|
+
<div class="file_list_box" :class="{ hidden: !uploadPlane }">
|
|
20
|
+
<div class="file_list">
|
|
21
|
+
<div
|
|
22
|
+
v-for="(item, index) in uFileList"
|
|
23
|
+
:key="index"
|
|
24
|
+
class="file_card"
|
|
25
|
+
>
|
|
26
|
+
<img class="img" :src="item.file_url" width="100%" alt="img" />
|
|
27
|
+
<div v-if="item.percent < 100" class="process">
|
|
28
|
+
<progress-ring :percent="item.percent" />
|
|
29
|
+
</div>
|
|
30
|
+
<close-border-icon
|
|
31
|
+
v-else
|
|
32
|
+
class="close"
|
|
33
|
+
@click.stop="clearFile(index)"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<div
|
|
37
|
+
v-if="uFileList.length < 4"
|
|
38
|
+
class="file_add"
|
|
39
|
+
@click.stop="triggerUploadInput"
|
|
40
|
+
>
|
|
41
|
+
<add-icon />
|
|
42
|
+
</div>
|
|
43
|
+
<div class="file_close" @click.stop="closeUpload">
|
|
44
|
+
<close-icon />
|
|
25
45
|
</div>
|
|
26
|
-
<close-border-icon
|
|
27
|
-
v-else
|
|
28
|
-
class="close"
|
|
29
|
-
@click.stop="clearFile(index)"
|
|
30
|
-
/>
|
|
31
|
-
</div>
|
|
32
|
-
<div
|
|
33
|
-
v-if="uFileList.length < 4"
|
|
34
|
-
class="file_add"
|
|
35
|
-
@click.stop="triggerUploadInput"
|
|
36
|
-
>
|
|
37
|
-
<add-icon />
|
|
38
|
-
</div>
|
|
39
|
-
<div class="file_close" @click.stop="closeUpload">
|
|
40
|
-
<close-icon />
|
|
41
46
|
</div>
|
|
42
47
|
</div>
|
|
43
|
-
</div>
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
<div class="om_operate">
|
|
50
|
+
<textarea
|
|
51
|
+
v-model="textValue"
|
|
52
|
+
ref="txtEle"
|
|
53
|
+
class="input"
|
|
54
|
+
rows="1"
|
|
55
|
+
placeholder="發消息⋯"
|
|
56
|
+
@input="handleInput"
|
|
57
|
+
@keyup.enter="sendMsg"
|
|
58
|
+
/>
|
|
59
|
+
<div class="btn_group">
|
|
60
|
+
<div class="btn" @click.stop="sendMsg">
|
|
61
|
+
<send-icon :style="{ color: textValue ? '#039938' : '#ccc' }" />
|
|
62
|
+
</div>
|
|
58
63
|
</div>
|
|
59
64
|
</div>
|
|
60
65
|
</div>
|
|
61
66
|
</div>
|
|
67
|
+
|
|
62
68
|
<div class="om_extra" style="display: none">
|
|
63
69
|
<input
|
|
64
70
|
ref="captureInput"
|
|
@@ -103,6 +109,7 @@ import ProgressRing from './icons/progressRing.vue';
|
|
|
103
109
|
import AddIcon from './icons/addIcon.vue';
|
|
104
110
|
import CloseBorderIcon from './icons/closeBorderIcon.vue';
|
|
105
111
|
import CloseIcon from './icons/CloseIcon.vue';
|
|
112
|
+
import NewChat from './icons/newChat.vue';
|
|
106
113
|
|
|
107
114
|
const extraList = [
|
|
108
115
|
// { name: '相機', icon: CameraIcon, type: 'camera' },
|
|
@@ -129,8 +136,12 @@ const props = defineProps({
|
|
|
129
136
|
type: Array,
|
|
130
137
|
required: true,
|
|
131
138
|
},
|
|
139
|
+
newChat: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: false,
|
|
142
|
+
},
|
|
132
143
|
});
|
|
133
|
-
const Emits = defineEmits(['update:modelValue', 'send', 'tag']);
|
|
144
|
+
const Emits = defineEmits(['update:modelValue', 'send', 'tag', 'call']);
|
|
134
145
|
|
|
135
146
|
const fetchOptions = computed(() => {
|
|
136
147
|
return {
|
|
@@ -178,7 +189,19 @@ const handleTag = (info) => {
|
|
|
178
189
|
Emits('tag', { ...info });
|
|
179
190
|
}
|
|
180
191
|
};
|
|
181
|
-
const sendMsg = (
|
|
192
|
+
const sendMsg = () => {
|
|
193
|
+
if (
|
|
194
|
+
uFileList.value.length &&
|
|
195
|
+
uFileList.value.findIndex((f) => f.percent < 100) > -1
|
|
196
|
+
) {
|
|
197
|
+
Emits('call', {
|
|
198
|
+
message: '文件正在上傳,請稍候...',
|
|
199
|
+
reason: 'is_uploading',
|
|
200
|
+
value: 'toast',
|
|
201
|
+
type: 'call',
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
182
205
|
const list = [{ content: textValue.value, text: textValue.value }];
|
|
183
206
|
if (uFileList.value.length) {
|
|
184
207
|
list.push({
|
|
@@ -279,6 +302,12 @@ const clearFile = (idx) => {
|
|
|
279
302
|
uploadInput.value ? (uploadInput.value.value = '') : '';
|
|
280
303
|
};
|
|
281
304
|
|
|
305
|
+
const newChatFunc = () => {
|
|
306
|
+
Emits('call', {
|
|
307
|
+
type: 'new_chat',
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
|
|
282
311
|
const resizeTextarea = () => {
|
|
283
312
|
nextTick(() => {
|
|
284
313
|
if (txtEle.value) {
|