SkeletonCard.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="skeleton-card" :style="{ width: width, borderRadius: radius }">
  3. <!-- 封面骨架 -->
  4. <div class="skeleton" :style="{ height: imageHeight }"></div>
  5. <!-- 内容骨架 -->
  6. <div class="skeleton-body" :style="{ padding: bodyPadding }">
  7. <!-- 时间行 -->
  8. <div class="skeleton skeleton-line" style="width: 40%; height: 14px; margin-bottom: 10px;"></div>
  9. <!-- 标题 -->
  10. <div class="skeleton skeleton-line" style="width: 90%; height: 18px; margin-bottom: 8px;"></div>
  11. <div class="skeleton skeleton-line" style="width: 70%; height: 18px; margin-bottom: 12px;"></div>
  12. <!-- 描述 -->
  13. <div class="skeleton skeleton-line" style="width: 100%; height: 13px; margin-bottom: 16px;"></div>
  14. <!-- 作者行 -->
  15. <div class="skeleton-row">
  16. <div class="skeleton skeleton-avatar"></div>
  17. <div class="skeleton skeleton-line" style="width: 80px; height: 14px;"></div>
  18. <div style="flex: 1;"></div>
  19. <div class="skeleton skeleton-line" style="width: 60px; height: 14px;"></div>
  20. </div>
  21. <!-- 按钮行 -->
  22. <div class="skeleton-row" style="margin-top: 12px; gap: 8px;">
  23. <div class="skeleton skeleton-btn"></div>
  24. <div class="skeleton skeleton-btn"></div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script setup>
  30. defineProps({
  31. width: {
  32. type: String,
  33. default: '345px',
  34. },
  35. imageHeight: {
  36. type: String,
  37. default: '204px',
  38. },
  39. bodyPadding: {
  40. type: String,
  41. default: '16px',
  42. },
  43. radius: {
  44. type: String,
  45. default: '12px',
  46. },
  47. })
  48. </script>
  49. <style scoped>
  50. .skeleton-card {
  51. background: #ffffff;
  52. border: 1px solid #f1f5f9;
  53. overflow: hidden;
  54. }
  55. .skeleton-body {
  56. background: white;
  57. }
  58. .skeleton-line {
  59. display: block;
  60. border-radius: 4px;
  61. }
  62. .skeleton-avatar {
  63. width: 24px;
  64. height: 24px;
  65. border-radius: 50%;
  66. flex-shrink: 0;
  67. }
  68. .skeleton-btn {
  69. flex: 1;
  70. height: 36px;
  71. border-radius: 6px;
  72. }
  73. .skeleton-row {
  74. display: flex;
  75. align-items: center;
  76. gap: 8px;
  77. }
  78. </style>