af-mobile-client-vue3 1.4.55 → 1.4.56
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
CHANGED
|
@@ -186,7 +186,7 @@ function handleSelectSession(session: { chatId: string, title: string, lastTime:
|
|
|
186
186
|
.chat-card {
|
|
187
187
|
width: 100%;
|
|
188
188
|
max-width: 1200px;
|
|
189
|
-
height: calc(
|
|
189
|
+
height: calc(100% - 40px);
|
|
190
190
|
background: #ffffff;
|
|
191
191
|
border-radius: 24px;
|
|
192
192
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
|
@@ -205,7 +205,7 @@ function handleSelectSession(session: { chatId: string, title: string, lastTime:
|
|
|
205
205
|
/* 移动端适配 */
|
|
206
206
|
@media (max-width: 768px) {
|
|
207
207
|
.chat-card {
|
|
208
|
-
height: calc(
|
|
208
|
+
height: calc(100% - 16px);
|
|
209
209
|
border-radius: 16px;
|
|
210
210
|
padding: 8px;
|
|
211
211
|
}
|
|
@@ -41,6 +41,21 @@ const finalLoading = computed(() => forceLoading.value || isLoading.value || !!c
|
|
|
41
41
|
// 当前使用的配置
|
|
42
42
|
const currentConfig = ref<MateChatConfig | null>(null)
|
|
43
43
|
|
|
44
|
+
const defaultBackgroundGradient = 'background: linear-gradient(to bottom, #d0c9ff 0%, #e6d6f0 8%, #f1dbea 12%, #c8dcfb 40%, #abc6f6 60%, #87aefe 90%)'
|
|
45
|
+
// 琉璃配色
|
|
46
|
+
// background: linear-gradient(to bottom, #a8f0ed 0%, #a8e6cf 8%, #c5b3ff 12%, #e0b3ff 40%, #fff4b8 60%, #ffb8d1 90%);
|
|
47
|
+
// 紫罗兰配色
|
|
48
|
+
// background: linear-gradient(to bottom, #d0c9ff 0%, #e6d6f0 8%, #f1dbea 12%, #c8dcfb 40%, #abc6f6 60%, #87aefe 90%);
|
|
49
|
+
// 蓝白配色
|
|
50
|
+
// 'linear-gradient(to bottom, #1c57e0 0%, #3b82f6 20%, #60a5fa 40%, #93c5fd 60%, #dbeafe 80%, #ffffff 100%)'
|
|
51
|
+
// 计算背景渐变样式
|
|
52
|
+
const backgroundStyle = computed(() => {
|
|
53
|
+
const gradient = currentConfig.value?.backgroundGradient || defaultBackgroundGradient
|
|
54
|
+
return {
|
|
55
|
+
background: gradient,
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
44
59
|
// 存储原始配置数据
|
|
45
60
|
const rawConfigs = ref<MateChatConfigs | MateChatConfig | null>(null)
|
|
46
61
|
|
|
@@ -305,7 +320,7 @@ onMounted(() => {
|
|
|
305
320
|
</script>
|
|
306
321
|
|
|
307
322
|
<template>
|
|
308
|
-
<div id="mate-chat-view">
|
|
323
|
+
<div id="mate-chat-view" :style="backgroundStyle">
|
|
309
324
|
<!-- 密码输入对话框 -->
|
|
310
325
|
<PasswordDialog
|
|
311
326
|
ref="passwordDialogRef"
|
|
@@ -351,9 +366,8 @@ onMounted(() => {
|
|
|
351
366
|
#mate-chat-view {
|
|
352
367
|
/* 外层渐变背景容器 */
|
|
353
368
|
width: 100%;
|
|
354
|
-
min-height:
|
|
355
|
-
|
|
356
|
-
/* background: linear-gradient(to bottom, #d0c9ff 0%, #e6d6f0 8%, #f1dbea 12%, #c8dcfb 40%, #abc6f6 60%, #87aefe 90%); */
|
|
369
|
+
min-height: 100%;
|
|
370
|
+
/* 背景色通过 :style 绑定从配置中获取 */
|
|
357
371
|
padding: 20px;
|
|
358
372
|
display: flex;
|
|
359
373
|
justify-content: center;
|
|
@@ -381,7 +395,7 @@ onMounted(() => {
|
|
|
381
395
|
|
|
382
396
|
/* 移动端适配 */
|
|
383
397
|
@media (max-width: 768px) {
|
|
384
|
-
height: calc(
|
|
398
|
+
height: calc(100% - 18px);
|
|
385
399
|
border-radius: 16px;
|
|
386
400
|
padding: 8px;
|
|
387
401
|
}
|
|
@@ -1,236 +1,241 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MateChat 提示项接口
|
|
3
|
-
*/
|
|
4
|
-
export interface MateChatPromptItem {
|
|
5
|
-
value: string
|
|
6
|
-
label: string
|
|
7
|
-
iconConfig?: {
|
|
8
|
-
name: string
|
|
9
|
-
color?: string
|
|
10
|
-
}
|
|
11
|
-
desc?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* MateChat 配置接口
|
|
16
|
-
*/
|
|
17
|
-
export interface MateChatConfig {
|
|
18
|
-
/**
|
|
19
|
-
* 可选密码,如果存在则需要密码验证
|
|
20
|
-
*/
|
|
21
|
-
password?: string
|
|
22
|
-
/**
|
|
23
|
-
* FastGPT 应用 ID
|
|
24
|
-
*/
|
|
25
|
-
appId: string
|
|
26
|
-
/**
|
|
27
|
-
* FastGPT API Key
|
|
28
|
-
*/
|
|
29
|
-
appKey: string
|
|
30
|
-
/**
|
|
31
|
-
* 介绍文案
|
|
32
|
-
*/
|
|
33
|
-
description: string[]
|
|
34
|
-
/**
|
|
35
|
-
* 首屏推荐问题列表
|
|
36
|
-
*/
|
|
37
|
-
introPrompt: MateChatPromptItem[]
|
|
38
|
-
/**
|
|
39
|
-
* 底部快捷问题列表
|
|
40
|
-
*/
|
|
41
|
-
simplePrompt: MateChatPromptItem[]
|
|
42
|
-
/**
|
|
43
|
-
* 客服名称
|
|
44
|
-
*/
|
|
45
|
-
serviceName: string
|
|
46
|
-
/**
|
|
47
|
-
* 是否使用流式对话
|
|
48
|
-
*/
|
|
49
|
-
useStream: boolean
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MateChat 提示项接口
|
|
3
|
+
*/
|
|
4
|
+
export interface MateChatPromptItem {
|
|
5
|
+
value: string
|
|
6
|
+
label: string
|
|
7
|
+
iconConfig?: {
|
|
8
|
+
name: string
|
|
9
|
+
color?: string
|
|
10
|
+
}
|
|
11
|
+
desc?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* MateChat 配置接口
|
|
16
|
+
*/
|
|
17
|
+
export interface MateChatConfig {
|
|
18
|
+
/**
|
|
19
|
+
* 可选密码,如果存在则需要密码验证
|
|
20
|
+
*/
|
|
21
|
+
password?: string
|
|
22
|
+
/**
|
|
23
|
+
* FastGPT 应用 ID
|
|
24
|
+
*/
|
|
25
|
+
appId: string
|
|
26
|
+
/**
|
|
27
|
+
* FastGPT API Key
|
|
28
|
+
*/
|
|
29
|
+
appKey: string
|
|
30
|
+
/**
|
|
31
|
+
* 介绍文案
|
|
32
|
+
*/
|
|
33
|
+
description: string[]
|
|
34
|
+
/**
|
|
35
|
+
* 首屏推荐问题列表
|
|
36
|
+
*/
|
|
37
|
+
introPrompt: MateChatPromptItem[]
|
|
38
|
+
/**
|
|
39
|
+
* 底部快捷问题列表
|
|
40
|
+
*/
|
|
41
|
+
simplePrompt: MateChatPromptItem[]
|
|
42
|
+
/**
|
|
43
|
+
* 客服名称
|
|
44
|
+
*/
|
|
45
|
+
serviceName: string
|
|
46
|
+
/**
|
|
47
|
+
* 是否使用流式对话
|
|
48
|
+
*/
|
|
49
|
+
useStream: boolean
|
|
50
|
+
/**
|
|
51
|
+
* 背景渐变颜色(CSS linear-gradient 字符串)
|
|
52
|
+
* 如果不提供,使用默认蓝白渐变
|
|
53
|
+
*/
|
|
54
|
+
backgroundGradient?: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 配置中心返回的多个配置对象
|
|
59
|
+
* key 为配置名称,value 为 MateChatConfig
|
|
60
|
+
*/
|
|
61
|
+
export type MateChatConfigs = Record<string, MateChatConfig>
|
|
62
|
+
|
|
63
|
+
// ==================== API 相关类型定义 ====================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 聊天消息接口
|
|
67
|
+
*/
|
|
68
|
+
export interface ChatMessage {
|
|
69
|
+
role: 'user' | 'assistant' | 'system'
|
|
70
|
+
content: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 聊天请求参数接口
|
|
75
|
+
*/
|
|
76
|
+
export interface ChatCompletionsRequest {
|
|
77
|
+
chatId: string
|
|
78
|
+
stream: boolean
|
|
79
|
+
detail: boolean
|
|
80
|
+
messages: ChatMessage[]
|
|
81
|
+
customUid?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 聊天响应使用情况接口
|
|
86
|
+
*/
|
|
87
|
+
export interface ChatUsage {
|
|
88
|
+
prompt_tokens: number
|
|
89
|
+
completion_tokens: number
|
|
90
|
+
total_tokens: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 聊天响应选择项接口
|
|
95
|
+
*/
|
|
96
|
+
export interface ChatChoice {
|
|
97
|
+
message: {
|
|
98
|
+
role: 'assistant'
|
|
99
|
+
content: string
|
|
100
|
+
}
|
|
101
|
+
finish_reason: string
|
|
102
|
+
index: number
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 聊天响应接口
|
|
107
|
+
*/
|
|
108
|
+
export interface ChatCompletionsResponse {
|
|
109
|
+
id: string
|
|
110
|
+
model: string
|
|
111
|
+
usage: ChatUsage
|
|
112
|
+
choices: ChatChoice[]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 业务层聊天结果
|
|
117
|
+
*/
|
|
118
|
+
export interface ChatBizResult {
|
|
119
|
+
/**
|
|
120
|
+
* normal: 普通回复
|
|
121
|
+
* transfer: 转人工
|
|
122
|
+
*/
|
|
123
|
+
type: 'normal' | 'transfer'
|
|
124
|
+
/**
|
|
125
|
+
* 大模型原始返回内容
|
|
126
|
+
*/
|
|
127
|
+
content: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 流式对话回调
|
|
132
|
+
*/
|
|
133
|
+
export interface ChatStreamCallbacks {
|
|
134
|
+
/**
|
|
135
|
+
* 每次收到 FastGPT SSE 的增量内容时触发
|
|
136
|
+
*/
|
|
137
|
+
onMessage?: (chunk: string) => void
|
|
138
|
+
/**
|
|
139
|
+
* 流结束时触发(包括收到 [DONE] 或正常读取结束)
|
|
140
|
+
*/
|
|
141
|
+
onComplete?: () => void
|
|
142
|
+
/**
|
|
143
|
+
* 请求或解析发生异常时触发
|
|
144
|
+
*/
|
|
145
|
+
onError?: (error: unknown) => void
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 历史会话项接口
|
|
150
|
+
*/
|
|
151
|
+
export interface ChatHistoryItem {
|
|
152
|
+
chatId: string
|
|
153
|
+
updateTime: string
|
|
154
|
+
appId: string
|
|
155
|
+
customTitle: string
|
|
156
|
+
title: string
|
|
157
|
+
top: boolean
|
|
158
|
+
[key: string]: any
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 历史会话查询请求参数接口
|
|
163
|
+
*/
|
|
164
|
+
export interface GetHistoriesRequest {
|
|
165
|
+
appId: string
|
|
166
|
+
outLinkUid: string
|
|
167
|
+
offset: number
|
|
168
|
+
pageSize: number
|
|
169
|
+
source: string
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 历史会话查询响应接口
|
|
174
|
+
*/
|
|
175
|
+
export interface GetHistoriesResponse {
|
|
176
|
+
code: number
|
|
177
|
+
statusText: string
|
|
178
|
+
message: string
|
|
179
|
+
data: {
|
|
180
|
+
list: ChatHistoryItem[]
|
|
181
|
+
total: number
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 历史会话记录项接口
|
|
187
|
+
*/
|
|
188
|
+
export interface ChatRecordItem {
|
|
189
|
+
_id: string
|
|
190
|
+
dataId: string
|
|
191
|
+
hideInUI: boolean
|
|
192
|
+
obj: 'Human' | 'AI'
|
|
193
|
+
value: Array<{
|
|
194
|
+
type: string
|
|
195
|
+
text: {
|
|
196
|
+
content: string
|
|
197
|
+
}
|
|
198
|
+
}>
|
|
199
|
+
customFeedbacks: any[]
|
|
200
|
+
time: string
|
|
201
|
+
durationSeconds?: number
|
|
202
|
+
llmModuleAccount?: number
|
|
203
|
+
totalQuoteList?: any[]
|
|
204
|
+
historyPreviewLength?: number
|
|
205
|
+
[key: string]: any
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 获取历史会话记录请求参数接口
|
|
210
|
+
*/
|
|
211
|
+
export interface GetPaginationRecordsRequest {
|
|
212
|
+
appId: string
|
|
213
|
+
chatId: string
|
|
214
|
+
offset: number
|
|
215
|
+
pageSize: number
|
|
216
|
+
loadCustomFeedbacks: boolean
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 获取历史会话记录响应接口
|
|
221
|
+
*/
|
|
222
|
+
export interface GetPaginationRecordsResponse {
|
|
223
|
+
code: number
|
|
224
|
+
statusText: string
|
|
225
|
+
message: string
|
|
226
|
+
data: {
|
|
227
|
+
list: ChatRecordItem[]
|
|
228
|
+
total: number
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ==================== MateChat 组件内部类型 ====================
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* MateChat 组件内部使用的消息结构
|
|
236
|
+
*/
|
|
237
|
+
export interface MateChatMessage {
|
|
238
|
+
from: 'user' | 'model' | 'service'
|
|
239
|
+
content: string
|
|
240
|
+
loading?: boolean
|
|
241
|
+
}
|