content.vue 676 B

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