<template>
  <div>
    <div class="home-header d-flex flex-end full-width">
      <div class="d-flex flex-column">
        <!-- 保留注释掉的云平台按钮代码 -->
        <!-- <div class="d-flex" style="width: 3.375rem; cursor: pointer">
          <div class="d-flex">
            <img
              style="width: 0.4375rem; height: 0.4375rem"
              src="../../../assets/images/yunpingtai.png"
              mode="scaleToFill"
            />
          </div>
          <div class="home-btn" @click="handleIconClick">
            {{ leftName }}
            <div>
              <dv-decoration-3
                style="width: 1.625rem; height: 0.0625rem; padding-top: 00.0375rem"
              />
            </div>
          </div>
        </div> -->
        <div class="header-title">{{ appName }}</div>
        <div class="d-flex a-c flex-end" style="margin-top:5px">
          <div>
            <span class="header-time">{{ currentTime }}</span>
            <span class="header-day">{{ currentDay }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentTime: "",
      currentDay: "",
      intervalId: null,
    };
  },
  mounted() {
    this.updateTime();
    this.intervalId = setInterval(this.updateTime, 1000);
  },
  computed: {
    appName() {
      return this.$store.state.app_name;
    },
    leftName() {
      return this.$store.state.leftName;
    },
  },
  beforeDestroy() {
    clearInterval(this.intervalId);
  },
  destroyed() {
    clearInterval(this.intervalId);
  },
  methods: {
    handleIconClick() {
      if (this.appName == "江夏住宅小区电梯大数据管理平台") {
        this.$router.push("/");
      } else {
        window.close();
      }
    },
    updateTime() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, "0");
      const day = String(now.getDate()).padStart(2, "0");
      const hour = String(now.getHours()).padStart(2, "0");
      const minute = String(now.getMinutes()).padStart(2, "0");
      const second = String(now.getSeconds()).padStart(2, "0");
      this.currentDay = `${year}-${month}-${day}`;
      this.currentTime = `${hour}:${minute}:${second}`;
    },
  },
};
</script>

<style lang="scss" scoped>
.home-header {
  width: 100%;
  height: 1.3rem;
  background: 
    linear-gradient(
      135deg,
      rgba(10, 51, 199, 0.9) 0%,
      rgba(8, 83, 156, 0.85) 50%,
      rgba(6, 115, 113, 0.8) 100%
    ),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M30,10 L10,30 M90,10 L70,30 M10,70 L30,90 M70,90 L90,70" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></svg>');
  background-size: 100% 100%, 1.6rem 1.6rem;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  padding: 0 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  border-bottom: 1px solid rgba(0, 190, 253, 0.3);
  
  &::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(0, 190, 253, 0.6),
      transparent
    );
  }
}

.header-title {
  font-size: 0.35rem;
  line-height: 0.4rem;
  color: #e8ffff;
  font-weight: bold;
  text-shadow: 
    0 0 10px rgba(0, 190, 253, 0.8),
    0 0 20px rgba(0, 190, 253, 0.5);
  margin-top: 0.2rem;
  letter-spacing: 1px;
  position: relative;
  display: inline-block;
  
  &::after {
    content: "";
    position: absolute;
    bottom: -0.05rem;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(0, 190, 253, 0.8),
      transparent
    );
  }
}

.header-time {
  color: #87ccff;
  font-size: 0.28rem;
  padding-right: 0.2rem;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(135, 204, 255, 0.5);
  position: relative;
  
  
}

.header-day {
  font-size: 0.22rem;
  font-weight: bold;
  color: #87ccff;
  text-shadow: 0 0 5px rgba(135, 204, 255, 0.3);
  position: relative;
  

}

.home-btn {
  font-size: 0.225rem;
  line-height: 14px;
  color: #ffffff;
  text-shadow: 0 0 0.8em #00befd;
  padding-top: 0.125rem;
  padding-left: 0.125rem;
  transition: all 0.3s ease;
  
  &:hover {
    text-shadow: 0 0 1em #00befd;
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .home-header {
    height: 1rem;
    padding: 0 0.3rem;
  }
  
  .header-title {
    font-size: 0.28rem;
    margin-top: 0.15rem;
  }
  
  .header-time {
    font-size: 0.24rem;
    padding-right: 0.15rem;
  }
  
  .header-day {
    font-size: 0.18rem;
  }
}
</style>