<template>
  <div 
    class="placeholder-image" 
    :style="{ 
      width: width + 'px', 
      height: height + 'px',
      borderRadius: rounded ? '50%' : '8px'
    }"
  >
    <div class="placeholder-content">
      <div class="placeholder-icon">{{ icon }}</div>
      <div v-if="showText" class="placeholder-text">{{ text }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  width?: number
  height?: number
  text?: string
  icon?: string
  showText?: boolean
  rounded?: boolean
}

withDefaults(defineProps<Props>(), {
  width: 100,
  height: 100,
  text: '图片',
  icon: '🖼️',
  showText: true,
  rounded: false
})
</script>

<style scoped>
.placeholder-image {
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #999;
}

.placeholder-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.placeholder-text {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

/* 小尺寸时隐藏文字 */
.placeholder-image[style*="width: 32px"] .placeholder-text,
.placeholder-image[style*="width: 40px"] .placeholder-text {
  display: none;
}

.placeholder-image[style*="width: 32px"] .placeholder-icon,
.placeholder-image[style*="width: 40px"] .placeholder-icon {
  font-size: 16px;
  margin-bottom: 0;
}
</style>
