fix导航栏在移动端无法正常显示
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import type { NavigationMenuItem } from '@nuxt/ui'
|
||||
|
||||
const isSettingsOpen = ref(false);
|
||||
const isLoginModalOpen = ref(false);
|
||||
const isRegisterModalOpen = ref(false);
|
||||
|
||||
const { header } = useAppConfig();
|
||||
// const { header } = useAppConfig();
|
||||
|
||||
|
||||
// 定义 props 来接收侧边栏状态和切换函数
|
||||
interface Props {
|
||||
@@ -11,9 +14,9 @@ interface Props {
|
||||
toggleSidebar?: () => void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
const Props = withDefaults(defineProps<Props>(), {
|
||||
isSidebarOpen: false,
|
||||
toggleSidebar: () => {},
|
||||
toggleSidebar: () => { },
|
||||
});
|
||||
|
||||
// 登录注册函数
|
||||
@@ -27,98 +30,60 @@ const handleLoginRegister = (type: "login" | "register") => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Header
|
||||
class="header bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 sticky top-0 z-50"
|
||||
>
|
||||
<div class="px-2 sm:px-4 lg:px-6">
|
||||
<div class="flex justify-between items-center h-12">
|
||||
<!-- 汉堡菜单按钮 - 只在移动端显示 -->
|
||||
<button
|
||||
@click="
|
||||
() => {
|
||||
console.log('汉堡按钮被点击');
|
||||
props.toggleSidebar();
|
||||
}
|
||||
"
|
||||
class="lg:hidden p-2 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
||||
aria-label="打开导航菜单"
|
||||
>
|
||||
<svg
|
||||
class="w-5 h-5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
:class="{ 'rotate-180': props.isSidebarOpen }"
|
||||
>
|
||||
<path
|
||||
v-if="!props.isSidebarOpen"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M4 6h16M4 12h16M4 18h16"
|
||||
/>
|
||||
<path
|
||||
v-else
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<UHeader toggle-side="left" title="Estel Docs" mode="modal">
|
||||
|
||||
<UContentSearchButton class="lg:hidden" />
|
||||
<div class="ml-auto flex items-center space-x-2">
|
||||
<UColorModeSwitch />
|
||||
<template #title>
|
||||
<LogoPro class="h-5 w-auto" />
|
||||
</template>
|
||||
|
||||
<UNavigationMenu :items="items" />
|
||||
<template #body>
|
||||
<UNavigationMenu :items="items" orientation="vertical" class="-mx-2.5" />
|
||||
<ContentDirectory />
|
||||
</template>
|
||||
|
||||
<!-- Settings Button -->
|
||||
<button
|
||||
class="ml-auto p-2 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
||||
title="页面设置"
|
||||
@click="isSettingsOpen = !isSettingsOpen"
|
||||
>
|
||||
<svg
|
||||
class="w-5 h-5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
|
||||
/>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
||||
/>
|
||||
<template #right>
|
||||
<UContentSearchButton class="lg:hidden" />
|
||||
<UColorModeSwitch />
|
||||
<button
|
||||
class=" p-2 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
||||
title="页面设置" @click="isSettingsOpen = !isSettingsOpen">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- User Actions - Mobile and Desktop -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<button
|
||||
@click="handleLoginRegister('login')"
|
||||
class="px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors"
|
||||
>
|
||||
|
||||
<UTooltip text="Open on GitHub" :kbds="['meta', 'G']">
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="ghost"
|
||||
to="https://github.com/nuxt/ui"
|
||||
target="_blank"
|
||||
icon="i-simple-icons-github"
|
||||
aria-label="GitHub"
|
||||
/>
|
||||
</UTooltip>
|
||||
<div class="flex items-center space-x-2">
|
||||
<button @click="handleLoginRegister('login')"
|
||||
class="px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors">
|
||||
登录
|
||||
</button>
|
||||
<button
|
||||
@click="handleLoginRegister('register')"
|
||||
class="text-sm font-medium text-white bg-primary rounded-md px-3 py-2 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors"
|
||||
>
|
||||
<button @click="handleLoginRegister('register')"
|
||||
class="text-sm font-medium text-white bg-primary rounded-md px-3 py-2 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors">
|
||||
注册
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Theme Settings Panel -->
|
||||
<ThemeSettings :is-open="isSettingsOpen" @close="isSettingsOpen = false" />
|
||||
</Header>
|
||||
</template>
|
||||
|
||||
|
||||
</UHeader>
|
||||
|
||||
<!-- Theme Settings Panel -->
|
||||
<ThemeSettings :is-open="isSettingsOpen" @close="isSettingsOpen = false" />
|
||||
|
||||
<!-- 登录模态框 -->
|
||||
<UModal v-model:open="isLoginModalOpen" title="登录" :dismissible="false">
|
||||
<template #body>
|
||||
|
Reference in New Issue
Block a user