MessageWindow.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <base-dialog v-model="visible" unless :footer="false" class="message-dialog" destroy-on-close>
  3. <component
  4. :is="MessageWindowContent"
  5. :reply-user-id="replyUserId"
  6. :paper-path="props.paperPath"
  7. @close="onClose"
  8. @change-type="onChangeType"
  9. @reply="onReply"
  10. ></component>
  11. </base-dialog>
  12. </template>
  13. <script setup lang="ts" name="MessageWindow">
  14. /** 发送/回复消息 */
  15. import { ref, computed, withDefaults } from 'vue'
  16. import useVModel from '@/hooks/useVModel'
  17. import BaseDialog from '@/components/element/BaseDialog.vue'
  18. import MessageHistory from '@/components/shared/message/MessageList.vue'
  19. import MessageSend from '@/components/shared/message/MessageSend.vue'
  20. type ModalType = 'view' | 'send'
  21. const props = withDefaults(
  22. defineProps<{
  23. modelValue: boolean
  24. type: ModalType
  25. replyUserId?: number | null
  26. paperPath?: string | null
  27. }>(),
  28. { type: 'view', replyUserId: null, paperPath: null }
  29. )
  30. const visible = useVModel(props, 'modelValue')
  31. const modalType = useVModel(props, 'type')
  32. const replyUserId = useVModel(props, 'replyUserId')
  33. const MessageWindowContent = computed(() => {
  34. return modalType.value === 'send' ? MessageSend : MessageHistory
  35. })
  36. const onClose = () => {
  37. visible.value = false
  38. replyUserId.value = null
  39. }
  40. const onChangeType = (type: ModalType) => {
  41. modalType.value = type
  42. }
  43. /** 回复 */
  44. const onReply = (userId: number) => {
  45. replyUserId.value = userId
  46. }
  47. </script>
  48. <style lang="scss">
  49. .message-dialog {
  50. background-color: transparent;
  51. box-shadow: none;
  52. .el-dialog__body {
  53. padding: 0 !important;
  54. }
  55. }
  56. </style>