<script setup lang="ts">
import { useFullscreen } from '@vueuse/core';
import { useAppStore } from '@/store/modules/app';
import { useThemeStore } from '@/store/modules/theme';
import { GLOBAL_HEADER_MENU_ID } from '@/constants/app';
import GlobalLogo from '../global-logo/index.vue';
import GlobalBreadcrumb from '../global-breadcrumb/index.vue';
// import GlobalSearch from '../global-search/index.vue';
import ThemeButton from './components/theme-button.vue';
import UserAvatar from './components/user-avatar.vue';
import { useRouter } from 'vue-router';
import { Home20Regular } from '@vicons/fluent'



const router = useRouter();

defineOptions({
  name: 'GlobalHeader'
});

interface Props {
  /** Whether to show the logo */
  showLogo?: App.Global.HeaderProps['showLogo'];
  /** Whether to show the menu toggler */
  showMenuToggler?: App.Global.HeaderProps['showMenuToggler'];
  /** Whether to show the menu */
  showMenu?: App.Global.HeaderProps['showMenu'];
}

defineProps<Props>();

const appStore = useAppStore();
const themeStore = useThemeStore(); 
const { isFullscreen, toggle } = useFullscreen();
</script>

<template>
  <!-- 组件框架 - 顶部菜单栏 -->
  <DarkModeContainer class="h-full flex-y-center px-12px shadow-header">
    <GlobalLogo v-if="showLogo" class="h-full" :style="{ width: themeStore.sider.width + 'px' }" />
    <MenuToggler v-if="showMenuToggler" :collapsed="appStore.siderCollapse" @click="appStore.toggleSiderCollapse" />
    <div v-if="showMenu" :id="GLOBAL_HEADER_MENU_ID" class="h-full flex-y-center flex-1-hidden"></div>
    <div v-else class="h-full flex-y-center flex-1-hidden">
      <GlobalBreadcrumb v-if="!appStore.isMobile" class="ml-12px" />
    </div>
    <div class="h-full flex-y-center justify-end">
      <!-- 全局搜索 -->
      <!-- <GlobalSearch /> -->
      <NButton @click="router.push('/demo')" style="margin-right: 20px">
        <n-icon size="18">
          <Home20Regular />
        </n-icon>
        <span style="display: inline-block; margin-left: 5px">可视化大屏</span>
      </NButton>

      <!-- 全屏 -->
      <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>
