mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 10:38:20 +00:00
25 lines
536 B
Vue
25 lines
536 B
Vue
<script lang="ts">
|
|
let activeTargets = $ref<string[]>([]);
|
|
</script>
|
|
|
|
<script setup lang="ts">
|
|
const props = $defineProps<{
|
|
from?: string,
|
|
to?: string,
|
|
}>();
|
|
const { from, to } = $(props);
|
|
|
|
if (from) {
|
|
onMounted(() => activeTargets.push(from));
|
|
onBeforeUnmount(() => activeTargets.splice(activeTargets.indexOf(from), 1));
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="from" :id="'portal-' + from">
|
|
<slot/>
|
|
</div>
|
|
<Teleport v-else-if="to && activeTargets.includes(to)" :to="'#portal-' + to">
|
|
<slot/>
|
|
</Teleport>
|
|
</template>
|