content.vue 742 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <div v-if="brotherInstances" class="ui-gate-content" :class="{ active }">
  3. <slot :active="active" />
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. // getCurrentInstance
  8. import { inject, onBeforeMount, onUnmounted, ref } from 'vue'
  9. import { Relation } from './constant'
  10. defineOptions({
  11. name: 'UIGateContent',
  12. })
  13. const active = ref(false)
  14. const brotherInstances = inject(Relation).value
  15. if (brotherInstances) {
  16. onBeforeMount(() => brotherInstances.push(active))
  17. onUnmounted(() => {
  18. const index = brotherInstances.indexOf(active)
  19. if (~index) {
  20. brotherInstances.splice(index, 1)
  21. }
  22. })
  23. }
  24. </script>
  25. <!-- <script>
  26. export default { name: 'UiGateContent' }
  27. </script> -->