ContentDialog.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <!-- 带一个关闭按钮的弹窗 -->
  3. <SimplePopup
  4. ref="popupContent"
  5. @change="(show: boolean) => emit('update:show', show)"
  6. >
  7. <img
  8. :src="CloseMini"
  9. class="content-dialog-close"
  10. @click="() => emit('update:show', false)"
  11. />
  12. <div :class="[
  13. 'd-flex',
  14. 'flex-col',
  15. 'content-dialog',
  16. small ? 'small' : '',
  17. light ? 'light' : '',
  18. ]">
  19. <slot />
  20. </div>
  21. </SimplePopup>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref, watch } from 'vue';
  25. import CloseMini from '@/assets/images/CloseMini.png';
  26. import SimplePopup from '../display/SimplePopup.vue';
  27. const props = defineProps({
  28. show : {
  29. type: Boolean,
  30. default: false,
  31. },
  32. small : {
  33. type: Boolean,
  34. default: false,
  35. },
  36. light : {
  37. type: Boolean,
  38. default: false,
  39. }
  40. })
  41. const emit = defineEmits([
  42. "update:show"
  43. ])
  44. const popupContent = ref()
  45. watch(() => props.show, (v) => {
  46. if(v) {
  47. popupContent.value.open()
  48. } else {
  49. popupContent.value.close()
  50. }
  51. })
  52. </script>
  53. <style lang="scss">
  54. @use '@/assets/scss/colors.scss' as *;
  55. @use '@/assets/scss/scroll.scss' as *;
  56. .content-dialog {
  57. width: 85vw;
  58. height: 80vh;
  59. overflow: hidden;
  60. border-radius: 10px;
  61. background-color: $box-color;
  62. border: 1px solid $border-split-color;
  63. padding: 25px 33px;
  64. pointer-events: all;
  65. overflow-y: scroll;
  66. @include pc-fix-scrollbar();
  67. &.small {
  68. width: 45vw;
  69. }
  70. }
  71. .content-dialog-close {
  72. position: absolute;
  73. top: -30px;
  74. right: -30px;
  75. width: 40px;
  76. height: 40px;
  77. pointer-events: all;
  78. cursor: pointer;
  79. }
  80. @media (max-width: 540px) {
  81. .content-dialog-close {
  82. right: -6px;
  83. top: -40px;
  84. }
  85. .content-dialog {
  86. width: 97vw;
  87. &.small {
  88. width: 97vw;
  89. }
  90. }
  91. }
  92. </style>