<template>
  <m-nav-bar class="navbar" v-if="navbar" />
  <div v-for="oneLevel in jsonData" class="flex-box">
    <div class="one-level-title">
      <m-icon type="biaotizhuangshi3" />
      {{ oneLevel.title }}
      <m-icon class="icon-right" type="biaotizhuangshi3" />
    </div>
    <div v-if="oneLevel.explain" class="one-level-explain box-set">
      {{ oneLevel.explain }}
    </div>
    <div class="two-flex-box" v-for="twoLevel in oneLevel.twoLevel">
      <div class="two-level-title">
        <m-icon type="biaotizhuangshi1" />
        {{ twoLevel.title }}
        <m-icon class="icon-right" type="biaotizhuangshi1" />
      </div>
      <div v-if="twoLevel.explain" class="box-set">
        {{ twoLevel.explain }}
      </div>
      <div
        class="box-set three-level-explain"
        v-for="threeLevel in twoLevel.threeLevel"
      >
        <div class="three-level-title">{{ threeLevel.title }}</div>
        <div
          class="four-level-explain"
          v-for="(item, index) in threeLevel.list"
          :key="item"
        >
          <span class="four-level-title">{{ Number(index) + 1 }}</span>
          <div>
            {{ item }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import marked from "marked";
import axios from "axios";
import { useRoute } from "vue-router";
marked.setOptions({
  renderer: new marked.Renderer(),
});
const route = useRoute();
const jsonData = ref(<any>[]);
const navbar = route.query.navbar === "false" ? false : true;
document.title = <string>route.query.markdown;
axios({
  url: `/markdown/${route.query.markdown}.json`,
}).then((res) => {
  jsonData.value = res.data.data;
});
</script>

<style scoped lang="scss">
.navbar {
  background-color: #ffffff;
  z-index: 10;
}
.flex-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 17px;
  font-family: PingFang SC;
  padding: 40px 0 20px;
  .box-set {
    width: 336px;
    border: 1px solid #498ef5;
    border-radius: 5px;
    padding: 20px;
    box-sizing: border-box;
    background-color: #f6f6f6;
    color: #5c6066;
    font-size: 15px;
    font-weight: 400;
    line-height: 23px;
    position: relative;
    margin-top: 40px;
  }
  .icon-right {
    transform: rotate(180deg);
  }
  .two-flex-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30px;
  }
  .one-level-title {
    font-size: 28px;
    font-weight: bold;
    color: #000000;
    position: relative;
    &::after {
      content: "";
      width: 100%;
      height: 4px;
      border-top: 1px dashed #498ef5;
      border-bottom: 1px solid #498ef5;
      position: absolute;
      bottom: 0;
      left: 0;
      transform: translateY(100%);
    }
  }
  .one-level-explain {
  }
  .three-level-explain {
    padding-top: 30px;
  }
  .two-level-title {
    font-size: 24px;
    font-weight: bold;
    color: #0a1a33;
  }
  .three-level-title {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 16px;
    height: 35px;
    background: #498ef5;
    border-radius: 18px;
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
    line-height: 43px;
    position: absolute;
    left: 40px;
    top: 0;
    transform: translateY(-50%);
  }
  .four-level-title {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 3px;
    margin-right: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #498ef5;
    border-radius: 50%;
    font-size: 15px;
    font-weight: 400;
    color: #fefeff;
  }
  .four-level-explain {
    display: flex;
    margin-bottom: 5px;
  }
}
</style>
