StatsSection.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <section class="stats-section" :style="{ backgroundImage: `url(${homeBg})` }">
  3. <NuxtPicture class="stats-figure" :src="homeD" alt="游戏盾" ></NuxtPicture>
  4. <div class="stat-item">
  5. <div class="stat-label">今日&nbsp;CC&nbsp;攻击次数</div>
  6. <div class="stat-value">{{ formatNumber(stats.ccAttacks) }}</div>
  7. </div>
  8. <div class="stat-item state-other">
  9. <div class="stat-label">今日&nbsp;DDoS&nbsp;攻击峰值</div>
  10. <div class="stat-value">{{ formatNumber(stats.ddosPeak) }}</div>
  11. </div>
  12. <div class="stat-item">
  13. <div class="stat-label">今日&nbsp;WAF&nbsp;拦截次数</div>
  14. <div class="stat-value">{{ formatNumber(stats.wafBlocks) }}</div>
  15. </div>
  16. </section>
  17. </template>
  18. <script setup>
  19. import { onMounted, onUnmounted } from 'vue'
  20. import { storeToRefs } from 'pinia'
  21. const homeBg = '/images/home/home-bg.png'
  22. const homeD = '/images/home/home-d.png'
  23. const statsStore = useStatsStore()
  24. const { stats } = storeToRefs(statsStore)
  25. let intervalId = null
  26. onMounted(() => {
  27. intervalId = statsStore.startAutoIncrement()
  28. })
  29. onUnmounted(() => {
  30. if (intervalId) {
  31. statsStore.stopAutoIncrement(intervalId)
  32. }
  33. })
  34. const formatNumber = (num) => {
  35. return num.toLocaleString()
  36. }
  37. </script>
  38. <style scoped lang="scss">
  39. .stats-section {
  40. width: 100%;
  41. max-width: 1920px;
  42. height: 749px;
  43. position: relative;
  44. display: flex;
  45. align-items: center;
  46. justify-content: center;
  47. background-size: cover;
  48. background-position: center top;
  49. overflow: hidden;
  50. .stats-figure {
  51. position: absolute;
  52. top: 280px;
  53. left: 50%;
  54. transform: translateX(-50%) translateY(0);
  55. width: 226.059px;
  56. height: 305.118px;
  57. object-fit: contain;
  58. pointer-events: none;
  59. z-index: 0;
  60. will-change: transform;
  61. animation: float 3s ease-in-out infinite;
  62. }
  63. @keyframes float {
  64. 0% {
  65. transform: translateX(-50%) translateY(0);
  66. }
  67. 50% {
  68. transform: translateX(-50%) translateY(-20px);
  69. }
  70. 100% {
  71. transform: translateX(-50%) translateY(0);
  72. }
  73. }
  74. .state-other {
  75. position: absolute;
  76. top: 100px;
  77. }
  78. .stat-item {
  79. display: flex;
  80. flex-direction: column;
  81. align-items: center;
  82. justify-content: space-between;
  83. margin: 0 300px;
  84. z-index: 1;
  85. .stat-label {
  86. font-family: 'Source Han Sans CN', sans-serif;
  87. font-size: 24px;
  88. font-weight: 400;
  89. line-height: 24px;
  90. color: #ffffff;
  91. text-align: center;
  92. margin-bottom: 20px;
  93. }
  94. .stat-value {
  95. font-family: 'Roboto', sans-serif;
  96. font-size: 56px;
  97. font-weight: 700;
  98. line-height: 56px;
  99. color: #a182ff;
  100. text-align: center;
  101. }
  102. }
  103. }
  104. </style>