@tencentcloud/ai-desk-customer-vue 0.3.0 → 1.0.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +5 -3
  2. package/README.md +153 -50
  3. package/assets/loading_message.svg +1 -0
  4. package/components/CustomerServiceChat/chat-header/index-web.vue +2 -2
  5. package/components/CustomerServiceChat/index-web.vue +77 -11
  6. package/components/CustomerServiceChat/message-input/message-input-editor-web.vue +7 -1
  7. package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +2 -1
  8. package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +2 -1
  9. package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/index.vue +2 -1
  10. package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +3 -2
  11. package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +4 -3
  12. package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +2 -2
  13. package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +2 -2
  14. package/components/CustomerServiceChat/message-list/index-web.vue +16 -7
  15. package/components/CustomerServiceChat/message-list/message-elements/message-bubble-web.vue +19 -0
  16. package/components/CustomerServiceChat/message-list/message-elements/message-custom.vue +6 -2
  17. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/marked.ts +4 -0
  18. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-branch.vue +13 -4
  19. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/component-mobile/input-mobile.vue +4 -2
  20. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/component-mobile/radios-mobile.vue +4 -2
  21. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/component-pc/input-pc.vue +4 -2
  22. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/component-pc/radio-pc.vue +5 -3
  23. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/form-mobile.vue +6 -4
  24. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form/form-pc.vue +5 -3
  25. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-product-card.vue +21 -11
  26. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating/message-rating-number.vue +6 -6
  27. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating/message-rating-star.vue +14 -14
  28. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-robot-welcome.vue +2 -6
  29. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form/form-input.vue +6 -4
  30. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-stream.vue +51 -52
  31. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/styles/common.scss +1 -1
  32. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/type-writer.ts +189 -0
  33. package/components/CustomerServiceChat/message-list/message-elements/message-location.vue +2 -1
  34. package/components/CustomerServiceChat/message-list/message-elements/message-text.vue +1 -1
  35. package/components/CustomerServiceChat/message-list/message-elements/message-thinking.vue +59 -0
  36. package/components/CustomerServiceChat/message-list/message-tool/index-web.vue +1 -1
  37. package/components/CustomerServiceChat/message-list/message-tool/message-revoked.vue +1 -0
  38. package/components/CustomerServiceChat/message-list/scroll-button/index.vue +3 -1
  39. package/components/CustomerServiceChat/message-toolbar-button/index.vue +69 -0
  40. package/components/common/Dialog/index.vue +2 -2
  41. package/components/common/ImagePreviewer/index-web.vue +2 -2
  42. package/constant.ts +15 -0
  43. package/excluded-list.txt +0 -1
  44. package/index.ts +1 -6
  45. package/interface.ts +8 -0
  46. package/locales/en/TUIChat.ts +158 -0
  47. package/locales/en/aidesk.ts +16 -0
  48. package/locales/en/component.ts +6 -0
  49. package/locales/en/index.ts +26 -0
  50. package/locales/en/time.ts +37 -0
  51. package/locales/fil/TUIChat.ts +160 -0
  52. package/locales/fil/aidesk.ts +16 -0
  53. package/locales/fil/component.ts +6 -0
  54. package/locales/fil/index.ts +25 -0
  55. package/locales/fil/time.ts +18 -0
  56. package/locales/id/TUIChat.ts +164 -0
  57. package/locales/id/aidesk.ts +16 -0
  58. package/locales/id/component.ts +6 -0
  59. package/locales/id/index.ts +26 -0
  60. package/locales/id/time.ts +19 -0
  61. package/locales/index.ts +30 -0
  62. package/locales/ja/TUIChat.ts +165 -0
  63. package/locales/ja/aidesk.ts +16 -0
  64. package/locales/ja/component.ts +6 -0
  65. package/locales/ja/index.ts +26 -0
  66. package/locales/ja/time.ts +18 -0
  67. package/locales/ms/TUIChat.ts +165 -0
  68. package/locales/ms/aidesk.ts +16 -0
  69. package/locales/ms/component.ts +6 -0
  70. package/locales/ms/index.ts +26 -0
  71. package/locales/ms/time.ts +18 -0
  72. package/locales/ru/TUIChat.ts +158 -0
  73. package/locales/ru/aidesk.ts +16 -0
  74. package/locales/ru/component.ts +7 -0
  75. package/locales/ru/index.ts +26 -0
  76. package/locales/ru/time.ts +30 -0
  77. package/locales/th/TUIChat.ts +165 -0
  78. package/locales/th/aidesk.ts +16 -0
  79. package/locales/th/component.ts +6 -0
  80. package/locales/th/index.ts +26 -0
  81. package/locales/th/time.ts +18 -0
  82. package/locales/vi/TUIChat.ts +156 -0
  83. package/locales/vi/aidesk.ts +16 -0
  84. package/locales/vi/component.ts +6 -0
  85. package/locales/vi/index.ts +26 -0
  86. package/locales/vi/time.ts +18 -0
  87. package/locales/zh_cn/TUIChat.ts +158 -0
  88. package/locales/zh_cn/aidesk.ts +17 -0
  89. package/locales/zh_cn/component.ts +6 -0
  90. package/locales/zh_cn/index.ts +26 -0
  91. package/locales/zh_cn/time.ts +37 -0
  92. package/locales/zh_tw/TUIChat.ts +158 -0
  93. package/locales/zh_tw/aidesk.ts +16 -0
  94. package/locales/zh_tw/component.ts +6 -0
  95. package/locales/zh_tw/index.ts +26 -0
  96. package/locales/zh_tw/time.ts +37 -0
  97. package/package.json +2 -2
  98. package/server.ts +36 -9
  99. package/utils/index.ts +42 -17
  100. package/utils/utils.ts +4 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
- ## [1.0.0] (2024-12-25)
1
+ ## [1.0.0] (2025-4-10)
2
2
 
3
3
  ### Features
4
-
5
- - web 客服插件首发
4
+ - 国际化语言,支持简体中文、繁体中文、英语、日语、马来西亚语、印尼语、越南语、泰语、俄语、菲律宾语。
5
+ - 登录失败和账号被踢出增加提示。
6
+ - 优化样式和移动端 H5 适配。
7
+ - 优化交互体验。
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 效果展示
6
6
 
7
- ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027960326/d0637be3f42811efa8355254001c06ec.png)
7
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027960326/2f5444f4095b11f0990f52540099c741.png)
8
8
 
9
9
 
10
10
  ## 开发环境要求
@@ -29,14 +29,14 @@
29
29
 
30
30
  【vue-cli】
31
31
 
32
- > **注意:**
33
- >
34
-
35
- > 请您务必保证您的** @vue/cli 版本在 5.0.0** 以上,您可使用以下示例代码升级您的 @vue/cli 版本至 v5.0.8。
36
- >
32
+ > **说明:**
33
+ >
34
+ > 1. 请确保您的`@vue/cli`版本在 **5.0.0** 以上,您可使用以下示例代码升级`@vue/cli`版本至 v5.0.8。
35
+ > 2. 如果您的项目由较低版本的`@vue/cli`创建,集成 UIKit 后运行项目如有报错,请查阅[常见问题](https://cloud.tencent.com/document/product/269/102783#04a7d474-e04a-4765-910f-9bbfe4e3ced9)解决。
37
36
 
38
37
 
39
38
  使用 vue-cli 方式创建项目, 配置 Vue2 / Vue3 + TypeScript + sass。
39
+
40
40
  如果您尚未安装 vue-cli 或者 vue-cli 版本低于 5.0.0 ,可以在 terminal 或 cmd 中采用如下方式进行安装:
41
41
 
42
42
 
@@ -79,10 +79,10 @@ npm i @vue/composition-api unplugin-vue2-script-setup vue@2.6.14 vue-template-co
79
79
  【vite】
80
80
 
81
81
  > **说明:**
82
- >
82
+ >
83
83
 
84
84
  > Vite 需要[**Node.js**](https://nodejs.org/en/)** 版本 18+,20+。**当您的包管理器发出警告时,请注意升级您的 Node 版本,详情请参考 [vite 官网](https://cn.vitejs.dev/guide/)。
85
- >
85
+ >
86
86
 
87
87
 
88
88
  使用 vite 方式创建项目,按照下图选项配置 Vue + TypeScript 。
@@ -134,13 +134,13 @@ echo. > src\style.css
134
134
 
135
135
  【shell】
136
136
  ``` bash
137
- npm i @tencentcloud/ai-desk-customer-vue
137
+ npm i @tencentcloud/ai-desk-customer-vue@latest
138
138
  ```
139
139
 
140
140
 
141
141
  【shell】
142
142
  ``` bash
143
- mkdir -p ./src/ai-desk-customer-vue && rsync -av --exclude={'node_modules','package.json','excluded-list.txt','srcipt'} ./node_modules/@tencentcloud/ai-desk-customer-vue/ ./src/ai-desk-customer-vue
143
+ mkdir -p ./src/ai-desk-customer-vue && rsync -av --exclude={'node_modules','excluded-list.txt'} ./node_modules/@tencentcloud/ai-desk-customer-vue/ ./src/ai-desk-customer-vue
144
144
  ```
145
145
 
146
146
  【Windows 端】
@@ -148,7 +148,7 @@ mkdir -p ./src/ai-desk-customer-vue && rsync -av --exclude={'node_modules','pack
148
148
 
149
149
  【shell】
150
150
  ``` bash
151
- npm i @tencentcloud/ai-desk-customer-vue
151
+ npm i @tencentcloud/ai-desk-customer-vue@latest
152
152
  ```
153
153
 
154
154
 
@@ -164,10 +164,10 @@ xcopy .\node_modules\@tencentcloud\ai-desk-customer-vue .\src\ai-desk-customer-v
164
164
  ##### 例如:在 App.vue 页面中实现以下代码,即可快速搭建客服咨询界面(以下示例代码同时支持 Web 端与 H5 端):
165
165
 
166
166
  > **说明:**
167
- >
167
+ >
168
168
 
169
169
  > 以下示例代码使用了 setup 语法,如果您的项目没有使用 setup 语法,请按照 Vue3/Vue2 的标准方式注册组件。
170
- >
170
+ >
171
171
 
172
172
 
173
173
 
@@ -176,14 +176,45 @@ xcopy .\node_modules\@tencentcloud\ai-desk-customer-vue .\src\ai-desk-customer-v
176
176
  ``` javascript
177
177
  <template>
178
178
  <CustomerServiceChat
179
- :SDKAppID=""
180
- userID=""
181
- userSig=""
182
- :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
183
- />
179
+ :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
180
+ :toolbarButtonList="toolbarButtonList"
181
+ />
184
182
  </template>
185
183
  <script setup lang="ts">
186
- import { CustomerServiceChat } from './ai-desk-customer-vue';
184
+ import TUICustomerServer from './ai-desk-customer-vue/server';
185
+ import { CustomerServiceChat } from './ai-desk-customer-vue';
186
+ import { onMounted, ref } from "vue";
187
+ import TUIChatEngine, { TUIChatService } from "@tencentcloud/chat-uikit-engine";
188
+
189
+ // 配置工具栏 button list,例如【转人工】
190
+ const toolbarButtonList = ref([
191
+ {
192
+ title: '转人工',
193
+ renderCondition: () => {
194
+ // return true 即渲染,您可以在这里控制 button 显隐时机
195
+ return true;
196
+ },
197
+ clickEvent: () => {
198
+ // 点击 button 后的回调
199
+ if (TUIChatEngine.isReady()) {
200
+ TUIChatService.sendTextMessage({
201
+ to: '@customer_service_account',
202
+ conversationType: TUIChatEngine.TYPES.CONV_C2C,
203
+ payload: {
204
+ text: '转人工'
205
+ }
206
+ });
207
+ }
208
+ }
209
+ }
210
+ ]);
211
+
212
+ onMounted(() => {
213
+ const SDKAppID = 0; // Your SDKAppID,即开通了智能客服 Desk 的应用 ID
214
+ const userID = ''; // Your userID,可复用您 app 的账号体系,或随机生成
215
+ const userSig = ''; // Your userSig,接入阶段可控制台生成,生产阶段请务必由服务端生成
216
+ TUICustomerServer.init(SDKAppID, userID, userSig);
217
+ });
187
218
  </script>
188
219
  <style scoped>
189
220
  </style>
@@ -194,20 +225,50 @@ xcopy .\node_modules\@tencentcloud\ai-desk-customer-vue .\src\ai-desk-customer-v
194
225
  <template>
195
226
  <div id="app">
196
227
  <CustomerServiceChat
197
- :SDKAppID=""
198
- userID=""
199
- userSig=""
200
- :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
228
+ :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
229
+ :toolbarButtonList="toolbarButtonList"
201
230
  />
202
231
  </div>
203
232
  </template>
204
233
  <script lang="ts" setup>
205
- import { CustomerServiceChat } from "./ai-desk-customer-vue";
234
+ import TUICustomerServer from './ai-desk-customer-vue/server';
235
+ import { CustomerServiceChat } from './ai-desk-customer-vue';
236
+ import vue from './ai-desk-customer-vue/adapter-vue';
237
+ import TUIChatEngine, { TUIChatService } from "@tencentcloud/chat-uikit-engine";
238
+
239
+ const { ref, onMounted } = vue;
240
+
241
+ // 配置工具栏 button list,例如【转人工】
242
+ const toolbarButtonList = ref([
243
+ {
244
+ title: '转人工',
245
+ renderCondition: () => {
246
+ // return true 即渲染,您可以在这里控制 button 显隐时机
247
+ return true;
248
+ },
249
+ clickEvent: () => {
250
+ // 点击 button 后的回调
251
+ if (TUIChatEngine.isReady()) {
252
+ TUIChatService.sendTextMessage({
253
+ to: '@customer_service_account',
254
+ conversationType: TUIChatEngine.TYPES.CONV_C2C,
255
+ payload: {
256
+ text: '转人工'
257
+ }
258
+ });
259
+ }
260
+ }
261
+ }
262
+ ]);
263
+
264
+ onMounted(() => {
265
+ const SDKAppID = 0; // Your SDKAppID
266
+ const userID = ''; // Your userID
267
+ const userSig = ''; // Your userSig
268
+ TUICustomerServer.init(SDKAppID, userID, userSig);
269
+ });
206
270
  </script>
207
271
  <style lang="scss">
208
- body {
209
- margin: 0;
210
- }
211
272
  </style>
212
273
  ```
213
274
 
@@ -216,23 +277,53 @@ body {
216
277
  <template>
217
278
  <div id="app">
218
279
  <CustomerServiceChat
219
- :SDKAppID=""
220
- userID=""
221
- userSig=""
222
- :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
280
+ :style="{ width: '600px', height: '80vh', margin: '10px auto', boxShadow: '0 11px 20px #ccc' }"
281
+ :toolbarButtonList="toolbarButtonList"
223
282
  />
224
283
  </div>
225
284
  </template>
226
285
  <script lang="ts" setup>
227
- import { CustomerServiceChat } from "./ai-desk-customer-vue";
286
+ import TUICustomerServer from './ai-desk-customer-vue/server';
287
+ import { CustomerServiceChat } from './ai-desk-customer-vue';
288
+ import vue from './ai-desk-customer-vue/adapter-vue';
289
+ import TUIChatEngine, { TUIChatService } from "@tencentcloud/chat-uikit-engine";
290
+
291
+ const { ref, onMounted } = vue;
292
+
293
+ // 配置工具栏 button list,例如【转人工】
294
+ const toolbarButtonList = ref([
295
+ {
296
+ title: '转人工',
297
+ renderCondition: () => {
298
+ // return true 即渲染,您可以在这里控制 button 显隐时机
299
+ return true;
300
+ },
301
+ clickEvent: () => {
302
+ // 点击 button 后的回调
303
+ if (TUIChatEngine.isReady()) {
304
+ TUIChatService.sendTextMessage({
305
+ to: '@customer_service_account',
306
+ conversationType: TUIChatEngine.TYPES.CONV_C2C,
307
+ payload: {
308
+ text: '转人工'
309
+ }
310
+ });
311
+ }
312
+ }
313
+ }
314
+ ]);
315
+
316
+ onMounted(() => {
317
+ const SDKAppID = 0; // Your SDKAppID
318
+ const userID = ''; // Your userID
319
+ const userSig = ''; // Your userSig
320
+ TUICustomerServer.init(SDKAppID, userID, userSig);
321
+ });
228
322
  </script>
229
323
  <style lang="scss">
230
- body {
231
- margin: 0;
232
- }
233
324
  </style>
234
325
  ```
235
- 1. 在 `main.ts/mian.js `中引入 VueCompositionAPI。
326
+ 1. 在 `main.ts/main.js `中引入 VueCompositionAPI。
236
327
 
237
328
  ``` javascript
238
329
  import VueCompositionAPI from "@vue/composition-api";
@@ -268,18 +359,18 @@ export * from "@vue/composition-api";
268
359
 
269
360
  ### 步骤4: 获取 SDKAppID 、userID 、 userSig
270
361
 
271
- 设置` App.vue `中 CustomerServiceChat 组件的 props 属性 SDKAppIDuserIDuserSig 。
272
- - SDKAppID 信息,可通过 [即时通信 IM 控制台](https://console.cloud.tencent.com/im) 获取:
362
+ 设置`App.vue`中的 `SDKAppID`、`userID`、`userSig`
363
+ - SDKAppID 信息,可在 [即时通信 IM 控制台](https://console.cloud.tencent.com/im) 单击**应用管理** > **创建新应用**,并选择**客服服务 Desk** > **智能客服**, [开通智能客服](https://console.cloud.tencent.com/im/ai-desk) 后获取。
273
364
 
274
- ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027984635/98fbf9465ebf11ef8f105254002693fd.png)
365
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100031390357/7ac165770ae411f088bd525400e889b2.png)
275
366
 
276
- - userID 信息,可通过单击 [ 即时通信 IM 控制台 -【账号管理】](https://console.cloud.tencent.com/im/account-management),切换至目标应用所在账号,即可创建账号并获取 userID。
367
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100031390357/c5699ccc0ae411f0b3015254001c06ec.png)
277
368
 
278
- ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027984635/98fee9bb5ebf11efb927525400fdb830.png)
369
+ - userID 信息,可本地生成一个随机的字符串,例如 test-1234。
279
370
 
280
- - userSig 信息,可单击 [ 即时通信 IM 控制台 > 开发工具 > UserSig生成&校验](https://console.cloud.tencent.com/im/tool-usersig),填写创建的 userID,即可生成 userSig。
371
+ - userSig 信息,可单击 [即时通信 IM 控制台 > UserSig生成校验](https://console.cloud.tencent.com/im/tool-usersig),填写创建的 userID,即可生成 userSig。
281
372
 
282
- ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027984635/9907771d5ebf11efb66652540055f650.png)
373
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100031390357/dbfdb4ca0ae411f088bd525400e889b2.png)
283
374
 
284
375
 
285
376
  ### 步骤5:启动项目,发起您的第一条客服咨询
@@ -291,15 +382,15 @@ export * from "@vue/composition-api";
291
382
  【vue-cli】
292
383
 
293
384
  > **说明:**
294
- >
385
+ >
295
386
 
296
387
  > 由于 vue-cli 默认开启 webpack 全局 overlay 报错信息提示,为了您有更好的体验,**建议您关闭全局 overlay 报错提示。**
297
- >
388
+ >
298
389
 
299
390
  > 在 vue.config.js 中添加以下代码
300
- >
391
+ >
301
392
 
302
- >
393
+ >
303
394
 
304
395
  【webpack4及以上】
305
396
  > `module.exports = defineConfig({`
@@ -316,10 +407,10 @@ export * from "@vue/composition-api";
316
407
  > ` overlay: false,`
317
408
  > ` },`
318
409
  > `};`
319
- >
410
+ >
320
411
 
321
412
  > 在 tsconfig.json 中关闭 ai-desk-customer-vue 的ts检测。
322
- >
413
+ >
323
414
  > `{`
324
415
  > ` "exclude": [`
325
416
  > ` "node_modules",`
@@ -374,6 +465,18 @@ vue add typescript
374
465
  npm install -D typescript
375
466
  ```
376
467
 
468
+ ##### 运行报错:Uncaught TypeError: marked__WEBPACK_IMPORTED_MODULE_0_ Marked is not a constructor
469
+
470
+ 如果您运行过程中出现如下错误,说明您当前 Vue CLI 构建的项目环境版本较低,需要降低 uikit 中使用的 marked 版本至 5.1.2。
471
+
472
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027960326/104ee490098211f0990f52540099c741.png)
473
+
474
+
475
+ 请在您项目的 根目录 使用以下脚本降低 marked 版本:
476
+ ``` bash
477
+ npm i marked@5.1.2 --legacy-peer-deps
478
+ ```
479
+
377
480
  ##### 编译报错 node_modules/marked/lib/marked.esm.js: Class private methods are not enabled.
378
481
 
379
482
  如果您运行过程中出现如下错误,说明您当前使用的 marked 版本过低,请升级 marked 版本至 6.0.0。
@@ -388,4 +491,4 @@ npm i marked@6.0.0 --legacy-peer-deps
388
491
 
389
492
  ## 交流与反馈
390
493
 
391
- [点此进入 IM 社群](https://zhiliao.qq.com/s/c5GY7HIM62CK),享有专业工程师的支持,解决您的难题。
494
+ [点此进入 IM 社群](https://zhiliao.qq.com/s/c5GY7HIM62CK),享有专业工程师的支持,解决您的难题。
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#CCCCCC"><path d="M480.2-240Q380-240 310-309.8q-70-69.8-70-170T309.8-650q69.8-70 170-70T650-650.2q70 69.8 70 170T650.2-310q-69.8 70-170 70Z"/></svg>
@@ -11,7 +11,7 @@
11
11
  <div class="chat-header-container">
12
12
  <Icon v-if="!isPC" style="width:32px;" :file="customerAvatarMobile" />
13
13
  <div :class="['chat-header-content', !isPC && 'chat-header-h5-content']">
14
- {{ isPC? currentConversationName :'Hi,我是'+ currentConversationName }}
14
+ {{ isPC? currentConversationName : TUITranslateService.t('AIDesk.Hi,我是') + currentConversationName }}
15
15
  </div>
16
16
  </div>
17
17
  </div>
@@ -31,7 +31,7 @@ import { isPC } from '../../../utils/env';
31
31
  const { ref, onMounted, onUnmounted } = vue;
32
32
 
33
33
  interface IProps {
34
- canCloseChat: boolean;
34
+ canCloseChat?: boolean;
35
35
  }
36
36
 
37
37
  const emits = defineEmits(['closeChat']);
@@ -18,6 +18,9 @@
18
18
  @handleEditor="handleEditor"
19
19
  @closeInputToolBar="() => changeToolbarDisplayType('none')"
20
20
  />
21
+ <MessageToolbarButton
22
+ :toolbarButtonList="props.toolbarButtonList"
23
+ />
21
24
  <MessageInputToolbar
22
25
  v-if="isInputToolbarShow"
23
26
  :class="[
@@ -35,8 +38,8 @@
35
38
  'tui-chat-message-input',
36
39
  !isPC && 'tui-chat-h5-message-input'
37
40
  ]"
38
- :isMuted="false"
39
- :muteText="TUITranslateService.t('TUIChat.您已被管理员禁言')"
41
+ :isMuted="isMuted"
42
+ :muteText="muteText"
40
43
  :placeholder="TUITranslateService.t('TUIChat.请输入消息')"
41
44
  :inputToolbarDisplayType="inputToolbarDisplayType"
42
45
  @changeToolbarDisplayType="changeToolbarDisplayType"
@@ -73,25 +76,28 @@
73
76
  <script lang="ts" setup>
74
77
  import vue from '../../adapter-vue';
75
78
  import {
76
- TUITranslateService,
79
+ IMessageModel,
80
+ StoreName,
81
+ TUIChatEngine,
77
82
  TUIConversationService,
78
83
  TUIStore,
79
- StoreName,
80
- IMessageModel,
81
- TUIChatEngine
84
+ TUITranslateService
82
85
  } from '@tencentcloud/chat-uikit-engine';
83
- import TUICore, { TUIConstants, TUILogin } from '@tencentcloud/tui-core';
86
+ import TUICore, {TUIConstants, TUILogin} from '@tencentcloud/tui-core';
84
87
  import ChatHeader from './chat-header/index-web.vue';
85
88
  import MessageList from './message-list/index-web.vue';
86
89
  import MessageInput from './message-input/index-web.vue';
87
90
  import MessageInputToolbar from './message-input-toolbar/index-web.vue';
88
91
  import EmojiDialog from './message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue';
89
- import { isPC, isH5} from '../../utils/env';
90
- import { ToolbarDisplayType } from '../../interface';
91
- import { isSupportedLang } from '../../utils/';
92
+ import {isH5, isPC} from '../../utils/env';
93
+ import {ToolbarButtonModel, ToolbarDisplayType} from '../../interface';
94
+ import {isSupportedLang} from '../../utils/';
92
95
  import Log from '../../utils/logger';
96
+ import MessageToolbarButton from './message-toolbar-button/index.vue';
97
+ import TUILocales from '../../locales';
98
+ import { Toast, TOAST_TYPE } from '../common/Toast/index-web';
93
99
 
94
- const { ref, onMounted, onUnmounted, computed } = vue;
100
+ const { ref, onMounted, onUnmounted, computed, nextTick } = vue;
95
101
 
96
102
  interface IProps {
97
103
  canCloseChat?: boolean;
@@ -99,6 +105,8 @@ interface IProps {
99
105
  userID?:string;
100
106
  userSig?:string;
101
107
  robotLang?:string;
108
+ userLang?:string;
109
+ toolbarButtonList?:ToolbarButtonModel[];
102
110
  }
103
111
 
104
112
  const emits = defineEmits(['closeChat']);
@@ -106,15 +114,20 @@ const emits = defineEmits(['closeChat']);
106
114
  const currentConversationID = ref();
107
115
  const inputToolbarDisplayType = ref<ToolbarDisplayType>('none');
108
116
  const messageInputRef = ref();
117
+ const isMuted = ref(false);
118
+ const muteText = ref('');
109
119
  const messageListRef = ref<InstanceType<typeof MessageList>>();
110
120
  const emojiOpen = ref(false);
111
121
  const toolShowH5 = ref(false);
122
+ const langauges = Object.keys(TUILocales);
112
123
  const props = withDefaults(defineProps<IProps>(), {
113
124
  canCloseChat: true,
114
125
  SDKAppID: 0,
115
126
  userID: '',
116
127
  userSig: '',
117
128
  robotLang: '',
129
+ userLang:'',
130
+ toolbarButtonList:() => [] as ToolbarButtonModel[]
118
131
  });
119
132
 
120
133
  const loginCustomerUIKit = () => {
@@ -129,10 +142,49 @@ const loginCustomerUIKit = () => {
129
142
  TUIConversationService.switchConversation(conversationID);
130
143
  TUIChatEngine.chat.callExperimentalAPI('isFeatureEnabledForStat', Math.pow(2, 42));
131
144
  }).catch((error) => {
145
+ Toast({
146
+ message: TUITranslateService.t('TUIChat.登录失败'),
147
+ type: TOAST_TYPE.ERROR,
148
+ duration: 30000,
149
+ });
132
150
  console.log(error);
133
151
  })
134
152
  }
135
153
 
154
+ const convertLanguageToLowercase = (language) => {
155
+ let lowercase = language.toLowerCase();
156
+ if (lowercase === 'zh-cn' || lowercase === 'zh_cn') {
157
+ lowercase = 'zh';
158
+ } else if (lowercase === 'zh-tw' || lowercase === 'zh-hk') {
159
+ lowercase = 'zh_tw';
160
+ }
161
+ return lowercase;
162
+ }
163
+
164
+ const initLanguage = () => {
165
+ Log.i(`initLanguage ${props.userLang}`);
166
+ TUITranslateService.provideLanguages({ ...TUILocales });
167
+ TUITranslateService.useI18n();
168
+ let language;
169
+ if (props.userLang !== '') {
170
+ let userLang = convertLanguageToLowercase(props.userLang);
171
+ if (!langauges.includes(userLang)) {
172
+ Log.w(`userLang:${props.userLang} is not supported`);
173
+ language = 'en';
174
+ } else {
175
+ language = userLang;
176
+ }
177
+ } else {
178
+ let navigatorLang = convertLanguageToLowercase(navigator.language);
179
+ if (!langauges.includes(navigatorLang)) {
180
+ language = 'en';
181
+ } else {
182
+ language = navigatorLang;
183
+ }
184
+ }
185
+ TUITranslateService.changeLanguage(language);
186
+ }
187
+
136
188
  try {
137
189
  const userContext = TUILogin.getContext();
138
190
  if(userContext.userID == '' && props.SDKAppID!==0 && props.userID!=='' && props.userSig!==''){
@@ -141,6 +193,7 @@ try {
141
193
  Log.w(`robotLang:${props.robotLang} is not supported`);
142
194
  }
143
195
  }
196
+ initLanguage();
144
197
  } catch (e) {
145
198
  console.log(e)
146
199
  }
@@ -149,12 +202,18 @@ onMounted(() => {
149
202
  TUIStore.watch(StoreName.CONV, {
150
203
  currentConversationID: onCurrentConversationIDUpdate,
151
204
  });
205
+ TUIStore.watch(StoreName.USER, {
206
+ kickedOut: onKickedOut
207
+ });
152
208
  });
153
209
 
154
210
  onUnmounted(() => {
155
211
  TUIStore.unwatch(StoreName.CONV, {
156
212
  currentConversationID: onCurrentConversationIDUpdate,
157
213
  });
214
+ TUIStore.unwatch(StoreName.USER, {
215
+ kickedOut: onKickedOut
216
+ });
158
217
  });
159
218
 
160
219
  const isInputToolbarShow = computed<boolean>(() => {
@@ -205,6 +264,13 @@ function scrollToLatestMessage() {
205
264
  messageListRef.value?.scrollToLatestMessage();
206
265
  }
207
266
 
267
+ function onKickedOut(type: string) {
268
+ if (type) {
269
+ isMuted.value = true;
270
+ muteText.value = TUITranslateService.t('TUIChat.账号被强制下线');
271
+ }
272
+ }
273
+
208
274
  function onCurrentConversationIDUpdate(conversationID: string) {
209
275
  if (!conversationID) {
210
276
  return;
@@ -759,7 +759,6 @@ defineExpose({
759
759
  overflow: hidden;
760
760
 
761
761
  .message-input-editor-area {
762
- overflow: auto;
763
762
  user-select: text;
764
763
  hyphens: auto;
765
764
  word-break: keep-all;
@@ -878,4 +877,11 @@ defineExpose({
878
877
  pointer-events: none;
879
878
  }
880
879
  }
880
+
881
+ .message-input-mute {
882
+ color: #721c24;
883
+ background-color: #f8d7da;
884
+ border-color: #f5c6cb;
885
+ text-align: center;
886
+ }
881
887
  </style>
@@ -17,7 +17,7 @@
17
17
  </ul>
18
18
  <div class="sendButtonContainer">
19
19
  <div class="sendButton" @click="sendMessage">
20
- 发送
20
+ {{ TUITranslateService.t("发送") }}
21
21
  </div>
22
22
  </div>
23
23
  </div>
@@ -32,6 +32,7 @@ import {
32
32
  TUIStore,
33
33
  StoreName,
34
34
  IConversationModel,
35
+ TUITranslateService,
35
36
  SendMessageParams,
36
37
  } from '@tencentcloud/chat-uikit-engine';
37
38
  import {
@@ -61,7 +61,7 @@
61
61
  class="send-btn"
62
62
  @click="sendMessage"
63
63
  >
64
- 发送
64
+ {{ TUITranslateService.t("发送") }}
65
65
  </li>
66
66
  </ul>
67
67
  </div>
@@ -74,6 +74,7 @@ import {
74
74
  StoreName,
75
75
  IConversationModel,
76
76
  SendMessageParams,
77
+ TUITranslateService
77
78
  } from '@tencentcloud/chat-uikit-engine';
78
79
  import Icon from '../../../common/Icon.vue';
79
80
  import faceIcon from '../../../../assets/face.png';
@@ -2,7 +2,7 @@
2
2
  <ToolbarItemContainer
3
3
  ref="container"
4
4
  :iconFile="faceIcon"
5
- title="表情"
5
+ :title="TUITranslateService.t('表情')"
6
6
  @onDialogShow="onDialogShow"
7
7
  @onDialogClose="onDialogClose"
8
8
  :isH5EmojiShow="props.isH5EmojiShow"
@@ -20,6 +20,7 @@ import {
20
20
  TUIStore,
21
21
  StoreName,
22
22
  IConversationModel,
23
+ TUITranslateService
23
24
  } from '@tencentcloud/chat-uikit-engine';
24
25
  import vue from '../../../../adapter-vue';
25
26
  import faceIcon from '../../../../assets/face.png';
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <ToolbarItemContainer
3
3
  :iconFile="isH5?fileIconH5:fileIcon"
4
- title="文件"
4
+ :title="TUITranslateService.t('文件')"
5
5
  iconWidth='21px'
6
6
  iconHeight='18px'
7
7
  :needDialog="false"
@@ -10,7 +10,7 @@
10
10
  <div :class="['file-upload', !isPC && 'file-upload-h5']">
11
11
  <input
12
12
  ref="inputRef"
13
- title="文件"
13
+ :title="TUITranslateService.t('文件')"
14
14
  type="file"
15
15
  data-type="file"
16
16
  accept="*"
@@ -27,6 +27,7 @@ import {
27
27
  IConversationModel,
28
28
  SendMessageParams,
29
29
  SendMessageOptions,
30
+ TUITranslateService
30
31
  } from '@tencentcloud/chat-uikit-engine';
31
32
  import vue from '../../../../adapter-vue';
32
33
  import ToolbarItemContainer from '../toolbar-item-container/index.vue';
@@ -13,7 +13,7 @@
13
13
  >
14
14
  <input
15
15
  ref="inputRef"
16
- title="图片"
16
+ :title="TUITranslateService.t('图片')"
17
17
  type="file"
18
18
  accept="image/gif,image/jpeg,image/jpg,image/png,image/bmp,image/webp,video/mov,video/mp4"
19
19
  @change="sendImageInWeb"
@@ -29,6 +29,7 @@ import {
29
29
  IConversationModel,
30
30
  SendMessageParams,
31
31
  SendMessageOptions,
32
+ TUITranslateService
32
33
  } from '@tencentcloud/chat-uikit-engine';
33
34
  import { TUIGlobal } from '@tencentcloud/universal-api';
34
35
  import vue from '../../../../adapter-vue';
@@ -58,11 +59,11 @@ const currentConversation = ref<IConversationModel>();
58
59
  const IMAGE_TOOLBAR_SHOW_MAP = {
59
60
  web_album: {
60
61
  icon: imageIcon,
61
- title: '图片',
62
+ title: TUITranslateService.t("图片"),
62
63
  },
63
64
  uni_album: {
64
65
  icon: imageUniIcon,
65
- title: '图片',
66
+ title: TUITranslateService.t("图片"),
66
67
  }
67
68
  };
68
69