<script setup lang="ts">
import { reactive } from "vue";
import dayjs from 'dayjs';
import type {DateDataType} from "./index.d"
import {useSettingStore} from "@/stores/index"

const dateData = reactive<DateDataType>({
  dateDay: "",
  dateYear: "",
  dateWeek: "",
  timing: null
});

const { setSettingShow} =useSettingStore()
const weekday= ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
const timeFn = () => {
  dateData.timing = setInterval(() => {
    dateData.dateYear = dayjs().format("YYYY年MM月DD日");
    dateData.dateDay = dayjs().format("HH:mm:ss");
    dateData.dateWeek = weekday[dayjs().day()];
  }, 1000);
};
timeFn();
const weather = [
  { icon: new URL('@/assets/img/weather/qing.png', import.meta.url).href, text: "天气：晴" },
  { icon: new URL('@/assets/img/weather/fengxiang.png', import.meta.url).href, text: "风向：东北风" },
  { icon: new URL('@/assets/img/weather/fengsu.png', import.meta.url).href, text: "风速：三级" },
  { icon: new URL('@/assets/img/weather/nengjiandu.png', import.meta.url).href, text: "能见度：200米" },
  { icon: new URL('@/assets/img/weather/wendu.png', import.meta.url).href, text: "温度：27" },
];
</script>

<template>
  <div class="d-flex jc-center title_wrap">
    <img src="../assets/img/header.png" alt="">
     <div class="zuojuxing">
        <div class="item" v-for="(item, index) in weather" :key="index">
          <img :src="item.icon" alt="图标" class="icon" />
          <span class="text">{{ item.text }}</span>
        </div>
     </div>
    <!--<div class="youjuxing"></div> -->
    <!-- <div class="guang"></div> -->
    <div class="d-flex jc-center">
      <!-- <div class="title">
        <span class="title-text"></span>
      </div> -->
    </div>
    <div class="timers">
      <span>admin</span>
      <span>{{ dateData.dateYear }}</span>
      <span>{{ dateData.dateWeek }}</span>
      <span class="dateDay">{{ dateData.dateDay }}</span>
      <!-- <div class="setting_icon"   @click="setSettingShow(true)">
          <img src="@/assets/img/headers/setting.png" alt="设置">
      </div> -->
    </div>
  </div>
</template>

<style scoped lang="scss">
.title_wrap {
  height: 112px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  // background-image: url("../assets/img/header.png");
  background-repeat: no-repeat;
  // background-size: 100% 100%;
  background-position: center center;
  position: relative;
  margin-bottom: 4px;
  .zuojuxing{
    position: absolute;
    left: 0;
    top: 0px;
    display: flex;
    align-items: center;
    line-height: 112px;
    font-size: 32px;
    color: #FFFFFF;
    .item {
      display: flex;
      align-items: center;
      margin-left: 96px; /* 每组之间的间距 */
    }

    .icon {
      width: 40px;
      height: 40px;
      margin-right: 12px; /* 图标与文字之间的间距 */
    }

    .text {
      font-size: 32px;
    }
  }
  .timers {
    position: absolute;
    right: 0;
    top: 0px;
    font-size: 32px;
    display: flex;
    align-items: center;
    line-height: 112px;
    .setting_icon {
      width: 20px;
      height: 20px;
      cursor: pointer;
      margin-left: 12px;
      img{
        width: 100%;
        height: 100%;
      }
    }
    span{
      margin-left: 96px;
    }
    .dateDay{
      margin-right: 120px;
    }
  }
}
.title {
  position: relative;
  // width: 500px;
  text-align: center;
  background-size: cover;
  color: transparent;
  height: 224px;
  line-height: 46px;

  .title-text {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 6px;
    width: 100%;
    background: linear-gradient(
      92deg,
      #0072ff 0%,
      #00eaff 48.8525390625%,
      #01aaff 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}
</style>
