@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
@@ -0,0 +1,17 @@
1
+ const AIDesk = {
2
+ "结束人工会话": "结束会话",
3
+ "转人工服务": "转人工服务",
4
+ "跳转": "跳转",
5
+ "立即填写": "立即填写",
6
+ "已提交": "已提交",
7
+ "提交": "提交",
8
+ "查看内容": "查看内容",
9
+ "请填写必填项": "请填写必填项",
10
+ "Hi,我是": "Hi,我是",
11
+ "请输入内容": "请输入内容",
12
+ "如果满意请给好评哦~": "如果满意请给好评哦~",
13
+ "请对本次服务进行评价": "请对本次服务进行评价",
14
+ "提交评价": "提交评价"
15
+
16
+ }
17
+ export default AIDesk;
@@ -0,0 +1,6 @@
1
+ const Component = {
2
+ "图片 url 不存在": "图片 url 不存在",
3
+ "暂不支持下载此类型图片": "暂不支持下载此类型图片",
4
+ }
5
+
6
+ export default Component;
@@ -0,0 +1,26 @@
1
+ import TUIChat from './TUIChat';
2
+ import Component from './component';
3
+ import Time from './time';
4
+ import AIDesk from './aidesk';
5
+
6
+ const messages = {
7
+ zh: {
8
+ "取消": '取消',
9
+ "确定": '确定',
10
+ "发送": '发送',
11
+ "系统通知": '系统通知',
12
+ "关闭": '关闭',
13
+ "图片": '图片',
14
+ "文件": '文件',
15
+ "表情": '表情',
16
+ "视频": '视频',
17
+ "录制": '录制',
18
+ "拍照": '拍照',
19
+ TUIChat,
20
+ Component,
21
+ Time,
22
+ AIDesk,
23
+ },
24
+ };
25
+
26
+ export default messages;
@@ -0,0 +1,37 @@
1
+ const Time = {
2
+ "周": "周",
3
+ "天": "天",
4
+ "小时": "小时",
5
+ "分钟": "分钟",
6
+ "刚刚": "刚刚",
7
+ "前": "前",
8
+ "昨天": "昨天",
9
+ "星期一": "星期一",
10
+ "星期二": "星期二",
11
+ "星期三": "星期三",
12
+ "星期四": "星期四",
13
+ "星期五": "星期五",
14
+ "星期六": "星期六",
15
+ "星期日": "星期日",
16
+ "一月": "一月",
17
+ "二月": "二月",
18
+ "三月": "三月",
19
+ "四月": "四月",
20
+ "五月": "五月",
21
+ "六月": "六月",
22
+ "七月": "七月",
23
+ "八月": "八月",
24
+ "九月": "九月",
25
+ "十月": "十月",
26
+ "十一月": "十一月",
27
+ "十二月": "十二月",
28
+ "一": "一",
29
+ "二": "二",
30
+ "三": "三",
31
+ "四": "四",
32
+ "五": "五",
33
+ "六": "六",
34
+ "日": "日",
35
+ }
36
+
37
+ export default Time;
@@ -0,0 +1,158 @@
1
+ const TUIChat = {
2
+ '按Enter发送,Ctrl+Enter换行': '按Enter發送,Ctrl+Enter換行',
3
+ '表情': '[表情]',
4
+ '查看更多': '查看更多',
5
+ '撤回': '撤回',
6
+ '撤回了一条消息': '撤回了一條消息',
7
+ '打开': '打開',
8
+ '单击下载': '單擊下載',
9
+ '下载':'下載',
10
+ '点此投诉': '點此投訴',
11
+ '点击处理': '點擊處理',
12
+ '对方正在输入': '對方正在輸入...',
13
+ '发起群视频': '發起群視頻',
14
+ '发起群语音': '發起群語音',
15
+ '发起通话': '發起通話',
16
+ '发送失败': '發送失敗',
17
+ '复制': '複製',
18
+ '复制成功': '文本複製成功',
19
+ '该消息不存在': '該消息不存在',
20
+ '关闭阅读状态': '關閉',
21
+ '管理员开启全员禁言': '管理員開啟全員禁言',
22
+ '欢迎使用TUICallKit': '歡迎使用騰訊雲音視頻通話組件TUICallKit',
23
+ '回到最新位置': '回到最新位置',
24
+ '回复': '回覆',
25
+ '回复详情': '回覆詳情',
26
+ '集成TUICallKit': '集成 TUICallKit',
27
+ '检测到您暂未集成TUICallKit,无法体验音视频通话功能': '檢測到您暫未集成TUICallKit,無法體驗音視頻通話功能。',
28
+ '结束群聊': '結束群聊',
29
+ '进行体验': '進行體驗。',
30
+ '经度': '經度',
31
+ '拒绝': '拒絕',
32
+ '拒绝通话': '拒絕通話',
33
+ '开通腾讯实时音视频服务': '開通騰訊實時音視頻服務',
34
+ '聊天记录': '[聊天記錄]',
35
+ '描述': '描述',
36
+ '内容包含敏感词汇': '內容包含敏感詞彙',
37
+ '您': '您',
38
+ '您当前购买使用的套餐包暂未开通此功能': '您當前購買使用的套餐包暫未開通此功能。',
39
+ '您当前购买使用的套餐包暂未开通群消息已读回执功能': '您當前購買使用的套餐包暫未開通【群消息已讀回執】功能,請升級至旗艦版進行體驗',
40
+ '您当前购买使用的套餐包暂未开通在线用户列表功能': '您當前購買使用的套餐包暫未開通【在線用戶列表】功能,請升級至旗艦版進行體驗',
41
+ '您已被管理员禁言': '您已被管理員禁言',
42
+ '您有': '您有',
43
+ '请点击': '請點擊',
44
+ '请输入消息': '請輸入消息',
45
+ '取消': '取消',
46
+ '取消通话': '取消通話',
47
+ '全部已读': '全部已讀',
48
+ '确定': '確定',
49
+ '确认重发该消息?': '確認重發該消息?',
50
+ '人关闭阅读状态': '人關閉閱讀狀態',
51
+ '人未读': '人未讀',
52
+ '人已读': '人已讀',
53
+ '删除': '刪除',
54
+ '涉及敏感内容': '涉及敏感內容',
55
+ '申请加入': '申請加入',
56
+ '视频': '[視頻]',
57
+ '视频通话': '視頻通話',
58
+ '条回复': '條回覆',
59
+ '条入群申请': '條入群申請',
60
+ '条新消息': '條新消息',
61
+ '通话时长': '通話時長',
62
+ '同意': '同意',
63
+ '图片': '[圖片]',
64
+ '图片消息失败,无效的图片格式': '圖片消息失敗,無效的圖片格式',
65
+ '纬度': '緯度',
66
+ '未读': '未讀',
67
+ '位置': '[位置]',
68
+ '文件': '[文件]',
69
+ '文件不存在,请检查文件路径是否正确': '文件不存在,請檢查文件路徑是否正確',
70
+ '文件大小超出了限制,如果上传文件,最大限制是100MB': '文件大小超出了限制,如果上傳文件,最大限制是100MB',
71
+ '文件消息失败,禁止发送违规封禁的文件': '文件消息失敗,禁止發送違規封禁的文件',
72
+ '我': '我',
73
+ '无法查看': '無法查看',
74
+ '无法定位到原消息': '無法定位到原消息',
75
+ '无法收听': '無法收聽',
76
+ '正在加载': '正在加載...',
77
+ '加载结束': '加載結束',
78
+ '无应答': '無應答',
79
+ '系统消息': '系統消息',
80
+ '消息': 'message',
81
+ '消息或者资料中文本存在敏感内容,发送失败': '消息或者資料中文本存在敏感內容,發送失敗',
82
+ '消息详情': '消息詳情',
83
+ '消息长度超出限制,消息长度不要超过12K': '消息長度超出限制,消息長度不要超過12K',
84
+ '消息中图片存在敏感内容,发送失败': '消息中圖片存在敏感內容,發送失敗',
85
+ '选择提醒的人': '選擇提醒的人',
86
+ '已读': '已讀',
87
+ '已过撤回时限': '已過撤回時限',
88
+ '已接听': '已接聽',
89
+ '已拒绝': '已拒絕',
90
+ '已同意': '已同意',
91
+ '引用': '引用',
92
+ '引用失败': '引用失敗',
93
+ '语音': '[語音]',
94
+ '语音通话': '語音通話',
95
+ '重新编辑': '重新編輯',
96
+ '重新发送': '重新發送',
97
+ '转发': '轉發',
98
+ '翻译': '翻譯',
99
+ '转文字': '轉文字',
100
+ '隐藏': '隱藏',
101
+ '转发给': '轉發給',
102
+ '自定义': '[自定義消息]',
103
+ '自定义消息': '自定義消息',
104
+ '腾讯云 IM': '騰訊雲 IM',
105
+ '空': '空',
106
+ '文本包含本地审核拦截词': '文本包含本地審核攔截詞',
107
+ '按住说话': '按住說話',
108
+ '抬起发送': '抬起發送',
109
+ '抬起取消': '抬起取消',
110
+ '正在录音': '正在錄音',
111
+ '继续上滑可取消': '繼續上滑可取消',
112
+ '松开手指 取消发送': '松開手指 取消發送',
113
+ '此机型暂不支持复制功能': '此機型暫不支持複製功能',
114
+ '请开通翻译功能': '請開通翻譯功能',
115
+ '请开通语音转文字功能': '請開通語音轉文字功能',
116
+ '翻译中': '翻譯中',
117
+ '转换中': '轉換中',
118
+ '由IM提供翻译支持': '由IM提供翻譯支持',
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
+ '请升级IMSDK到v2.10.1或更高版本查看此消息': '請升級IMSDK到v2.10.1或更高版本查看此消息',
150
+ '您已被管理员移出群聊': '您已被管理員移出群聊',
151
+ '该群聊已被解散': '該群聊已被解散',
152
+ '您已退出该群聊': '您已退出該群聊',
153
+ '您已被禁止聊天': '您已被禁止聊天',
154
+ '账号被强制下线': '帳號被強制下線',
155
+ '登录失败': '登入失敗',
156
+ };
157
+
158
+ export default TUIChat;
@@ -0,0 +1,16 @@
1
+ const AIDesk = {
2
+ "结束人工会话": "結束會話",
3
+ "转人工服务": "轉人工服務",
4
+ "跳转": "跳轉",
5
+ "立即填写": "立即填寫",
6
+ "已提交": "已提交",
7
+ "提交": "提交",
8
+ "查看内容": "查看內容",
9
+ "请填写必填项": "請填寫必填項",
10
+ "Hi,我是": "Hi,我是",
11
+ "请输入内容": "請輸入內容",
12
+ "如果满意请给好评哦~": "如果滿意請給好評哦~",
13
+ "请对本次服务进行评价": "請對本次服務進行評價",
14
+ "提交评价": "提交評價",
15
+ }
16
+ export default AIDesk;
@@ -0,0 +1,6 @@
1
+ const Component = {
2
+ "图片 url 不存在": "圖片 url 不存在",
3
+ "暂不支持下载此类型图片": "暫不支持下載此類型圖片",
4
+ };
5
+
6
+ export default Component;
@@ -0,0 +1,26 @@
1
+ import TUIChat from './TUIChat';
2
+ import Component from './component';
3
+ import Time from './time';
4
+ import AIDesk from './aidesk';
5
+
6
+ const messages = {
7
+ zh_tw: {
8
+ "取消": '取消',
9
+ "确定": '確定',
10
+ "发送": '發送',
11
+ "系统通知": '系統通知',
12
+ "关闭": '關閉',
13
+ "图片": '圖片',
14
+ "文件": '文件',
15
+ "表情": '表情',
16
+ "视频": '視頻',
17
+ "录制": '錄製',
18
+ "拍照": '拍照',
19
+ AIDesk,
20
+ TUIChat,
21
+ Component,
22
+ Time,
23
+ },
24
+ };
25
+
26
+ export default messages;
@@ -0,0 +1,37 @@
1
+ const Time = {
2
+ "周": "週",
3
+ "天": "天",
4
+ "小时": "小時",
5
+ "分钟": "分鐘",
6
+ "刚刚": "剛剛",
7
+ "前": "前",
8
+ "昨天": "昨天",
9
+ "星期一": "星期一",
10
+ "星期二": "星期二",
11
+ "星期三": "星期三",
12
+ "星期四": "星期四",
13
+ "星期五": "星期五",
14
+ "星期六": "星期六",
15
+ "星期日": "星期日",
16
+ "一月": "一月",
17
+ "二月": "二月",
18
+ "三月": "三月",
19
+ "四月": "四月",
20
+ "五月": "五月",
21
+ "六月": "六月",
22
+ "七月": "七月",
23
+ "八月": "八月",
24
+ "九月": "九月",
25
+ "十月": "十月",
26
+ "十一月": "十一月",
27
+ "十二月": "十二月",
28
+ "一": "一",
29
+ "二": "二",
30
+ "三": "三",
31
+ "四": "四",
32
+ "五": "五",
33
+ "六": "六",
34
+ "日": "日",
35
+ }
36
+
37
+ export default Time;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tencentcloud/ai-desk-customer-vue",
3
- "version": "0.3.0",
4
- "description": "chat uikit ai-desk-customer web-mui-uikit",
3
+ "version": "1.0.0",
4
+ "description": "Vue UIKit for AI Desk",
5
5
  "main": "index",
6
6
  "keywords": [
7
7
  "customer service",
package/server.ts CHANGED
@@ -1,15 +1,25 @@
1
1
  import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
2
2
  import {
3
3
  isCustomerServiceMessage,
4
+ isThinkingMessage,
4
5
  isMessageInvisible,
6
+ clearChatStorage,
5
7
  } from './utils/index';
6
- import TUIChatEngine, { TUIChatService, TUIConversationService,IMessageModel } from '@tencentcloud/chat-uikit-engine';
8
+ import TUIChatEngine, {
9
+ TUIChatService,
10
+ TUIConversationService,
11
+ IMessageModel,
12
+ TUITranslateService
13
+ } from '@tencentcloud/chat-uikit-engine';
7
14
  import Log from './utils/logger';
15
+ import { version } from './package.json'
16
+ import { Toast, TOAST_TYPE } from "./components/common/Toast/index-web";
8
17
 
9
18
  export default class TUICustomerServer {
10
19
  static isInitialized: boolean;
11
20
  static instance: TUICustomerServer;
12
21
  private customerServiceAccounts: any[];
22
+ static loggedInUserID: string;
13
23
  constructor() {
14
24
  TUICore.registerService(TUIConstants.TUICustomerServicePlugin.SERVICE.NAME, this);
15
25
  TUICore.registerExtension(TUIConstants.TUIContact.EXTENSION.CONTACT_LIST.EXT_ID, this);
@@ -25,34 +35,48 @@ export default class TUICustomerServer {
25
35
  }
26
36
 
27
37
  static loginCustomerUIKit(SDKAppID:number, userID:string, userSig:string) {
38
+ clearChatStorage(SDKAppID, userID);
28
39
  TUIChatEngine.login({
29
40
  SDKAppID,
30
41
  userID,
31
42
  userSig,
32
43
  useUploadPlugin: true,
33
44
  }).then(() => {
34
- Log.i("login success");
45
+ Log.i(`login success. userID:${userID}`);
46
+ TUICustomerServer.loggedInUserID = userID;
35
47
  TUIConversationService.switchConversation('C2C@customer_service_account');
36
48
  TUIChatEngine.chat.callExperimentalAPI('isFeatureEnabledForStat', Math.pow(2, 42));
37
49
  })
38
50
  .catch((error) => {
51
+ Toast({
52
+ message: TUITranslateService.t('TUIChat.登录失败'),
53
+ type: TOAST_TYPE.ERROR,
54
+ duration: 30000,
55
+ });
39
56
  Log.l(error);
40
57
  })
41
58
  }
42
59
 
43
- /**
44
- * init
45
- */
46
60
  public static init(SDKAppID:number, userID:string, userSig:string) {
61
+ Log.l(`TUICustomerServer.init version:${version} SDKAppID:${SDKAppID} userID:${userID} isInitialized:${TUICustomerServer.isInitialized} loggedInUserID:${TUICustomerServer.loggedInUserID}`);
47
62
  // Backward compatibility, the new version executes the init operation by default in index.ts
48
63
  if (TUICustomerServer.isInitialized) {
49
- return;
64
+ if (TUICustomerServer.loggedInUserID === userID) {
65
+ return;
66
+ }
67
+ TUICustomerServer.unInit().finally(() => {
68
+ this.loginCustomerUIKit(SDKAppID, userID, userSig);
69
+ });
70
+ } else {
71
+ TUICustomerServer.isInitialized = true;
72
+ // Execute call server when native plugin TUICallKit exists
73
+ this.loginCustomerUIKit(SDKAppID, userID, userSig);
50
74
  }
51
- TUICustomerServer.isInitialized = true;
52
- // Execute call server when native plugin TUICallKit exists
53
- this.loginCustomerUIKit(SDKAppID, userID, userSig);
54
75
  }
55
76
 
77
+ public static async unInit() {
78
+ return TUIChatEngine.logout();
79
+ }
56
80
 
57
81
  // Determine if the current session is a customer service session
58
82
  public isCustomerConversation(conversationID: string) {
@@ -65,6 +89,9 @@ export default class TUICustomerServer {
65
89
  if (!message || !this.isCustomerConversation(message.conversationID)) {
66
90
  return false;
67
91
  }
92
+ if (isThinkingMessage(message)) {
93
+ return false;
94
+ }
68
95
  return isCustomerServiceMessage(message) || isMessageInvisible(message);
69
96
  }
70
97
 
package/utils/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { customerServicePayloadType } from '../interface';
2
- import { CUSTOM_MESSAGE_SRC, TYPES } from '../constant';
2
+ import { CUSTOM_MESSAGE_SRC, TYPES, WHITE_LIST } from '../constant';
3
3
  import { IMessageModel } from '@tencentcloud/chat-uikit-engine';
4
4
 
5
5
  // Determine if it is a JSON string
@@ -37,26 +37,31 @@ export const isMessageRating = (message: IMessageModel): boolean => {
37
37
  return isCustomerServiceMessage(message) && customerServicePayload.src === CUSTOM_MESSAGE_SRC.MENU;
38
38
  };
39
39
 
40
+ export const isThinkingMessage = (message: IMessageModel): boolean => {
41
+ const isCustomerMessage = message?.type === TYPES.MSG_CUSTOM;
42
+ const customerServicePayload: customerServicePayloadType = JSONToObject(message?.payload?.data);
43
+ return isCustomerMessage && customerServicePayload?.src === CUSTOM_MESSAGE_SRC.THINKING && customerServicePayload?.thinkingStatus === 0;
44
+ }
45
+
46
+ export const isThinkingMessageOverTime = (message: IMessageModel): boolean => {
47
+ const messageTime = message.time * 1000;
48
+ const minute = 60 * 1000;
49
+ const now = Date.now();
50
+ if (now - messageTime > minute) {
51
+ return false;
52
+ }
53
+ return true;
54
+ }
55
+
40
56
  export const isMessageInvisible = (message: IMessageModel): boolean => {
41
57
  const customerServicePayload: customerServicePayloadType = JSONToObject(message?.payload?.data);
42
58
  const robotCommandArray = ['feedback', 'updateBotStatus'];
43
- const whiteList = [
44
- CUSTOM_MESSAGE_SRC.MENU,
45
- CUSTOM_MESSAGE_SRC.BRANCH,
46
- CUSTOM_MESSAGE_SRC.BRANCH_NUMBER,
47
- CUSTOM_MESSAGE_SRC.FROM_INPUT,
48
- CUSTOM_MESSAGE_SRC.PRODUCT_CARD,
49
- CUSTOM_MESSAGE_SRC.ROBOT_MSG,
50
- CUSTOM_MESSAGE_SRC.RICH_TEXT,
51
- CUSTOM_MESSAGE_SRC.STREAM_TEXT,
52
- CUSTOM_MESSAGE_SRC.MULTI_BRANCH,
53
- CUSTOM_MESSAGE_SRC.MULTI_FORM
54
- ];
55
59
  const isCustomerMessage = message?.type === TYPES.MSG_CUSTOM;
56
- const isCustomerInvisible = customerServicePayload?.src && !whiteList.includes(customerServicePayload?.src);
57
- const isMultiFormMessage:boolean = customerServicePayload?.src !== null && customerServicePayload?.src === CUSTOM_MESSAGE_SRC.MULTI_FORM && message.flow === 'out';
60
+ const isGroupTipMessage = message?.type === TYPES.MSG_GROUP_TIP;
61
+ const isCustomerInvisible = customerServicePayload?.src && !WHITE_LIST.includes(customerServicePayload?.src);
62
+ const isMultiFormMessage: boolean = customerServicePayload?.src !== null && customerServicePayload?.src === CUSTOM_MESSAGE_SRC.MULTI_FORM && message.flow === 'out';
58
63
  const isRobot = customerServicePayload?.src === CUSTOM_MESSAGE_SRC.ROBOT && robotCommandArray.indexOf(customerServicePayload?.content?.command) !== -1;
59
- return isCustomerMessage && (isCustomerInvisible || isRobot || isMultiFormMessage);
64
+ return (isCustomerMessage && (isCustomerInvisible || isRobot || isMultiFormMessage)) || isGroupTipMessage;
60
65
  };
61
66
 
62
67
  export const isSupportedLang = (lang: string): boolean => {
@@ -67,6 +72,26 @@ export const isSupportedLang = (lang: string): boolean => {
67
72
  'id', // Indonesian印度尼西亚语:id
68
73
  'vi', // Vietnamese越南语:vi
69
74
  'ja', // Japanese日语:ja
70
- 'fil' // Filipino菲律宾语:fil
75
+ 'fil', // Filipino菲律宾语:fil
76
+ 'ru', // Russian俄语:ru
71
77
  ].indexOf(lang) !== -1;
72
78
  }
79
+
80
+ // 如果用户选择 block cookies,此时访问 localStorage 浏览器会抛错
81
+ // Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document
82
+ // 通过 navigator.cookieEnabled 短路逻辑规避
83
+ const canIUseCookies = () => {
84
+ // When the browser is configured to block third-party cookies, and navigator.cookieEnabled is invoked inside a third-party iframe,
85
+ // it returns true in Safari, Edge Spartan and IE (while trying to set a cookie in such scenario would fail).
86
+ // It returns false in Firefox and Chromium-based browsers.
87
+ if (typeof window !== 'undefined') {
88
+ return window.navigator?.cookieEnabled && localStorage;
89
+ }
90
+ return false;
91
+ }
92
+
93
+ export const clearChatStorage = (SDKAppID, userID) => {
94
+ if (canIUseCookies()) {
95
+ localStorage.removeItem(`TIM_${SDKAppID}_${userID}_conversationMap`);
96
+ }
97
+ }
package/utils/utils.ts CHANGED
@@ -91,9 +91,8 @@ export const isCreateGroupCustomMessage = (message: IMessageModel) => {
91
91
  * @return {boolean} - Returns a boolean value indicating if the message read receipt is enabled globally.
92
92
  */
93
93
  export function isEnabledMessageReadReceiptGlobal(): boolean {
94
- return true;
95
- // return TUIStore.getData(StoreName.USER, 'displayMessageReadReceipt')
96
- // && TUIStore.getData(StoreName.APP, 'enabledMessageReadReceipt');
94
+ return TUIStore.getData(StoreName.USER, 'displayMessageReadReceipt')
95
+ && TUIStore.getData(StoreName.APP, 'enabledMessageReadReceipt');
97
96
  }
98
97
 
99
98
  export function shallowCopyMessage(message: IMessageModel) {
@@ -128,7 +127,7 @@ export function calculateTimestamp(timestamp: number): string {
128
127
  return `${formatNum(target.getHours())}:${formatNum(target.getMinutes())}`;
129
128
  } else if (diff <= oneDay) {
130
129
  // yesterday, display yesterday:hour:minute
131
- return `${TUITranslateService.t('time.昨天')} ${formatNum(
130
+ return `${TUITranslateService.t('Time.昨天')} ${formatNum(
132
131
  target.getHours(),
133
132
  )}:${formatNum(target.getMinutes())}`;
134
133
  } else if (diff <= oneWeek - oneDay) {
@@ -143,7 +142,7 @@ export function calculateTimestamp(timestamp: number): string {
143
142
  '星期六',
144
143
  ];
145
144
  const weekday = weekdays[target.getDay()];
146
- return `${TUITranslateService.t('time.' + weekday)} ${formatNum(
145
+ return `${TUITranslateService.t('Time.' + weekday)} ${formatNum(
147
146
  target.getHours(),
148
147
  )}:${formatNum(target.getMinutes())}`;
149
148
  } else if (target.getTime() >= thisYear) {