contact-info-config.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import { TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
  2. import {
  3. CONTACT_INFO_LABEL_POSITION,
  4. CONTACT_INFO_MORE_EDIT_TYPE,
  5. CONTACT_INFO_BUTTON_TYPE,
  6. } from '../../../constant';
  7. import {
  8. updateFriendRemark,
  9. deleteFriend,
  10. enterConversation,
  11. quitGroup,
  12. dismissGroup,
  13. joinGroup,
  14. addFriend,
  15. acceptFriendApplication,
  16. refuseFriendApplication,
  17. addToBlacklist,
  18. removeFromBlacklist,
  19. } from '../utils/index';
  20. export const contactMoreInfoConfig = {
  21. // set friends' remark
  22. setRemark: {
  23. key: 'setRemark',
  24. label: '备注名',
  25. data: '',
  26. labelPosition: CONTACT_INFO_LABEL_POSITION.LEFT,
  27. editable: true,
  28. editType: CONTACT_INFO_MORE_EDIT_TYPE.INPUT,
  29. editing: false,
  30. editSubmitHandler: (props: {
  31. item: any;
  32. contactInfoData: any;
  33. [propsName: string]: any;
  34. }) => {
  35. if (props?.isBothFriend) {
  36. const newRemarkValue = props?.item?.data;
  37. updateFriendRemark(props?.contactInfoData?.userID, newRemarkValue);
  38. props?.item?.editing && (props.item.editing = false);
  39. props?.item?.data && (props.item.data = props?.contactInfoData?.remark);
  40. } else {
  41. props?.item?.editing && (props.item.editing = false);
  42. }
  43. },
  44. },
  45. // blocked list
  46. blackList: {
  47. key: 'blackList',
  48. label: '加入黑名单',
  49. data: false,
  50. labelPosition: CONTACT_INFO_LABEL_POSITION.LEFT,
  51. editable: true,
  52. editType: CONTACT_INFO_MORE_EDIT_TYPE.SWITCH,
  53. editing: true,
  54. editSubmitHandler: (props: {
  55. item: any;
  56. contactInfoData: any;
  57. [propsName: string]: any;
  58. }) => {
  59. if (props?.isInBlackList) {
  60. removeFromBlacklist(props?.contactInfoData?.userID);
  61. } else {
  62. addToBlacklist(props?.contactInfoData?.userID);
  63. TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', 'blackList');
  64. }
  65. },
  66. },
  67. // Fill in verification words (applicant)
  68. setWords: {
  69. key: 'setWords',
  70. label: '请填写验证信息',
  71. data: '',
  72. labelPosition: CONTACT_INFO_LABEL_POSITION.TOP,
  73. editable: true,
  74. editType: CONTACT_INFO_MORE_EDIT_TYPE.TEXTAREA,
  75. editing: true,
  76. },
  77. // Display verification words (application recipient)
  78. displayWords: {
  79. key: 'displayWords',
  80. label: '验证信息',
  81. data: '',
  82. labelPosition: CONTACT_INFO_LABEL_POSITION.LEFT,
  83. editable: false,
  84. },
  85. };
  86. export const contactButtonConfig = {
  87. // ---------------------
  88. // group command config
  89. // ---------------------
  90. dismissGroup: {
  91. key: 'dismissGroup',
  92. label: '解散群聊',
  93. type: CONTACT_INFO_BUTTON_TYPE.CANCEL,
  94. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  95. dismissGroup(props?.contactInfoData?.groupID);
  96. },
  97. },
  98. quitGroup: {
  99. key: 'quitGroup',
  100. label: '退出群聊',
  101. type: CONTACT_INFO_BUTTON_TYPE.CANCEL,
  102. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  103. quitGroup(props?.contactInfoData?.groupID);
  104. },
  105. },
  106. joinGroup: {
  107. key: 'joinGroup',
  108. label: '发送申请',
  109. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  110. onClick: (props: {
  111. contactInfoData: any;
  112. contactInfoMoreList: any;
  113. [propsName: string]: any;
  114. }) => {
  115. joinGroup(
  116. props?.contactInfoData?.groupID,
  117. props?.contactInfoMoreList[0]?.data,
  118. );
  119. },
  120. },
  121. joinAVChatGroup: {
  122. key: 'joinAVChatGroup',
  123. label: '加入直播群',
  124. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  125. onClick: (props: {
  126. contactInfoData: any;
  127. contactInfoMoreList: any;
  128. [propsName: string]: any;
  129. }) => {
  130. joinGroup(props?.contactInfoData?.groupID);
  131. },
  132. },
  133. enterGroupConversation: {
  134. key: 'enterGroupConversation',
  135. label: '进入群聊',
  136. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  137. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  138. enterConversation(props?.contactInfoData);
  139. },
  140. },
  141. // ---------------------
  142. // friend command config
  143. // ---------------------
  144. addFriend: {
  145. key: 'addFriend',
  146. label: '发送申请',
  147. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  148. onClick: (props: {
  149. contactInfoData: any;
  150. contactInfoMoreList: any;
  151. [propsName: string]: any;
  152. }) => {
  153. addFriend({
  154. to: props?.contactInfoData?.userID,
  155. source: 'AddSource_Type_Web',
  156. remark: props?.contactInfoMoreList[1]?.data,
  157. wording: props?.contactInfoMoreList[0]?.data,
  158. });
  159. },
  160. },
  161. deleteFriend: {
  162. key: 'deleteFriend',
  163. label: '删除好友',
  164. type: CONTACT_INFO_BUTTON_TYPE.CANCEL,
  165. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  166. deleteFriend(props?.contactInfoData?.userID);
  167. },
  168. },
  169. enterC2CConversation: {
  170. key: 'enterC2CConversation',
  171. label: '发送消息',
  172. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  173. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  174. enterConversation(props?.contactInfoData);
  175. },
  176. },
  177. // ---------------------
  178. // friend application command config
  179. // ---------------------
  180. acceptFriendApplication: {
  181. key: 'acceptFriendApplication',
  182. label: '同意',
  183. type: CONTACT_INFO_BUTTON_TYPE.SUBMIT,
  184. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  185. acceptFriendApplication(props?.contactInfoData?.userID);
  186. TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', 'friendList');
  187. },
  188. },
  189. refuseFriendApplication: {
  190. key: 'refuseFriendApplication',
  191. label: '拒绝',
  192. type: CONTACT_INFO_BUTTON_TYPE.CANCEL,
  193. onClick: (props: { contactInfoData: any; [propsName: string]: any }) => {
  194. refuseFriendApplication(props?.contactInfoData?.userID);
  195. },
  196. },
  197. };