<template>
  <div class="main-header">
    <div class="main-header-left">
      <img :src="logo" alt="图标" class="logo_img">
      <div class="title">垃圾回收监管平台</div>
      <IxDivider class="divider" vertical/>
      <IxButton class="menu-btn" icon="view-thumbnail" mode="primary" @click="menuPanel!.showMenuPanel = !menuPanel!.showMenuPanel"></IxButton>
      <TabList/>
    </div>
    <div class="main-header-right">
      <!--<div class="alert-btn">
        <IxIcon name="alert"/>
        <div>99+</div>
      </div>

      <IxDropdown placement="bottom">
        <IxButton class="language-btn" mode="text">简体</IxButton>
        <template #overlay>
          <IxMenu :dataSource="languageList" :onClick="triggerLanguageHandler" :selectable="false"/>
        </template>
      </IxDropdown>-->
      <IxDivider class="divider" vertical/>
      <UserPanel/>
    </div>
    <MenuPanel ref="menuPanel"/>
  </div>
</template>

<script lang="ts" setup>
import defaultLogo from '@/assets/images/循环.svg'
import MenuPanel from '@/pages/main-zone/menu-panel/MenuPanel.vue'
import TabList from '@/pages/main-zone/tab-list/TabList.vue'
import Strings from '@/common/utils/strings.ts'
import { useAppSettingStore } from '@/common/app/app-setting-store.ts'
import UserPanel from '@/pages/main-zone/header-bar/UserPanel.vue'
import AppApi from '@/common/app/app-api.ts'

const appSettingStore = useAppSettingStore()
const logo = computed(() => {
  return Strings.isBlank(appSettingStore.logo) ? defaultLogo : AppApi.fileUrl(appSettingStore.logo!)
})

const menuPanel = ref<InstanceType<typeof MenuPanel>>()

/* const languageList: MenuData[] = [
 {type: 'item', key: 'zh', label: '简体'},
 {type: 'item', key: 'en', label: 'English'},
 ]

 function triggerLanguageHandler(opt: MenuClickOptions) {
 HeaderBarApi.modifyUserSetting({language: opt.key as string})
 .then(reloadUserInfo)
 } */
</script>

<style lang="stylus" scoped>
.main-header {
  box-sizing: border-box;
  width: 100%;
  height: 4.1rem;
  display: flex;
  border-bottom: 0.1rem solid #EEEEEE;
  justify-content: space-between;
  padding: .5rem;
  box-shadow: 0 1px 4px 0 var(--wh-box-shadow-color);
}

.main-header-left,
.main-header-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-header-left {
  .menu-btn {
    height: 100%;
    width: 4rem;
  }

  .title {
    color: rgb(22 93 255);
    font-weight: bold;
    font-size: 1.25rem
  }

  .logo_img {
    height: 80%;
    margin: 0 1rem;
  }

  .divider {
    height: 100%
  }

  .tab_list {
    margin-left: 1rem;
  }
}


.main-header-right {
  .alert-btn {
    position: relative;
    font-size: 2rem;
    width: 3rem;
    text-align: center;
    cursor: pointer;

    & > div:last-child {
      position: absolute;
      top: 0;
      left: 0.4rem;
      font-size: 1rem;
      background-color: #D9534F;
      color: #FFFFFF;
      border-radius: 50%;
      width: 2.5rem;
    }
  }

  .language-btn {
    margin: 0 1rem;
  }

  .divider {
    height: 100%
  }
}
</style>
