<template>
  <div class="home-title-nav">
    <span class="l-span">
      <img src="@/assets/images/logo.png" alt="" @click="toTarget" style="cursor: pointer"/>
    </span>
    <span class="title-text">国网四川电力交易中心运行环境风险监测</span>
    <span class="r-span">{{date}} {{week}} {{time}}</span>
  </div>
</template>
<script setup lang="ts">
import {parseTime} from "@/utils/ruoyi"
import {onMounted} from "vue";
import {useRouter} from "vue-router";

const router = useRouter()
const week = ref("");
const date = ref("");
const time = ref("");
const weekText = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
onMounted(()=>{
  getWeek()
  setInterval(()=>{
    getWeek()
  },1000)
})

function getWeek(){
  let dayOfWeek = new Date().getDay();
  date.value = parseTime(new Date(),'{y}-{m}-{d}')
  time.value = parseTime(new Date(),'{h}:{i}:{s}')
  week.value = weekText[dayOfWeek]
}

function toTarget(){
  router.push({path:"/link/pp-link"})
}

</script>
