| > |
| 9 | <div class="stat-card-content"> |
| 10 | <div class="stat-icon" :class="`icon-${type}`"> |
| 11 | <component :is="iconComponent" class="icon" /> |
| 12 | </div> |
| 13 | <div class="stat-info"> |
| 14 | <div class="stat-value">{{ value }}</div> |
| 15 | <div class="stat-label">{{ label }}</div> |
| 16 | </div> |
| 17 | <el-icon v-if="to" class="arrow-icon"><ArrowRight /></el-icon> |
| 18 | </div> |
| 19 | <div v-if="subtitle" class="stat-subtitle">{{ subtitle }}</div> |
| 20 | </el-card> |
| 21 | </template> |
| 22 |
| 23 | <script setup lang="ts"> |
| 24 | import { computed } from 'vue' |
| 25 | import { useRouter } from 'vue-router' |
| 26 | import { |
| 27 | User, |
| 28 | Connection, |
| 29 | DataAnalysis, |
| 30 | Promotion, |
| 31 | ArrowRight, |
| 32 | } from '@element-plus/icons-vue' |
| 33 |
| 34 | interface Props { |
| 35 | label: string |
| 36 | value: string | number |
| 37 | type?: 'clients' | 'proxies' | 'connections' | 'traffic' |
| 38 | subtitle?: string |
| 39 | to?: string |
| 40 | } |
| 41 |
| 42 | const props = withDefaults(defineProps<Props>(), { |
| 43 | type: 'clients', |
| 44 | }) |
| 45 |
| 46 | const router = useRouter() |
| 47 |
| 48 | const iconComponent = computed(() => { |
| 49 | switch (props.type) { |
| 50 | case 'clients': |
| 51 | return User |
| 52 | case 'proxies': |
| 53 | return Connection |
| 54 | case 'connections': |
| 55 | return DataAnalysis |
| 56 | case 'traffic': |
| 57 | return Promotion |
| 58 | default: |
| 59 | return User |
| 60 | } |
| 61 | }) |
| 62 |
| 63 | const handleClick = () => { |
| 64 | if (props.to) { |
| 65 | router.push(props.to) |
| 66 | } |
| 67 | } |
| 68 | </script> |
| 69 |
| 70 | <style scoped> |
| 71 | .stat-card { |
| 72 | border-radius: 12px; |
| 73 | transition: all 0.3s ease; |
| 74 | border: 1px solid #e4e7ed; |
| 75 | } |
| 76 |
| 77 | .stat-card.clickable { |
| 78 | cursor: pointer; |
| 79 | } |
| 80 |
| 81 | .stat-card.clickable:hover { |
| 82 | transform: translateY(-4px); |
| 83 | box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1); |
| 84 | } |
| 85 |
| 86 | .stat-card.clickable:hover .arrow-icon { |
| 87 | transform: translateX(4px); |
| 88 | } |
| 89 |
| 90 | html.dark .stat-card { |
| 91 | border-color: #3a3d5c; |
| 92 | background: #27293d; |
| 93 | } |
| 94 |
| 95 | .stat-card-content { |
| 96 | display: flex; |
| 97 | align-items: center; |
| 98 | gap: 16px; |
| 99 | } |
| 100 |
| 101 | .arrow-icon { |
| 102 | color: #909399; |
| 103 | font-size: 18px; |
| 104 | transition: transform 0.2s ease; |
| 105 | flex-shrink: 0; |
| 106 | } |
| 107 |
| 108 | html.dark .arrow-icon { |
| 109 | color: #9ca3af; |
| 110 | } |
| 111 |
| 112 | .stat-icon { |
| 113 | width: 56px; |
| 114 | height: 56px; |
| 115 | border-radius: 12px; |
| 116 | display: flex; |
| 117 | align-items: center; |
| 118 | justify-content: center; |
| 119 | flex-shrink: 0; |
| 120 | } |
| 121 |
| 122 | .stat-icon .icon { |
| 123 | width: 28px; |
| 124 | height: 28px; |
| 125 | } |
| 126 |
| 127 | .icon-clients { |
| 128 | background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| 129 | color: white; |
| 130 | } |
| 131 |
| 132 | .icon-proxies { |
| 133 | background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); |
| 134 | color: white; |
| 135 | } |
| 136 |
| 137 | .icon-connections { |
| 138 | background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); |
| 139 | color: white; |
| 140 | } |
| 141 |
| 142 | .icon-traffic { |
| 143 | background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); |
| 144 | color: white; |
| 145 | } |
| 146 |
| 147 | html.dark .icon-clients { |
| 148 | background: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%); |
| 149 | } |
| 150 |
| 151 | html.dark .icon-proxies { |
| 152 | background: linear-gradient(135deg, #fb7185 0%, #f43f5e 100%); |
| 153 | } |
| 154 |
| 155 | html.dark .icon-connections { |
| 156 | background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); |
| 157 | } |
| 158 |
| 159 | html.dark .icon-traffic { |
| 160 | background: linear-gradient(135deg, #34d399 0%, #10b981 100%); |
| 161 | } |
| 162 |
| 163 | .stat-info { |
| 164 | flex: 1; |
| 165 | min-width: 0; |
| 166 | } |
| 167 |
| 168 | .stat-value { |
| 169 | font-size: 28px; |
| 170 | font-weight: 500; |
| 171 | line-height: 1.2; |
| 172 | color: #303133; |
| 173 | margin-bottom: 4px; |
| 174 | } |
| 175 |
| 176 | html.dark .stat-value { |
| 177 | color: #e5e7eb; |
| 178 | } |
| 179 |
| 180 | .stat-label { |
| 181 | font-size: 14px; |
| 182 | color: #909399; |
| 183 | font-weight: 500; |
| 184 | } |
| 185 |
| 186 | html.dark .stat-label { |
| 187 | color: #9ca3af; |
| 188 | } |
| 189 |
| 190 | .stat-subtitle { |
| 191 | margin-top: 12px; |
| 192 | padding-top: 12px; |
| 193 | border-top: 1px solid #e4e7ed; |
| 194 | font-size: 12px; |
| 195 | color: #909399; |
| 196 | } |
| 197 |
| 198 | html.dark .stat-subtitle { |
| 199 | border-top-color: #3a3d5c; |
| 200 | color: #9ca3af; |
| 201 | } |
| 202 | </style> |