<!-- 移动端头部 -->
<script lang="ts" setup name="HeaderMobile">
import { ArrowLeftBold, House } from '@element-plus/icons-vue'
const route = useRoute()
const router = useRouter()
const goBack = (type: 'back' | 'home') => {
  if (type === 'back') {
    router.go(-1)
  }
  else if (type === 'home') {
    router.push('/')
  }
}
</script>

<template>
  <div>
    <div v-if="route.meta.isHeader" class="header-mobile">
      <div v-if="route.meta.isBack">
        <el-icon :size="25" @click="goBack('back')">
          <arrow-left-bold />
        </el-icon>
      </div>
      <div v-else style="width: 24px;" />
      <div class="name">
        {{ route.meta.title }}
      </div>
      <el-icon v-if="route.meta.isHome" :size="25" @click="goBack('home')">
        <house />
      </el-icon>
      <div v-else style="width: 24px;" />
    </div>
    <div v-if="route.meta.isHeader" class="occupying" />
  </div>
</template>

<style lang="scss" scoped>
.header-mobile {
  width: 100%;
  background-color: #0d76d4;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  // padding: 0 10px;
  position: fixed;
  top: 0;
  color: #fff;

  .name {
    font-size: 20px;
  }
}

.occupying {
  height: 40px;
  background-color: transparent;
  width: 100%;
}
</style>
