<template>
  <el-container>
    <el-header class="header-bg">
      <div class="header-content">
        <div class="logo">
          <img src="@/assets/logo.png" alt="Logo" />
          <span>深海应急搜捞数据管理可视化平台</span>
        </div>
        <el-menu
          mode="horizontal"
          :default-active="activeMenu"
          :ellipsis="false"
          router
          class="main-menu"
        >
          <el-menu-item index="/">首页</el-menu-item>
          <el-menu-item index="/demand">任务需求</el-menu-item>
          <el-menu-item index="/search">任务检索</el-menu-item>
          <el-menu-item index="/statistics">统计分析</el-menu-item>
          <el-menu-item index="/contact">联系我们</el-menu-item>
        </el-menu>
      </div>
      <img class="bg" v-show="activeMenu == '/' || activeMenu == '/statistics'" src="@/assets/bg.jpg" alt="背景图片" />
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>
    <el-footer>
      <div>
        <div class="title">
          <img src="@/assets/logo.png" alt="Logo" />
          <span>中国科学院深海科学与工程研究所</span>
        </div>
        <div class="info">
          <div class="item">
            <div class="icon">
              <img src="@/assets/icon_@.png" alt="Logo" />
            </div>
            <span>联系方式：chencx@idsse.ac.cn</span>
          </div>
          <div class="item">
            <div class="icon">
              <img src="@/assets/icon_area.png" alt="Logo" />
            </div>
            <span>地址：三亚市鹿回头路28号</span>
          </div>
          <div class="item">
            <div class="icon">
              <img src="@/assets/icon_mail.png" alt="Logo" />
            </div>
            <span>邮编：572000</span>
          </div>
        </div>
      </div>
    </el-footer>
  </el-container>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'

const activeMenu = ref('/')

const route = useRoute()

// 或者只监听特定属性
watch(
    () => route.path,
    (newPath) => {
      activeMenu.value = newPath
    }
)

</script>

<style lang="scss" scoped>
.el-container {
  min-height: 100vh;
  background: #fff;
}

.header-bg {
  background-image: url(@/assets/footer_bg.png);
}

.el-header {
  position: relative;
  color: white;
  height: 100px;
  z-index: 0;

  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 120px);
    z-index: -1;
  }

  .header-content {
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .logo {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-right: 40px;

      img {
        width: 56px;
        height: 56px;
      }

      span {
        font-size: 30px;
        font-weight: bold;
        color: white;
      }
    }
  }
}

.main-menu {
  background-color: transparent;
  border-bottom: none;

  :deep(.el-menu-item) {
    color: white;
    font-size: 18px;

    &.is-active {
      background-color: transparent;
      color: white;
    }

    &:hover {
      background-color: transparent;
    }
  }
}

.el-main {
  background-color: transparent;
  padding: 0;
  z-index: 2;

}

.el-footer {
  height: 120px;
  background-image: url(@/assets/footer_bg.png);
  display: flex;
  justify-content: center;
  align-items: center;

  .title {
    display: flex;
    align-items: center;
    font-size: 18px;
    color: #fff;
    margin-bottom: 20px;

    img {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
  }

  .info {
    display: flex;
    font-size: 14px;
    color: #fff;

    .item {
      display: flex;
      align-items: center;
      margin-right: 20px;

      .icon {
        width: 30px;
        height: 30px;
        background: #263954;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
        margin-right: 5px;

        img {
          width: 13px;
          height: 13px;
        }
      }

    }
  }
}
</style>
