StatsSection.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <section class="stats-section" style="background-image: url(/images/home/home-bg.png)">
  3. <NuxtPicture class="stats-figure" src="/images/home/home-d.png" 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 statsStore = useStatsStore()
  22. const { stats } = storeToRefs(statsStore)
  23. let intervalId = null
  24. onMounted(() => {
  25. intervalId = statsStore.startAutoIncrement()
  26. })
  27. onUnmounted(() => {
  28. if (intervalId) {
  29. statsStore.stopAutoIncrement(intervalId)
  30. }
  31. })
  32. const formatNumber = (num) => {
  33. return num.toLocaleString()
  34. }
  35. </script>
  36. <style scoped lang="scss">
  37. .stats-section {
  38. width: 100%;
  39. max-width: 1920px;
  40. height: 749px;
  41. position: relative;
  42. display: flex;
  43. align-items: center;
  44. justify-content: center;
  45. background-size: cover;
  46. background-position: center top;
  47. overflow: hidden;
  48. .stats-figure {
  49. position: absolute;
  50. top: 280px;
  51. left: 50%;
  52. transform: translateX(-50%) translateY(0);
  53. width: 226.059px;
  54. height: 305.118px;
  55. object-fit: contain;
  56. pointer-events: none;
  57. z-index: 0;
  58. will-change: transform;
  59. animation: float 3s ease-in-out infinite;
  60. }
  61. @keyframes float {
  62. 0% {
  63. transform: translateX(-50%) translateY(0);
  64. }
  65. 50% {
  66. transform: translateX(-50%) translateY(-20px);
  67. }
  68. 100% {
  69. transform: translateX(-50%) translateY(0);
  70. }
  71. }
  72. .state-other {
  73. position: absolute;
  74. top: 100px;
  75. }
  76. .stat-item {
  77. display: flex;
  78. flex-direction: column;
  79. align-items: center;
  80. justify-content: space-between;
  81. margin: 0 300px;
  82. z-index: 1;
  83. .stat-label {
  84. font-family: 'Source Han Sans CN', sans-serif;
  85. font-size: 24px;
  86. font-weight: 400;
  87. line-height: 24px;
  88. color: #ffffff;
  89. text-align: center;
  90. margin-bottom: 20px;
  91. }
  92. .stat-value {
  93. font-family: 'Roboto', sans-serif;
  94. font-size: 56px;
  95. font-weight: 700;
  96. line-height: 56px;
  97. color: #a182ff;
  98. text-align: center;
  99. }
  100. }
  101. }
  102. </style>