Browse Source
Introduce a new AppShell component to encapsulate the main application layout, including header, footer, and menu items. Refactor existing layouts (default and not-login) to utilize the new AppShell component, enhancing code reusability and maintainability. Update the blank layout for a simplified structure. Modify index, login, and register pages for consistent styling and improved user experience.feat/auth-access-control
7 changed files with 184 additions and 173 deletions
@ -0,0 +1,83 @@ |
|||
<script setup lang="ts"> |
|||
withDefaults( |
|||
defineProps<{ |
|||
showAuthActions?: boolean |
|||
}>(), |
|||
{ |
|||
showAuthActions: false, |
|||
}, |
|||
) |
|||
|
|||
const menuItems = [ |
|||
[ |
|||
{ |
|||
label: '首页', |
|||
icon: 'i-lucide-house', |
|||
to: '/', |
|||
}, |
|||
{ |
|||
label: '文档', |
|||
icon: 'i-lucide-book-open', |
|||
children: [ |
|||
{ |
|||
label: 'Nuxt', |
|||
to: 'https://nuxt.com/docs', |
|||
target: '_blank', |
|||
}, |
|||
{ |
|||
label: 'Nuxt UI', |
|||
to: 'https://ui.nuxt.com/getting-started', |
|||
target: '_blank', |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
label: '示例', |
|||
icon: 'i-lucide-layout-grid', |
|||
children: [ |
|||
{ |
|||
label: 'Hello API', |
|||
to: '/api/hello', |
|||
target: '_blank', |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
] |
|||
</script> |
|||
|
|||
<template> |
|||
<UApp> |
|||
<div class="min-h-screen bg-default text-default flex flex-col"> |
|||
<header class="border-b border-default"> |
|||
<UContainer class="h-14 flex items-center justify-between"> |
|||
<div class="flex items-center gap-2"> |
|||
<NuxtLink to="/" class="font-semibold tracking-tight"> |
|||
BigHouse |
|||
</NuxtLink> |
|||
<UDropdownMenu :items="menuItems" :content="{ align: 'end' }"> |
|||
<UButton color="neutral" variant="ghost" label="菜单" icon="i-lucide-menu" /> |
|||
</UDropdownMenu> |
|||
</div> |
|||
|
|||
<div v-if="showAuthActions" class="flex items-center gap-2"> |
|||
<UButton color="neutral" variant="ghost" to="/login" label="登录" /> |
|||
<UButton color="neutral" variant="outline" to="/register" label="注册" /> |
|||
</div> |
|||
</UContainer> |
|||
</header> |
|||
|
|||
<main class="flex-1"> |
|||
<UContainer class="py-8"> |
|||
<slot /> |
|||
</UContainer> |
|||
</main> |
|||
|
|||
<footer class="border-t border-default"> |
|||
<UContainer class="h-12 flex items-center text-sm text-muted"> |
|||
Built with Nuxt + Nuxt UI & BigHouse |
|||
</UContainer> |
|||
</footer> |
|||
</div> |
|||
</UApp> |
|||
</template> |
|||
@ -0,0 +1,7 @@ |
|||
<template> |
|||
<UApp> |
|||
<div class="min-h-screen bg-gradient-to-br from-neutral-50 via-white to-neutral-100 text-default"> |
|||
<slot /> |
|||
</div> |
|||
</UApp> |
|||
</template> |
|||
@ -1,77 +1,5 @@ |
|||
<template> |
|||
<UApp> |
|||
<div class="min-h-screen bg-default text-default flex flex-col"> |
|||
<header class="border-b border-default"> |
|||
<UContainer class="h-14 flex items-center justify-between"> |
|||
<div class="flex items-center gap-2"> |
|||
<NuxtLink to="/" class="font-semibold tracking-tight"> |
|||
BigHouse |
|||
</NuxtLink> |
|||
<UDropdownMenu :items="menuItems" :content="{ align: 'end' }"> |
|||
<UButton color="neutral" variant="ghost" label="菜单" icon="i-lucide-menu" /> |
|||
</UDropdownMenu> |
|||
</div> |
|||
<div class="flex items-center gap-2"> |
|||
<UButton color="neutral" variant="ghost" to="/login" label="登录" /> |
|||
<UButton color="neutral" variant="outline" to="/register" label="注册" /> |
|||
</div> |
|||
</UContainer> |
|||
</header> |
|||
|
|||
<main class="flex-1"> |
|||
<UContainer class="py-8"> |
|||
<NuxtPage /> |
|||
</UContainer> |
|||
</main> |
|||
|
|||
<footer class="border-t border-default"> |
|||
<UContainer class="h-12 flex items-center text-sm text-muted"> |
|||
Built with Nuxt + Nuxt UI & BigHouse |
|||
</UContainer> |
|||
</footer> |
|||
</div> |
|||
</UApp> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
const menuItems = [ |
|||
[ |
|||
{ |
|||
label: "首页", |
|||
icon: "i-lucide-house", |
|||
to: "/", |
|||
}, |
|||
{ |
|||
label: "文档", |
|||
icon: "i-lucide-book-open", |
|||
children: [ |
|||
{ |
|||
label: "Nuxt", |
|||
to: "https://nuxt.com/docs", |
|||
target: "_blank", |
|||
}, |
|||
{ |
|||
label: "Nuxt UI", |
|||
to: "https://ui.nuxt.com/getting-started", |
|||
target: "_blank", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
label: "示例", |
|||
icon: "i-lucide-layout-grid", |
|||
children: [ |
|||
{ |
|||
label: "Hello API", |
|||
to: "/api/hello", |
|||
target: "_blank", |
|||
}, |
|||
{ |
|||
label: "首页页面", |
|||
to: "/", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
] |
|||
</script> |
|||
<AppShell> |
|||
<slot /> |
|||
</AppShell> |
|||
</template> |
|||
@ -1,73 +1,5 @@ |
|||
<template> |
|||
<UApp> |
|||
<div class="min-h-screen bg-default text-default flex flex-col"> |
|||
<header class="border-b border-default"> |
|||
<UContainer class="h-14 flex items-center justify-between"> |
|||
<div class="flex items-center gap-2"> |
|||
<NuxtLink to="/" class="font-semibold tracking-tight"> |
|||
BigHouse |
|||
</NuxtLink> |
|||
<UDropdownMenu :items="menuItems" :content="{ align: 'end' }"> |
|||
<UButton color="neutral" variant="ghost" label="菜单" icon="i-lucide-menu" /> |
|||
</UDropdownMenu> |
|||
</div> |
|||
</UContainer> |
|||
</header> |
|||
|
|||
<main class="flex-1"> |
|||
<UContainer class="py-8"> |
|||
<NuxtPage /> |
|||
</UContainer> |
|||
</main> |
|||
|
|||
<footer class="border-t border-default"> |
|||
<UContainer class="h-12 flex items-center text-sm text-muted"> |
|||
Built with Nuxt + Nuxt UI & BigHouse |
|||
</UContainer> |
|||
</footer> |
|||
</div> |
|||
</UApp> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
const menuItems = [ |
|||
[ |
|||
{ |
|||
label: "首页", |
|||
icon: "i-lucide-house", |
|||
to: "/", |
|||
}, |
|||
{ |
|||
label: "文档", |
|||
icon: "i-lucide-book-open", |
|||
children: [ |
|||
{ |
|||
label: "Nuxt", |
|||
to: "https://nuxt.com/docs", |
|||
target: "_blank", |
|||
}, |
|||
{ |
|||
label: "Nuxt UI", |
|||
to: "https://ui.nuxt.com/getting-started", |
|||
target: "_blank", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
label: "示例", |
|||
icon: "i-lucide-layout-grid", |
|||
children: [ |
|||
{ |
|||
label: "Hello API", |
|||
to: "/api/hello", |
|||
target: "_blank", |
|||
}, |
|||
{ |
|||
label: "首页页面", |
|||
to: "/", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
] |
|||
</script> |
|||
<AppShell show-auth-actions> |
|||
<slot /> |
|||
</AppShell> |
|||
</template> |
|||
Loading…
Reference in new issue