<template>
  <HeaderNav headerText="消息通知"></HeaderNav>
  <div class="notifi-index">
    <div class="notifi-classifi pf600 fs18 fc121212">
      <div
        class="classifi-item"
        :class="current == 'insite' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('insite')">
        站内信
        <div class="active-line" v-if="current == 'insite'"></div>
      </div>
      <div
        class="classifi-item"
        :class="current == 'sys' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('sys')">
        系统通知
        <div class="active-line" v-if="current == 'sys'"></div>
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import HeaderNav from "../index/components/HeaderNav.vue";
  import InsiteMessage from "./InsiteMessage.vue";
  import SysMessage from "./SysMessage.vue";
  import { ref, computed } from "vue";

  const current = ref("insite");
  const componentsMap = {
    insite: InsiteMessage,
    sys: SysMessage,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

  const messageChange = (key) => {
    current.value = key;
  };
</script>
<style lang="less" scoped>
  .notifi-index {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;

    .notifi-classifi {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-end;
      margin-top: 48px;
      width: 345px;
      height: 24px;

      .classifi-item {
        position: relative;
        margin-left: 43px;

        .active-line {
          position: absolute;
          bottom: -6px;
          left: 50%;
          transform: translateX(-50%);
          width: 20px;
          height: 3px;
          background-color: #323233;
          border-radius: 2px;
        }

        &:first-child {
          margin-left: 0;
        }
      }

      .current-classifi {
        font-family: "PingFang SC";
        font-style: normal;
        font-weight: 600;
        font-size: 18px;
        color: #121212;
        transition: color 0.3s, font-size 0.3s;
      }
    }
  }
</style>
