message.tsx 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { defineComponent } from "vue";
  2. import { ElButton } from "element-plus";
  3. import runtime, * as RuntimeUtils from '/src/components/live-broadcast/runtime'
  4. import styles from './message.module.less';
  5. import { state } from '/src/state'
  6. import request from '/src/helpers/request'
  7. type optionsType = 'ALL' | 'JOIN'
  8. export default defineComponent({
  9. name: 'message',
  10. data() {
  11. return {
  12. options: 'ALL' as optionsType,
  13. }
  14. },
  15. mounted() {
  16. const config = state.user?.roomConfig ? JSON.parse(state.user?.roomConfig) : {}
  17. runtime.allowChatCtrl = config.whether_chat === 0
  18. runtime.allowSeatsCtrl = config.whether_mic === 0
  19. },
  20. methods: {
  21. async SeatsCtrl() {
  22. try {
  23. const users = state.user
  24. const roomConfig = users?.roomConfig ? JSON.parse(users?.roomConfig) : {}
  25. await request.post('/api-web/imLiveBroadcastRoom/update', {
  26. requestType: 'json',
  27. data: {
  28. id: users.id,
  29. liveRemark: users.liveRemark,
  30. liveStartTime: users.liveStartTime,
  31. preTemplate: users.preTemplate,
  32. roomConfig: {
  33. whether_chat: roomConfig.whether_chat,
  34. whether_like: roomConfig.whether_like,
  35. whether_mic: runtime.allowSeatsCtrl ? 1 : 0,
  36. whether_video: roomConfig.whether_video
  37. },
  38. roomTitle: users.roomTitle,
  39. speakerId: users.speakerId,
  40. tenantId: users.tenantId
  41. }
  42. })
  43. await RuntimeUtils.sendMessage({ seatBan: runtime.allowSeatsCtrl, ...RuntimeUtils.getSendMessageUser() }, 'SeatsCtrl')
  44. runtime.allowSeatsCtrl = !runtime.allowSeatsCtrl
  45. } catch {
  46. //
  47. }
  48. },
  49. async ChatBan() {
  50. try {
  51. const users = state.user
  52. const roomConfig = users?.roomConfig ? JSON.parse(users?.roomConfig) : {}
  53. await request.post('/api-web/imLiveBroadcastRoom/update', {
  54. requestType: 'json',
  55. data: {
  56. id: users.id,
  57. liveRemark: users.liveRemark,
  58. liveStartTime: users.liveStartTime,
  59. preTemplate: users.preTemplate,
  60. roomConfig: {
  61. whether_chat: runtime.allowChatCtrl ? 1 : 0,
  62. whether_like: roomConfig.whether_like,
  63. whether_video: roomConfig.whether_video,
  64. whether_mic: roomConfig.whether_mic
  65. },
  66. roomTitle: users.roomTitle,
  67. speakerId: users.speakerId,
  68. tenantId: users.tenantId
  69. }
  70. })
  71. await RuntimeUtils.sendMessage({ chatBan: runtime.allowChatCtrl, ...RuntimeUtils.getSendMessageUser() }, 'ChatBan')
  72. runtime.allowChatCtrl = !runtime.allowChatCtrl
  73. } catch {
  74. //
  75. }
  76. },
  77. },
  78. render() {
  79. return (
  80. <div class={styles.message}>
  81. <div class={styles.buttonGroup}>
  82. {/* {this.whetherChat ? <ElButton type={!runtime.allowChatCtrl ? 'primary' : 'info'} onClick={this.ChatBan} >{runtime.allowChatCtrl ? '全体禁言' : '关闭全体禁言'}</ElButton> : null} */}
  83. <ElButton type={!runtime.allowChatCtrl ? 'primary' : 'info'} onClick={this.ChatBan} >{runtime.allowChatCtrl ? '关闭聊天' : '开启聊天'}</ElButton>
  84. <ElButton type={!runtime.allowSeatsCtrl ? 'primary' : 'info'} onClick={this.SeatsCtrl}>{runtime.allowSeatsCtrl ? '关闭连麦' : '开启连麦'}</ElButton>
  85. </div>
  86. </div>
  87. )
  88. }
  89. })