<template>
  <div class="data-loader">
    <div v-if="loading" class="loading-indicator">
      {{ loadingMessage }}
    </div>
    <div v-else-if="error" class="error-message">
      {{ errorMessage }}
    </div>
    <div v-else-if="empty" class="empty-message">
      {{ emptyMessage }}
    </div>
    <div v-else>
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DataLoader',
  props: {
    loading: {
      type: Boolean,
      required: true,
      default: false
    },
    error: {
      type: Boolean,
      required: true,
      default: false
    },
    empty: {
      type: Boolean,
      required: true,
      default: false
    },
    loadingMessage: {
      type: String,
      default: '数据加载中...'
    },
    errorMessage: {
      type: String,
      default: '数据加载失败，请稍后重试。'
    },
    emptyMessage: {
      type: String,
      default: '暂无数据'
    }
  }
}
</script>

<style scoped>
.data-loader {
  width: 100%;
}

.loading-indicator,
.error-message,
.empty-message {
  text-align: center;
  padding: 20px;
  font-size: 16px;
}

.loading-indicator {
  color: #666;
}

.error-message {
  color: #ff4d4f;
}

.empty-message {
  color: #999;
}
</style>