2023-11-17 08:45:00 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed } from 'vue';
|
|
|
|
import { useFullscreen } from '@vueuse/core';
|
|
|
|
import { useAppStore } from '@/store/modules/app';
|
|
|
|
import { useThemeStore } from '@/store/modules/theme';
|
|
|
|
import { useRouteStore } from '@/store/modules/route';
|
|
|
|
import HorizontalMenu from '../global-menu/base-menu.vue';
|
|
|
|
import GlobalLogo from '../global-logo/index.vue';
|
|
|
|
import GlobalBreadcrumb from '../global-breadcrumb/index.vue';
|
2024-03-06 10:59:40 +08:00
|
|
|
import GlobalSearch from '../global-search/index.vue';
|
2024-03-24 03:02:08 +08:00
|
|
|
import { useMixMenuContext } from '../../context';
|
2023-11-17 08:45:00 +08:00
|
|
|
import ThemeButton from './components/theme-button.vue';
|
|
|
|
import UserAvatar from './components/user-avatar.vue';
|
|
|
|
|
2023-12-14 21:45:29 +08:00
|
|
|
defineOptions({
|
|
|
|
name: 'GlobalHeader'
|
|
|
|
});
|
2023-11-17 08:45:00 +08:00
|
|
|
|
|
|
|
interface Props {
|
2023-12-14 21:45:29 +08:00
|
|
|
/** Whether to show the logo */
|
2023-11-17 08:45:00 +08:00
|
|
|
showLogo?: App.Global.HeaderProps['showLogo'];
|
2023-12-14 21:45:29 +08:00
|
|
|
/** Whether to show the menu toggler */
|
2023-11-17 08:45:00 +08:00
|
|
|
showMenuToggler?: App.Global.HeaderProps['showMenuToggler'];
|
2023-12-14 21:45:29 +08:00
|
|
|
/** Whether to show the menu */
|
2023-11-17 08:45:00 +08:00
|
|
|
showMenu?: App.Global.HeaderProps['showMenu'];
|
|
|
|
}
|
|
|
|
|
2024-01-25 23:24:35 +08:00
|
|
|
defineProps<Props>();
|
|
|
|
|
|
|
|
const appStore = useAppStore();
|
|
|
|
const themeStore = useThemeStore();
|
|
|
|
const routeStore = useRouteStore();
|
|
|
|
const { isFullscreen, toggle } = useFullscreen();
|
|
|
|
const { menus } = useMixMenuContext();
|
|
|
|
|
2023-11-17 08:45:00 +08:00
|
|
|
const headerMenus = computed(() => {
|
|
|
|
if (themeStore.layout.mode === 'horizontal') {
|
|
|
|
return routeStore.menus;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (themeStore.layout.mode === 'horizontal-mix') {
|
|
|
|
return menus.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-05-24 02:12:33 +08:00
|
|
|
<DarkModeContainer class="h-full flex-y-center px-12px shadow-header">
|
2023-11-17 08:45:00 +08:00
|
|
|
<GlobalLogo v-if="showLogo" class="h-full" :style="{ width: themeStore.sider.width + 'px' }" />
|
|
|
|
<HorizontalMenu v-if="showMenu" mode="horizontal" :menus="headerMenus" class="px-12px" />
|
2024-03-03 10:32:00 +08:00
|
|
|
<div v-else class="h-full flex-y-center flex-1-hidden">
|
2023-11-17 08:45:00 +08:00
|
|
|
<MenuToggler v-if="showMenuToggler" :collapsed="appStore.siderCollapse" @click="appStore.toggleSiderCollapse" />
|
|
|
|
<GlobalBreadcrumb v-if="!appStore.isMobile" class="ml-12px" />
|
|
|
|
</div>
|
2024-03-03 10:32:00 +08:00
|
|
|
<div class="h-full flex-y-center justify-end">
|
2024-03-06 10:59:40 +08:00
|
|
|
<GlobalSearch />
|
2023-11-17 08:45:00 +08:00
|
|
|
<FullScreen v-if="!appStore.isMobile" :full="isFullscreen" @click="toggle" />
|
|
|
|
<LangSwitch :lang="appStore.locale" :lang-options="appStore.localeOptions" @change-lang="appStore.changeLocale" />
|
|
|
|
<ThemeSchemaSwitch
|
|
|
|
:theme-schema="themeStore.themeScheme"
|
|
|
|
:is-dark="themeStore.darkMode"
|
|
|
|
@switch="themeStore.toggleThemeScheme"
|
|
|
|
/>
|
|
|
|
<ThemeButton />
|
|
|
|
<UserAvatar />
|
|
|
|
</div>
|
|
|
|
</DarkModeContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped></style>
|