<!-- Loading.vue 组件 -->
<template>
  <transition name="fade">
    <div
      v-if="visible"
      class="loading-container">
      <div class="loading-spinner">
        <!-- 你的加载动画，比如旋转的圆圈 -->
        <svg
          viewBox="25 25 50 50"
          class="circular">
          <circle
            cx="50"
            cy="50"
            r="20"
            fill="none"
            class="path"></circle>
        </svg>
      </div>
    </div>
  </transition>
</template>

<script>
  export default {
    props: {
      visible: Boolean,
      text: String,
    },

    name: "Loading",
  };
</script>

<style scoped scss>
  @import url("../../assets/index.scss");
  .fade-enter,
  .fade-leave-to {
    opacity: 0;
  }
  .fade-leave-active,
  .fade-enter-active {
    transition: opacity 0.3s ease-in-out;
  }
  .loading-container {
    position: absolute;
    z-index: 2000;
    background-color: #ffffffe6;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 5px;
    margin: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    /* transition: opacity 1s; */
    /* animation: opacitys 0.3s linear; */
  }
  .loading-spinner {
    top: 50%;
    margin-top: -21px;
    width: 100%;
    text-align: center;
    position: absolute;
    .circular {
      height: 42px;
      width: 42px;
      animation: loading-rotate 2s linear infinite;
      .path {
        animation: loading-dash 1.5s ease-in-out infinite;
        stroke-dasharray: 90, 150;
        stroke-dashoffset: 0;
        stroke-width: 2;
        stroke: #409eff;
        stroke-linecap: round;
      }
    }
    .loading-text {
      padding: 0;
      margin: 0;
      font-size: 13px;
    }
  }
  @keyframes spin {
    100% {
      transform: rotate(1turn);
    }
  }

  @keyframes loading-dash {
    0% {
      stroke-dasharray: 1, 200;
      stroke-dashoffset: 0;
    }
    50% {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -40px;
    }
    to {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -120px;
    }
  }
</style>
