<template>
  <div class="d-flex jc-center title_wrap">
    <div class="d-flex jc-center">
      <div class="title">
        <span class="title-text">{{ title }}</span>
      </div>
    </div>
    <div class="timers">
      {{ formatDate(now, "YYYY年mm月dd日 HH:MM:SS WWW") }}
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import dayjs from "dayjs";
import { useNow, useTitle } from "@vueuse/core";
import { formatDate } from "@/utils/formatTime";
import { useThemeConfig } from "@/stores/themeConfig";
import { storeToRefs } from "pinia";

const storesThemeConfig = useThemeConfig();
const { themeConfig } = storeToRefs(storesThemeConfig);

const emit = defineEmits(["changeDate"]);
const title = ref("12345政务服务便民热线");
const now = useNow(); // 获取当前时间
const timeValue = ref<any>([
  dayjs().subtract(1, "month").toDate(),
  dayjs().toDate(),
]); //默认近一个月
emit("changeDate", timeValue.value);

onMounted(() => {
  // title.value = `${themeConfig.value.cityName}随手拍`;
  title.value = "自贡随手拍";
  useTitle(title.value);
});
</script>

<style scoped lang="scss">
.title_wrap {
  height: 60px;
  background-size: cover;
  background-position: center center;
  position: relative;

  .time-picker {
    position: absolute;
    left: 30px;
    top: 40px;
    font-size: 14px;
    z-index: 9;
  }

  .timers {
    position: absolute;
    right: 30px;
    top: 40px;
    font-size: 18px;
    display: flex;
    align-items: center;
  }
}

.title {
  position: relative;
  text-align: center;
  height: 90px;
  line-height: 90px;

  .title-text {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 2px;
    width: 100%;
    color: #fff;
  }
}
</style>
