simplify code
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="tabs is-centered">
|
||||
<ul>
|
||||
<li
|
||||
v-for="window in windows"
|
||||
v-for="window in props.windows"
|
||||
:key="window.label"
|
||||
@click="emit('set-window', window)"
|
||||
:class="{ 'is-active': window.label === activeWindow?.label }"
|
||||
@@ -13,22 +13,15 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, defineProps, defineEmits } from 'vue'
|
||||
import { windows } from '@/utils/helpers'
|
||||
import { defineProps, defineEmits } from 'vue'
|
||||
import type { Window } from '@/utils/types'
|
||||
|
||||
const props = defineProps<{
|
||||
activeWindow: Window | undefined
|
||||
activeWindow: Window
|
||||
windows: Window[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'set-window', window: Window): void
|
||||
}>()
|
||||
|
||||
onMounted(() => {
|
||||
const activeWindow = !props.activeWindow?.label
|
||||
? windows[1]
|
||||
: windows.find((w) => w.label === props.activeWindow?.label.replace('-', ' '))
|
||||
if (activeWindow) emit('set-window', activeWindow)
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user