index.vue 918 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div
  3. v-if="showMask"
  4. class="mask"
  5. @click.self="!isWeChat && toggleView"
  6. >
  7. <slot />
  8. </div>
  9. </template>
  10. <script lang="ts" setup>
  11. import { ref, watchEffect } from '../../../adapter-vue';
  12. import { isWeChat } from '../../../utils/env';
  13. const props = defineProps({
  14. show: {
  15. type: Boolean,
  16. default: () => false,
  17. },
  18. });
  19. const showMask = ref(false);
  20. watchEffect(() => {
  21. showMask.value = props.show;
  22. });
  23. const emit = defineEmits(['update:show']);
  24. const toggleView = () => {
  25. showMask.value = !showMask.value;
  26. emit('update:show', showMask.value);
  27. };
  28. </script>
  29. <style lang="scss" scoped>
  30. @import '../../../assets/styles/common';
  31. .mask {
  32. position: fixed;
  33. width: 100vw;
  34. height: 100vh;
  35. left: 0;
  36. top: 0;
  37. z-index: 99;
  38. background: rgba(#000, 0.5);
  39. display: flex;
  40. justify-content: center;
  41. align-items: center;
  42. main {
  43. position: relative;
  44. }
  45. }
  46. </style>