<template>
  <div class="header grid min-h-[160px] w-full bg-cyan-800 flex flex-col">
    <div class="w-full h-[100px] flex max-w-screen-xl my-0 mx-auto justify-between items-center">
      <div class="logo">
        <a href="/"> <img src="@/assets/img/logo_4dge_cn.png" alt="logo" /></a>
      </div>
      <div class="menu">
        <n-dropdown :options="options" @select="handleSelect">
          <n-button type="primary" ghost>{{ locale === 'zh' ? $t('zh') : $t('en') }}</n-button>
        </n-dropdown>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { NDropdown, NButton } from 'naive-ui'
// import { SearchOutline } from '@vicons/ionicons5'

const { t, locale } = useI18n()

const options = ref([
  {
    label: t('zh'),
    key: 'zh',
  },
  {
    label: t('en'),
    key: 'en',
  },
])

const handleSelect = (key: string) => {
  locale.value = key
  localStorage.setItem('locale', key)
  location.reload();

}
onMounted(() => {
  const localeValue = localStorage.getItem('locale') || 'en'
  locale.value = String(localeValue)
  document.title = t('web_title')
})
</script>
<style>
.header {
  background-image: url('@/assets/img/banner_bg2.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: top center;
}
</style>
