init
Some checks failed
Deploy / build (push) Has been cancelled

This commit is contained in:
alsaze 2025-11-26 17:30:06 +03:00
parent 9c650b3c30
commit 31c9e5f49c
2 changed files with 41 additions and 13 deletions

12
composables/useScreen.ts Normal file
View File

@ -0,0 +1,12 @@
import { useMediaQuery } from '@vueuse/core'
export default function useScreen() {
const isMobile = useMediaQuery('(max-width: 1279px)')
const isDesktop = computed(() => !isMobile.value)
return {
isMobile,
isDesktop,
}
}

View File

@ -1,9 +1,15 @@
<template> <template>
<div class="layout"> <div class="layout">
<UHeader title="Rental"> <UHeader
title="Rental"
:toggle="false"
:ui="{ left: 'justify-between w-full', container: 'gap-0', right: 'hidden' }"
>
<template #left>
<NuxtLink to="/">
Rental
</NuxtLink>
<UTabs v-model="activeTab" :content="false" :items="tabs" /> <UTabs v-model="activeTab" :content="false" :items="tabs" />
<template #right>
<UColorModeButton /> <UColorModeButton />
</template> </template>
</UHeader> </UHeader>
@ -14,40 +20,50 @@
</UContainer> </UContainer>
</UMain> </UMain>
<UFooter /> <UFooter>
<div class="flex flex-col md:flex-row justify-between items-center w-full text-sm opacity-70">
<div>
© {{ new Date().getFullYear() }} Rental. Все права защищены.
</div>
</div>
</UFooter>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { TabsItem } from '@nuxt/ui' import type { TabsItem } from '@nuxt/ui'
import useScreen from '~/composables/useScreen'
const { isMobile } = useScreen()
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const tabs = ref<TabsItem[]>([ const tabs = ref<TabsItem[]>([
{ {
label: 'Главная', label: isMobile.value ? '' : 'Главная',
icon: 'i-lucide-home', icon: 'i-lucide-home',
value: 'index',
route: '/', route: '/',
}, },
{ {
label: 'Недвижимость', label: isMobile.value ? '' : 'Недвижимость',
icon: 'i-lucide-building-2', icon: 'i-lucide-building-2',
value: 'nedvizhimost',
route: '/nedvizhimost', route: '/nedvizhimost',
}, },
{ {
label: 'Авто', label: isMobile.value ? '' : 'Авто',
icon: 'i-lucide-car', icon: 'i-lucide-car',
value: 'transport',
route: '/transport', route: '/transport',
}, },
]) ])
const activeTab = ref(tabs.value.findIndex(tab => route.path.startsWith(tab.route))) const activeTab = ref(route.path.split('/')[1])
watch(() => activeTab.value, () => { watch(() => activeTab.value, () => {
router.push(tabs.value[activeTab?.value]?.route) const tab = tabs.value.find(tab => tab.value === activeTab.value)
router.push(tab.route)
}) })
</script> </script>
<style lang="scss">
</style>