<template>
  <div class="app-container home">
    <div class="" style="width: 80%;margin-left: 10%;margin-top: 20px;display: none;">
      <div class="riLi-card mt20">
        <el-calendar ref="calendar">
          <template #header="{ date }">
            <el-button-group class="top-btnGroup">
              <span type="button" class="goToday" @click="selectDate('today')">今天</span>

              <span class="top-btn year" @click="selectDate('prev-year')">
                <el-icon><ArrowLeft /></el-icon>
              </span>
              <span class="top-btn month" style="margin-left: 30px;" @click="selectDate('prev-month')">
                <el-icon><ArrowLeft /></el-icon>
              </span>
              <span class="top-btn-date">{{ date }}</span>
              <span class="top-btn month" style="margin-right: 30px;" @click="selectDate('next-month')">
                <el-icon><ArrowRight /></el-icon>
              </span>
              <span class="top-btn year" @click="selectDate('next-year')">
                <el-icon><ArrowRight /></el-icon>
              </span>
            </el-button-group>
          </template>
          <template #date-cell="{ data }">
            <div style="text-align: center;position: relative;">
              <div class="day1">
                {{ data.day.split('-').slice(2)[0] < 10 ? data.day.split('-').slice(2)[0].substring(1) : data.day.split('-').slice(2)[0] }}
                <span class="dayText today">今</span>
              </div>
            </div>
          </template>
        </el-calendar>
      </div>
    </div>
  </div>
</template>

<script setup name="Index" lang="ts">
import { initWebSocket } from '@/utils/websocket';
import type { CalendarDateType } from 'element-plus'
import { CalendarInstance } from 'element-plus/es/components/calendar/src/instance';

onMounted(() => {
  let protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'
  initWebSocket(protocol + window.location.host + import.meta.env.VITE_APP_BASE_API + "/resource/websocket");
});

const goTarget = (url:string) => {
  window.open(url, '__blank')
}
const calendar = ref<CalendarInstance>()
const selectDate = (val: CalendarDateType) => {
  if (!calendar.value) return
  calendar.value.selectDate(val)
}

const month = ref('')
const monthDate = ref('')
month.value = (new Date().getFullYear()) + '-' + (new Date().getMonth()+1)
monthDate.value = (new Date().getFullYear()) + '-' + (new Date().getMonth()+1)+(new Date().getDate())
</script>

<style scoped lang="scss">
.home {
  height: calc(100vh - 60px);
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}


// 日历
:deep(table td) {
  border: 0 !important;
}

:deep(.el-calendar__body thead th) {
  font-size: 14px;
  font-weight: 500;
  color: rgba(100,119,146,.3);
}
:deep(.el-calendar-table td){
  margin: 4px 2px 0;
  background: transparent;
}
:deep(.el-calendar-day) {
  height: 43px !important;
  line-height: 43px;
  text-align: center;
  width: 46px !important;
  position: relative;
  margin: 17px auto;
  padding: 0;
  padding-top: 1px;
}

:deep(.el-calendar-table td.is-today) {
  color: #000;
}
:deep(.el-calendar-table td.is-selected .el-calendar-day){
  color: #fff !important;
  background-color: #545ff0 !important;
  border-radius: 8px;
  box-shadow: 0px 2px 4px 0px rgba(84, 95, 240, 0.05);
}

:deep(.el-calendar-table td.is-selected .day1),:deep(.el-calendar-table td.is-selected .day2){
  color: #fff;
}
:deep(.el-calendar-table tbody tr:first-child td){
 padding-top: 0;
}
:deep(.el-calendar-table .el-calendar-day:hover) {
  background-color: rgba(78,110,242,.1);
  border-radius: 8px;
}
.day1{
  font-size: 16px;text-align: center;font-weight: bold;
}
.day2{
  font-size: 12px;text-align: center;color: rgba(30,31,36,.5);line-height: 12px;
  transform: scale(.8);
}
.today{
  display: none;
  background: #6b88ff;
}
.dayText{
  display: none;
  font-size: 12px;
  line-height: 14px;
  padding: 1px 2px;
  position: absolute;
  right: -4px;
  top: -6px;
  border-radius: 4px;
  color: #fff;
  z-index: 5;
}
:deep(.el-calendar-table td.is-today .today){
  display: block;
}
.block{
  display: block;
  position: absolute;
  right: 20px;
  top: 22px;
}
.longText {
  transform: scale(0.8);
  width: 60px;
  margin-left: -11px;
}
.riLi-card{
  background: #FFFFFF;
  box-shadow: 0px 2px 26px 0px #E0E7F0;
  border-radius: 10px;
  position: relative;
  height: 370px;
}

.mt20 {
  margin-top: 14px;
}
/* 日历顶部按钮 */
.top-btnGroup{
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
}
.top-btn-date{
  font-size: 16px;
  font-weight: 500;
  color: #2D2D2D;
  line-height: 25px;
  padding: 0 40px;
}
.top-btn{}
.top-btn.year{
  width: 22px;
  height: 22px;
  background: #E5E5E5;
  opacity: 0.38;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.top-btn.year i{
  font-size: 14px;
  cursor: pointer;
}
.top-btn.month{
  width: 15px;
  height: 15px;
  background: #E5E5E5;
  opacity: 0.38;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.top-btn.month i{
  font-size: 12px;
  cursor: pointer;
}

.goToday{
  width: 57px;
  height: 28px;
  line-height: 28px;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8E8E8 100%);
  border-radius: 7px;
  border: 1px solid #D6D6D6;
  text-align: center;
  cursor: pointer;

  font-size: 14px;
  font-weight: 500;
  color: #647792;

  position: absolute;
  right: 20px;
  // top: 20px;
}

.riLi-card{
  font-size: 18px;
  font-weight: 500;
  color: #2D2D2D;
  line-height: 25px;
  position: relative;
}

.selectCon{
  position: absolute;
  top: 23px;
  right: 23px;
  z-index: 5;
}
.xiu{
  position: absolute;
  bottom: 0;
  left: 5px;
  font-size: 12px;
  cursor: pointer;
  height: 28px;
  line-height: 28px;
}
.xiuText{
  display: block;
  background-color: #e5c03f;
}
.chu{
  position: absolute;
  bottom: 0;
  right: 5px;
  font-size: 12px;
  cursor: pointer;
  height: 28px;
  line-height: 28px;
}
.chuText{
  display: block;
  background-color: #909399;
}
</style>
