custom-panel.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <el-card shadow="hover">
  3. <div class="panel-top">
  4. <div class="panel-name">{{prop.title}}</div>
  5. <div :class="['panel-refresh', { 'panel-refresh-rotate': roading }]" @click="handleRefresh">
  6. <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  7. <path d="M16.7167 6.66667C15.4895 4.19712 12.9411 2.5 9.99637 2.5C7.05158 2.5 4.56062 4.19712 3.33337 6.66667" stroke="#ADBFD7" stroke-linecap="round"/>
  8. <path d="M3.33337 3.33334V6.66667" stroke="#ADBFD7" stroke-linecap="round"/>
  9. <path d="M6.15845 6.66666H3.33337" stroke="#ADBFD7" stroke-linecap="round"/>
  10. <path d="M3.33337 13.3333C4.56062 15.8029 7.109 17.5 10.0538 17.5C12.9985 17.5 15.4895 15.8029 16.7167 13.3333" stroke="#ADBFD7" stroke-linecap="round"/>
  11. <path d="M16.7167 16.6667V13.3333" stroke="#ADBFD7" stroke-linecap="round"/>
  12. <path d="M13.8916 13.3333H16.7167" stroke="#ADBFD7" stroke-linecap="round"/>
  13. </svg>
  14. </div>
  15. </div>
  16. <slot></slot>
  17. </el-card>
  18. </template>
  19. <script setup lang="ts" name="panel-top">
  20. const prop = defineProps({
  21. title: {
  22. type: String,
  23. default: ''
  24. }
  25. })
  26. const emit = defineEmits(['refresh']);
  27. const roading = ref(false);
  28. const handleRefresh = () => {
  29. if (roading.value) return;
  30. roading.value = true;
  31. setTimeout(() => {
  32. roading.value = false;
  33. }, 1000);
  34. emit('refresh');
  35. };
  36. </script>
  37. <style scoped lang="scss">
  38. .panel-top {
  39. display: flex;
  40. justify-content: space-between;
  41. align-items: center;
  42. }
  43. .panel-name {
  44. line-height: 22px;
  45. font-family: Source Han Sans SC;
  46. font-weight: 500;
  47. font-size: 18px;
  48. color: rgba(18, 18, 18, 1);
  49. position: relative;
  50. padding-left: 12px;
  51. &::after {
  52. content: '';
  53. position: absolute;
  54. left: 0;
  55. top: 50%;
  56. transform: translateY(-50%);
  57. width: 4px;
  58. height: 14px;
  59. background-color: rgb(22, 122, 240, 1);
  60. }
  61. }
  62. .panel-refresh-rotate svg {
  63. animation: rotate 1s linear infinite;
  64. transform-origin: center center;
  65. }
  66. @keyframes rotate {
  67. 0% {
  68. transform: rotate(0deg);
  69. transform-origin: center center;
  70. }
  71. 100% {
  72. transform: rotate(-360deg);
  73. transform-origin: center center;
  74. }
  75. }
  76. </style>