<template>
  <div class="fullscreen-spin" v-if="loading">
    <div class="spin">
      <el-progress class="progress" :percentage="progress" :show-text="false" />
      <div class="text">{{ `${tip} ${progress}%` }}</div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ElProgress } from "element-plus"
withDefaults(
  defineProps<{
    loading?: boolean
    tip?: string
    progress: number
  }>(),
  {
    loading: false,
    tip: "",
    progress: 0
  }
)
</script>

<style lang="scss" scoped>
.fullscreen-spin {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000000000;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.6);
  .spin {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .progress {
      width: 280px;
      height: 6px;
      &::v-deep(.el-progress-bar) {
        .el-progress-bar__inner {
          background-color: #20bdff;
        }
        .el-progress-bar__outer {
          background-color: rgba(255, 255, 255, 0.3);
        }
      }
    }
    .text {
      margin-top: 24px;
      font-weight: 400;
      font-size: 14px;
      color: #ffffff;
      line-height: 20px;
    }
  }
}
</style>
