index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!--
  2. * @Descripttion: 状态指示器
  3. * @version: 1.0
  4. * @Author: sakuya
  5. * @Date: 2021年11月11日09:30:12
  6. * @LastEditors:
  7. * @LastEditTime:
  8. -->
  9. <template>
  10. <div :class="['sc-status-indicator', content && 'hasValue']">
  11. <span class="sc-state" :class="[{ 'sc-status-processing': pulse }, 'sc-state-bg--' + type]"></span>
  12. {{ content }}
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. type: { type: String, default: "primary" },
  19. pulse: { type: Boolean, default: false },
  20. content: { type: String, default: "" }
  21. }
  22. }
  23. </script>
  24. <style scoped>
  25. .sc-status-indicator {display: flex;align-items: center;}
  26. .sc-state {
  27. display: inline-block;
  28. background: #000;
  29. width: 8px;
  30. height: 8px;
  31. border-radius: 50%;
  32. vertical-align: middle;
  33. }
  34. .sc-status-processing {
  35. position: relative;
  36. }
  37. .sc-status-processing:after {
  38. position: absolute;
  39. top: 0px;
  40. left: 0px;
  41. width: 100%;
  42. height: 100%;
  43. border-radius: 50%;
  44. background: inherit;
  45. content: "";
  46. animation: warn 1.2s ease-in-out infinite;
  47. }
  48. .sc-state-bg--offline {
  49. background: rgba(0, 0, 0, 0.25);
  50. }
  51. .sc-state-bg--primary {
  52. background: var(--el-color-primary);
  53. }
  54. .sc-state-bg--success {
  55. background: var(--el-color-success);
  56. }
  57. .sc-state-bg--warning {
  58. background: var(--el-color-warning);
  59. }
  60. .sc-state-bg--danger {
  61. background: var(--el-color-danger);
  62. }
  63. .sc-state-bg--info {
  64. background: var(--el-color-info);
  65. }
  66. .sc-state-bg--orange {
  67. background: #fa8c16;
  68. }
  69. .sc-status-indicator.hasValue .sc-state {
  70. margin-right: 6px;
  71. }
  72. @keyframes warn {
  73. 0% {
  74. transform: scale(0.5);
  75. opacity: 1;
  76. }
  77. 30% {
  78. opacity: 0.7;
  79. }
  80. 100% {
  81. transform: scale(2.5);
  82. opacity: 0;
  83. }
  84. }
  85. </style>