<!-- LoadingComponent.vue -->
<template>
  <div class="loading-container">
    <div class="loading-spinner"></div>
    <span v-if="showText" class="loading-text">{{ text }}</span>
  </div>
</template>

<script setup lang="ts">
interface Props {
  text?: string
  showText?: boolean
}

withDefaults(defineProps<Props>(), {
  text: '加载中...',
  showText: true,
})
</script>

<style scoped>
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f0f0f0;
  border-top-color: #409eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 14px;
  color: #909399;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
</style>
