@tencentcloud/ai-desk-customer-vue 1.5.3 → 1.5.4
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/CHANGELOG.md +12 -0
- package/assets/language_arrow_down.svg +3 -0
- package/assets/language_check.svg +3 -0
- package/components/CustomerServiceChat/chat-header/index-web.vue +215 -13
- package/components/CustomerServiceChat/index-web.vue +86 -25
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +14 -4
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +19 -16
- package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +4 -4
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +10 -3
- package/components/CustomerServiceChat/message-list/index-web.vue +27 -14
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-desk.vue +6 -1
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch/branch-pc.vue +20 -13
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch/index.vue +1 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-robot-welcome.vue +73 -29
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-transfer-with-desc.vue +51 -0
- package/components/CustomerServiceChat/message-toolbar-button/index.vue +13 -2
- package/components/CustomerServiceChat/style/web.scss +2 -0
- package/constant.ts +21 -1
- package/interface.ts +15 -2
- package/locales/en/aidesk.ts +4 -4
- package/locales/en/index.ts +2 -2
- package/locales/en/time.ts +2 -2
- package/locales/fil/index.ts +2 -2
- package/locales/fil/time.ts +2 -2
- package/locales/id/index.ts +2 -2
- package/locales/id/time.ts +2 -2
- package/locales/ja/index.ts +2 -2
- package/locales/ja/time.ts +2 -2
- package/locales/ms/index.ts +2 -2
- package/locales/ms/time.ts +2 -2
- package/locales/ru/index.ts +2 -2
- package/locales/ru/time.ts +2 -2
- package/locales/th/index.ts +2 -2
- package/locales/th/time.ts +2 -2
- package/locales/vi/index.ts +2 -2
- package/locales/vi/time.ts +2 -2
- package/locales/zh_cn/aidesk.ts +1 -1
- package/locales/zh_cn/index.ts +2 -2
- package/locales/zh_cn/time.ts +2 -2
- package/locales/zh_tw/aidesk.ts +1 -1
- package/locales/zh_tw/index.ts +2 -2
- package/locales/zh_tw/time.ts +2 -2
- package/package.json +2 -1
- package/server.ts +21 -3
- package/utils/index.ts +6 -13
- package/utils/utils.ts +44 -3
package/locales/id/time.ts
CHANGED
package/locales/ja/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -19,7 +19,7 @@ const messages = {
|
|
|
19
19
|
AIDesk,
|
|
20
20
|
TUIChat,
|
|
21
21
|
Component,
|
|
22
|
-
|
|
22
|
+
time,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
package/locales/ja/time.ts
CHANGED
package/locales/ms/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -19,7 +19,7 @@ const messages = {
|
|
|
19
19
|
AIDesk,
|
|
20
20
|
TUIChat,
|
|
21
21
|
Component,
|
|
22
|
-
|
|
22
|
+
time,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
package/locales/ms/time.ts
CHANGED
package/locales/ru/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -18,7 +18,7 @@ const messages = {
|
|
|
18
18
|
"拍照": 'Сделать фото',
|
|
19
19
|
TUIChat,
|
|
20
20
|
Component,
|
|
21
|
-
|
|
21
|
+
time,
|
|
22
22
|
AIDesk,
|
|
23
23
|
},
|
|
24
24
|
};
|
package/locales/ru/time.ts
CHANGED
package/locales/th/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -19,7 +19,7 @@ const messages = {
|
|
|
19
19
|
AIDesk,
|
|
20
20
|
TUIChat,
|
|
21
21
|
Component,
|
|
22
|
-
|
|
22
|
+
time,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
package/locales/th/time.ts
CHANGED
package/locales/vi/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -19,7 +19,7 @@ const messages = {
|
|
|
19
19
|
AIDesk,
|
|
20
20
|
TUIChat,
|
|
21
21
|
Component,
|
|
22
|
-
|
|
22
|
+
time,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
package/locales/vi/time.ts
CHANGED
package/locales/zh_cn/aidesk.ts
CHANGED
package/locales/zh_cn/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -18,7 +18,7 @@ const messages = {
|
|
|
18
18
|
"拍照": '拍照',
|
|
19
19
|
TUIChat,
|
|
20
20
|
Component,
|
|
21
|
-
|
|
21
|
+
time,
|
|
22
22
|
AIDesk,
|
|
23
23
|
},
|
|
24
24
|
};
|
package/locales/zh_cn/time.ts
CHANGED
package/locales/zh_tw/aidesk.ts
CHANGED
package/locales/zh_tw/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TUIChat from './TUIChat';
|
|
2
2
|
import Component from './component';
|
|
3
|
-
import
|
|
3
|
+
import time from './time';
|
|
4
4
|
import AIDesk from './aidesk';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -19,7 +19,7 @@ const messages = {
|
|
|
19
19
|
AIDesk,
|
|
20
20
|
TUIChat,
|
|
21
21
|
Component,
|
|
22
|
-
|
|
22
|
+
time,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
package/locales/zh_tw/time.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencentcloud/ai-desk-customer-vue",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Vue2/Vue3 UIKit for AI Desk",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@tiptap/pm": "2.0.0-beta.220",
|
|
33
33
|
"@tiptap/suggestion": "2.0.0-beta.220",
|
|
34
34
|
"@types/lodash": "^4.14.202",
|
|
35
|
+
"countries-and-timezones": "^3.8.0",
|
|
35
36
|
"dayjs": "^1.11.10",
|
|
36
37
|
"lodash": "^4.17.21",
|
|
37
38
|
"marked": "^6.0.0",
|
package/server.ts
CHANGED
|
@@ -13,14 +13,17 @@ import TUIChatEngine, {
|
|
|
13
13
|
SendMessageParams,
|
|
14
14
|
SendMessageOptions,
|
|
15
15
|
TUIUserService,
|
|
16
|
+
TUIStore,
|
|
17
|
+
StoreName,
|
|
16
18
|
} from '@tencentcloud/chat-uikit-engine';
|
|
17
19
|
import Log from './utils/logger';
|
|
18
20
|
import { version } from './package.json'
|
|
19
21
|
import { Toast, TOAST_TYPE } from "./components/common/Toast/index-web";
|
|
20
|
-
import { switchReadStatus } from "./utils/utils";
|
|
22
|
+
import { switchReadStatus, transferToHuman, transferToTaskFlow } from "./utils/utils";
|
|
21
23
|
import state from "./utils/state";
|
|
22
|
-
import { USER_DEFAULT_AVATAR } from "./constant";
|
|
24
|
+
import { CUSTOM_MESSAGE_SRC, USER_DEFAULT_AVATAR } from "./constant";
|
|
23
25
|
import { vueVersion } from "./adapter-vue-web";
|
|
26
|
+
import { ITransferToHumanModel, ITransferToTaskFlowModel } from './interface';
|
|
24
27
|
|
|
25
28
|
interface IInitWithProfile {
|
|
26
29
|
SDKAppID: number,
|
|
@@ -119,6 +122,7 @@ export default class TUICustomerServer {
|
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
public unInit() {
|
|
125
|
+
this.isLoggedIn = false;
|
|
122
126
|
return TUIChatEngine.logout();
|
|
123
127
|
}
|
|
124
128
|
|
|
@@ -199,6 +203,14 @@ export default class TUICustomerServer {
|
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
|
|
206
|
+
public transferToTaskFlow(options: ITransferToTaskFlowModel) {
|
|
207
|
+
transferToTaskFlow(this.currentCustomerServiceID, options.taskFlowID, options.description);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public transferToHuman(options: ITransferToHumanModel) {
|
|
211
|
+
transferToHuman(this.currentCustomerServiceID, options.groupID, options.specificMemberList, options.description);
|
|
212
|
+
}
|
|
213
|
+
|
|
202
214
|
public onCall(method: string, params: any) {
|
|
203
215
|
Log.l(`TUICustomerServer.onCall method:${method} params:`, params);
|
|
204
216
|
if (method === TUIConstants.TUICustomerServicePlugin.SERVICE.METHOD.ACTIVE_CONVERSATION) {
|
|
@@ -218,6 +230,7 @@ export default class TUICustomerServer {
|
|
|
218
230
|
|
|
219
231
|
// 激活会话服务流
|
|
220
232
|
private activeServiceFlow(params: any) {
|
|
233
|
+
Log.i(`activeServiceFlow params: language:${params.robotLang} country:${params.country} timezone:${params.timezone}`)
|
|
221
234
|
TUIChatService.sendCustomMessage({
|
|
222
235
|
to: params.conversationID.slice(3),
|
|
223
236
|
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
|
@@ -225,9 +238,14 @@ export default class TUICustomerServer {
|
|
|
225
238
|
data: JSON.stringify({
|
|
226
239
|
src: '7',
|
|
227
240
|
customerServicePlugin: 0,
|
|
228
|
-
triggeredContent:
|
|
241
|
+
triggeredContent: {
|
|
242
|
+
language: params.robotLang,
|
|
243
|
+
country: params.country,
|
|
244
|
+
timezone: params.timezone,
|
|
245
|
+
}
|
|
229
246
|
}),
|
|
230
247
|
},
|
|
231
248
|
}, { onlineUserOnly: true });
|
|
249
|
+
TUIStore.update(StoreName.CUSTOM, "isInSession", true);
|
|
232
250
|
}
|
|
233
251
|
}
|
package/utils/index.ts
CHANGED
|
@@ -43,6 +43,12 @@ export const isThinkingMessage = (message: IMessageModel): boolean => {
|
|
|
43
43
|
return isCustomerMessage && customerServicePayload?.src === CUSTOM_MESSAGE_SRC.THINKING && customerServicePayload?.thinkingStatus === 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export const isTransferMessageWithoutDesc = (message: IMessageModel): boolean => {
|
|
47
|
+
const isCustomerMessage = message.type === TYPES.MSG_CUSTOM;
|
|
48
|
+
const customerServicePayload: customerServicePayloadType = JSONToObject(message?.payload?.data);
|
|
49
|
+
return isCustomerMessage && (customerServicePayload.src === CUSTOM_MESSAGE_SRC.TRANSFER_TO_TASK_FLOW || customerServicePayload.src === CUSTOM_MESSAGE_SRC.TRANSFER_TO_HUMAN) && !customerServicePayload.description;
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
export const isThinkingMessageOverTime = (message: IMessageModel): boolean => {
|
|
47
53
|
const messageTime = message.time * 1000;
|
|
48
54
|
const minute = 60 * 1000;
|
|
@@ -64,19 +70,6 @@ export const isMessageInvisible = (message: IMessageModel): boolean => {
|
|
|
64
70
|
return (isCustomerMessage && (isCustomerInvisible || isRobot || isMultiFormMessage)) || isGroupTipMessage;
|
|
65
71
|
};
|
|
66
72
|
|
|
67
|
-
export const isSupportedLang = (lang: string): boolean => {
|
|
68
|
-
return [
|
|
69
|
-
'zh', // Simplified Chinese中文简体:zh
|
|
70
|
-
'zh-TW', // Traditional Chinese中文繁体:zh-TW
|
|
71
|
-
'en', // English英语:en
|
|
72
|
-
'id', // Indonesian印度尼西亚语:id
|
|
73
|
-
'vi', // Vietnamese越南语:vi
|
|
74
|
-
'ja', // Japanese日语:ja
|
|
75
|
-
'fil', // Filipino菲律宾语:fil
|
|
76
|
-
'ru', // Russian俄语:ru
|
|
77
|
-
].indexOf(lang) !== -1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
73
|
// 如果用户选择 block cookies,此时访问 localStorage 浏览器会抛错
|
|
81
74
|
// Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document
|
|
82
75
|
// 通过 navigator.cookieEnabled 短路逻辑规避
|
package/utils/utils.ts
CHANGED
|
@@ -5,11 +5,12 @@ import TUIChatEngine, {
|
|
|
5
5
|
IMessageModel,
|
|
6
6
|
TUIUserService,
|
|
7
7
|
IConversationModel,
|
|
8
|
+
TUIChatService,
|
|
8
9
|
} from '@tencentcloud/chat-uikit-engine';
|
|
9
10
|
import Log from './logger';
|
|
10
11
|
import { isCustomerServiceMessage, JSONToObject } from './index';
|
|
11
12
|
import { CUSTOM_MESSAGE_SRC } from '../constant';
|
|
12
|
-
import { Marked
|
|
13
|
+
import { Marked } from 'marked';
|
|
13
14
|
|
|
14
15
|
export function deepCopy(data: any, hash = new WeakMap()) {
|
|
15
16
|
if (typeof data !== 'object' || data === null || data === undefined) {
|
|
@@ -138,7 +139,7 @@ export function calculateTimestamp(timestamp: number): string {
|
|
|
138
139
|
return `${formatNum(target.getHours())}:${formatNum(target.getMinutes())}`;
|
|
139
140
|
} else if (diff <= oneDay) {
|
|
140
141
|
// yesterday, display yesterday:hour:minute
|
|
141
|
-
return `${TUITranslateService.t('
|
|
142
|
+
return `${TUITranslateService.t('time.昨天')} ${formatNum(
|
|
142
143
|
target.getHours(),
|
|
143
144
|
)}:${formatNum(target.getMinutes())}`;
|
|
144
145
|
} else if (diff <= oneWeek - oneDay) {
|
|
@@ -153,7 +154,7 @@ export function calculateTimestamp(timestamp: number): string {
|
|
|
153
154
|
'星期六',
|
|
154
155
|
];
|
|
155
156
|
const weekday = weekdays[target.getDay()];
|
|
156
|
-
return `${TUITranslateService.t('
|
|
157
|
+
return `${TUITranslateService.t('time.' + weekday)} ${formatNum(
|
|
157
158
|
target.getHours(),
|
|
158
159
|
)}:${formatNum(target.getMinutes())}`;
|
|
159
160
|
} else if (target.getTime() >= thisYear) {
|
|
@@ -265,4 +266,44 @@ function parseQuoteMarkdown(content: string): string {
|
|
|
265
266
|
.replace(/\*\*|\*|_|`|#/g, '')
|
|
266
267
|
.replace(/<[^>]+>/g, '');
|
|
267
268
|
return result;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function transferToTaskFlow(conversationID: string, taskFlowID: number, description?: string) {
|
|
272
|
+
if (!taskFlowID) {
|
|
273
|
+
Log.w(`taskFlowID is required`);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
TUIChatService.sendCustomMessage({
|
|
277
|
+
to: conversationID,
|
|
278
|
+
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
|
279
|
+
payload: {
|
|
280
|
+
data: JSON.stringify({
|
|
281
|
+
src: CUSTOM_MESSAGE_SRC.TRANSFER_TO_TASK_FLOW,
|
|
282
|
+
customerServicePlugin: 0,
|
|
283
|
+
taskId: taskFlowID,
|
|
284
|
+
env: 'production',
|
|
285
|
+
description: description || '',
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
},{ onlineUserOnly: description ? false : true });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function transferToHuman(conversationID: string, groupID?: string, specificMemberList?: Array<string>, description?: string) {
|
|
292
|
+
if (!groupID && (!specificMemberList || specificMemberList.length === 0)) {
|
|
293
|
+
Log.w(`groupID or specificMemberList is required`);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
TUIChatService.sendCustomMessage({
|
|
297
|
+
to: conversationID,
|
|
298
|
+
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
|
299
|
+
payload: {
|
|
300
|
+
data: JSON.stringify({
|
|
301
|
+
src: CUSTOM_MESSAGE_SRC.TRANSFER_TO_HUMAN,
|
|
302
|
+
customerServicePlugin: 0,
|
|
303
|
+
groupId: groupID || 0,
|
|
304
|
+
specificMemberList: specificMemberList || [],
|
|
305
|
+
description: description || '',
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
},{ onlineUserOnly: description ? false : true });
|
|
268
309
|
}
|