2026-04-11 15:59:14 +08:00
|
|
|
<script setup lang="ts">
|
2026-04-15 09:12:54 +08:00
|
|
|
import { onMounted, onUnmounted, computed, ref, watch } from 'vue'
|
2026-04-14 21:48:53 +08:00
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
2026-04-11 15:59:14 +08:00
|
|
|
import { NConfigProvider, NMessageProvider, NDialogProvider, NNotificationProvider } from 'naive-ui'
|
|
|
|
|
import { themeOverrides } from '@/styles/theme'
|
|
|
|
|
import AppSidebar from '@/components/layout/AppSidebar.vue'
|
|
|
|
|
import { useKeyboard } from '@/composables/useKeyboard'
|
|
|
|
|
import { useAppStore } from '@/stores/app'
|
|
|
|
|
|
|
|
|
|
const appStore = useAppStore()
|
2026-04-14 21:48:53 +08:00
|
|
|
const route = useRoute()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const ready = ref(false)
|
|
|
|
|
|
|
|
|
|
const isLoginPage = computed(() => route.name === 'login')
|
|
|
|
|
|
2026-04-15 09:12:54 +08:00
|
|
|
// Close mobile sidebar on route change
|
|
|
|
|
watch(() => route.path, () => {
|
|
|
|
|
appStore.closeSidebar()
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-14 21:48:53 +08:00
|
|
|
// Wait for router to resolve before rendering layout
|
|
|
|
|
router.isReady().then(() => {
|
|
|
|
|
ready.value = true
|
|
|
|
|
})
|
2026-04-11 15:59:14 +08:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
2026-04-14 21:48:53 +08:00
|
|
|
if (!isLoginPage.value) {
|
|
|
|
|
appStore.loadModels()
|
|
|
|
|
appStore.startHealthPolling()
|
|
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
appStore.stopHealthPolling()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
useKeyboard()
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<NConfigProvider :theme-overrides="themeOverrides">
|
|
|
|
|
<NMessageProvider>
|
|
|
|
|
<NDialogProvider>
|
|
|
|
|
<NNotificationProvider>
|
2026-04-14 21:48:53 +08:00
|
|
|
<div v-if="ready" class="app-layout" :class="{ 'no-sidebar': isLoginPage }">
|
2026-04-15 09:12:54 +08:00
|
|
|
<button v-if="!isLoginPage" class="hamburger-btn" @click="appStore.toggleSidebar">
|
|
|
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>
|
|
|
|
|
</button>
|
|
|
|
|
<div v-if="!isLoginPage && appStore.sidebarOpen" class="mobile-backdrop" @click="appStore.closeSidebar" />
|
2026-04-14 21:48:53 +08:00
|
|
|
<AppSidebar v-if="!isLoginPage" />
|
2026-04-11 15:59:14 +08:00
|
|
|
<main class="app-main">
|
|
|
|
|
<router-view />
|
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
</NNotificationProvider>
|
|
|
|
|
</NDialogProvider>
|
|
|
|
|
</NMessageProvider>
|
|
|
|
|
</NConfigProvider>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@use '@/styles/variables' as *;
|
|
|
|
|
|
|
|
|
|
.app-layout {
|
|
|
|
|
display: flex;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
width: 100vw;
|
|
|
|
|
overflow: hidden;
|
2026-04-14 21:48:53 +08:00
|
|
|
|
|
|
|
|
&.no-sidebar {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.app-main {
|
|
|
|
|
flex: 1;
|
2026-04-14 14:47:18 +08:00
|
|
|
overflow-y: auto;
|
2026-04-11 15:59:14 +08:00
|
|
|
background-color: $bg-primary;
|
2026-04-14 21:48:53 +08:00
|
|
|
|
|
|
|
|
.no-sidebar & {
|
|
|
|
|
height: 100vh;
|
|
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
}
|
|
|
|
|
</style>
|