StatsSection.vue 2.7 KB

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