config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. class TUIChatConfig {
  2. static instance: TUIChatConfig;
  3. private chatType: string;
  4. private features: Record<string, any>;
  5. constructor() {
  6. this.chatType = '';
  7. this.features = {
  8. DownloadFile: true,
  9. CopyMessage: true,
  10. DeleteMessage: true,
  11. RevokeMessage: true,
  12. modifyMessage: true,
  13. QuoteMessage: true,
  14. ForwardMessage: true,
  15. TranslateMessage: true,
  16. VoiceToText: true,
  17. MultiSelection: true,
  18. EmojiReaction: true,
  19. InputEmoji: true,
  20. InputStickers: true,
  21. InputImage: true,
  22. InputVoice: true,
  23. InputVideo: true,
  24. InputFile: true,
  25. InputEvaluation: true,
  26. InputQuickReplies: true,
  27. InputMention: true,
  28. MessageSearch: true,
  29. ReadStatus: true,
  30. };
  31. }
  32. static getInstance(): TUIChatConfig {
  33. if (!TUIChatConfig.instance) {
  34. TUIChatConfig.instance = new TUIChatConfig();
  35. }
  36. return TUIChatConfig.instance;
  37. }
  38. setChatType(chatType: string) {
  39. this.chatType = chatType;
  40. }
  41. getChatType() {
  42. return this.chatType;
  43. }
  44. hideTUIChatFeatures(features: string[]) {
  45. if (!features) {
  46. return;
  47. }
  48. features.forEach((feature: string) => {
  49. if (this.features[feature]) {
  50. this.features[feature] = false;
  51. }
  52. });
  53. }
  54. getFeatureConfig(key?: string) {
  55. if (key) {
  56. return this.features[key];
  57. }
  58. return this.features;
  59. }
  60. }
  61. const ChatConfig = TUIChatConfig.getInstance();
  62. const hideTUIChatFeatures = ChatConfig.hideTUIChatFeatures.bind(ChatConfig);
  63. export {
  64. hideTUIChatFeatures,
  65. };
  66. export default ChatConfig;