| type="clients" |
| 9 | subtitle="Connected clients" |
| 10 | to="/clients" |
| 11 | /> |
| 12 | </el-col> |
| 13 | <el-col :xs="24" :sm="12" :lg="6"> |
| 14 | <StatCard |
| 15 | label="Proxies" |
| 16 | :value="proxyCounts" |
| 17 | type="proxies" |
| 18 | subtitle="Active proxies" |
| 19 | to="/proxies/tcp" |
| 20 | /> |
| 21 | </el-col> |
| 22 | <el-col :xs="24" :sm="12" :lg="6"> |
| 23 | <StatCard |
| 24 | label="Connections" |
| 25 | :value="data.status.curConns" |
| 26 | type="connections" |
| 27 | subtitle="Current connections" |
| 28 | /> |
| 29 | </el-col> |
| 30 | <el-col :xs="24" :sm="12" :lg="6"> |
| 31 | <StatCard |
| 32 | label="Traffic" |
| 33 | :value="formatTrafficTotal()" |
| 34 | type="traffic" |
| 35 | subtitle="Total today" |
| 36 | /> |
| 37 | </el-col> |
| 38 | </el-row> |
| 39 |
| 40 | <el-row :gutter="20" class="charts-row"> |
| 41 | <el-col :xs="24" :md="12"> |
| 42 | <el-card class="chart-card" shadow="hover"> |
| 43 | <template #header> |
| 44 | <div class="card-header"> |
| 45 | <span class="card-title">Network Traffic</span> |
| 46 | <el-tag size="small" type="info">Today</el-tag> |
| 47 | </div> |
| 48 | </template> |
| 49 | <div class="traffic-summary"> |
| 50 | <div class="traffic-item in"> |
| 51 | <div class="traffic-icon"> |
| 52 | <el-icon><Download /></el-icon> |
| 53 | </div> |
| 54 | <div class="traffic-info"> |
| 55 | <div class="label">Inbound</div> |
| 56 | <div class="value"> |
| 57 | {{ formatFileSize(data.status.totalTrafficIn) }} |
| 58 | </div> |
| 59 | </div> |
| 60 | </div> |
| 61 | <div class="traffic-divider"></div> |
| 62 | <div class="traffic-item out"> |
| 63 | <div class="traffic-icon"> |
| 64 | <el-icon><Upload /></el-icon> |
| 65 | </div> |
| 66 | <div class="traffic-info"> |
| 67 | <div class="label">Outbound</div> |
| 68 | <div class="value"> |
| 69 | {{ formatFileSize(data.status.totalTrafficOut) }} |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | </div> |
| 74 | </el-card> |
| 75 | </el-col> |
| 76 | <el-col :xs="24" :md="12"> |
| 77 | <el-card class="chart-card" shadow="hover"> |
| 78 | <template #header> |
| 79 | <div class="card-header"> |
| 80 | <span class="card-title">Proxy Types</span> |
| 81 | <el-tag size="small" type="info">Now</el-tag> |
| 82 | </div> |
| 83 | </template> |
| 84 | <div class="proxy-types-grid"> |
| 85 | <div |
| 86 | v-for="(count, type) in data.status.proxyTypeCount" |
| 87 | :key="type" |
| 88 | class="proxy-type-item" |
| 89 | v-show="count > 0" |
| 90 | > |
| 91 | <div class="proxy-type-name">{{ type.toUpperCase() }}</div> |
| 92 | <div class="proxy-type-count">{{ count }}</div> |
| 93 | </div> |
| 94 | <div v-if="!hasActiveProxies" class="no-data"> |
| 95 | No active proxies |
| 96 | </div> |
| 97 | </div> |
| 98 | </el-card> |
| 99 | </el-col> |
| 100 | </el-row> |
| 101 |
| 102 | <el-card class="config-card" shadow="hover"> |
| 103 | <template #header> |
| 104 | <div class="card-header"> |
| 105 | <span class="card-title">Server Configuration</span> |
| 106 | <el-tag size="small" type="success">v{{ data.version }}</el-tag> |
| 107 | </div> |
| 108 | </template> |
| 109 | <div class="config-grid"> |
| 110 | <div class="config-item"> |
| 111 | <span class="config-label">Bind Port</span> |
| 112 | <span class="config-value">{{ data.config.bindPort }}</span> |
| 113 | </div> |
| 114 | <div class="config-item" v-if="data.config.kcpBindPort != 0"> |
| 115 | <span class="config-label">KCP Port</span> |
| 116 | <span class="config-value">{{ data.config.kcpBindPort }}</span> |
| 117 | </div> |
| 118 | <div class="config-item" v-if="data.config.quicBindPort != 0"> |
| 119 | <span class="config-label">QUIC Port</span> |
| 120 | <span class="config-value">{{ data.config.quicBindPort }}</span> |
| 121 | </div> |
| 122 | <div class="config-item" v-if="data.config.vhostHTTPPort != 0"> |
| 123 | <span class="config-label">HTTP Port</span> |
| 124 | <span class="config-value">{{ data.config.vhostHTTPPort }}</span> |
| 125 | </div> |
| 126 | <div class="config-item" v-if="data.config.vhostHTTPSPort != 0"> |
| 127 | <span class="config-label">HTTPS Port</span> |
| 128 | <span class="config-value">{{ data.config.vhostHTTPSPort }}</span> |
| 129 | </div> |
| 130 | <div class="config-item" v-if="data.config.tcpmuxHTTPConnectPort != 0"> |
| 131 | <span class="config-label">TCPMux Port</span> |
| 132 | <span class="config-value">{{ data.config.tcpmuxHTTPConnectPort }}</span> |
| 133 | </div> |
| 134 | <div class="config-item" v-if="data.config.subdomainHost != ''"> |
| 135 | <span class="config-label">Subdomain Host</span> |
| 136 | <span class="config-value">{{ data.config.subdomainHost }}</span> |
| 137 | </div> |
| 138 | <div class="config-item"> |
| 139 | <span class="config-label">Max Pool Count</span> |
| 140 | <span class="config-value">{{ data.config.maxPoolCount }}</span> |
| 141 | </div> |
| 142 | <div class="config-item"> |
| 143 | <span class="config-label">Max Ports/Client</span> |
| 144 | <span class="config-value">{{ maxPortsPerClientLabel }}</span> |
| 145 | </div> |
| 146 | <div class="config-item" v-if="data.config.allowPortsStr != ''"> |
| 147 | <span class="config-label">Allow Ports</span> |
| 148 | <span class="config-value">{{ data.config.allowPortsStr }}</span> |
| 149 | </div> |
| 150 | <div class="config-item" v-if="data.config.tlsForce"> |
| 151 | <span class="config-label">TLS Force</span> |
| 152 | <el-tag size="small" type="warning">Enabled</el-tag> |
| 153 | </div> |
| 154 | <div class="config-item"> |
| 155 | <span class="config-label">Heartbeat Timeout</span> |
| 156 | <span class="config-value">{{ data.config.heartbeatTimeout }}s</span> |
| 157 | </div> |
| 158 | </div> |
| 159 | </el-card> |
| 160 | </div> |
| 161 | </template> |
| 162 |
| 163 | <script setup lang="ts"> |
| 164 | import { ref, onMounted, computed } from 'vue' |
| 165 | import { ElMessage } from 'element-plus' |
| 166 | import { formatFileSize } from '../utils/format' |
| 167 | import { Download, Upload } from '@element-plus/icons-vue' |
| 168 | import StatCard from '../components/StatCard.vue' |
| 169 | import { getServerInfo } from '../api/server' |
| 170 | import type { ServerInfo } from '../types/server' |
| 171 |
| 172 | const data = ref<ServerInfo>({ |
| 173 | version: '', |
| 174 | config: { |
| 175 | bindPort: 0, |
| 176 | kcpBindPort: 0, |
| 177 | quicBindPort: 0, |
| 178 | vhostHTTPPort: 0, |
| 179 | vhostHTTPSPort: 0, |
| 180 | tcpmuxHTTPConnectPort: 0, |
| 181 | subdomainHost: '', |
| 182 | maxPoolCount: 0, |
| 183 | maxPortsPerClient: 0, |
| 184 | allowPortsStr: '', |
| 185 | tlsForce: false, |
| 186 | heartbeatTimeout: 0, |
| 187 | }, |
| 188 | status: { |
| 189 | clientCounts: 0, |
| 190 | curConns: 0, |
| 191 | totalTrafficIn: 0, |
| 192 | totalTrafficOut: 0, |
| 193 | proxyTypeCount: {}, |
| 194 | }, |
| 195 | }) |
| 196 |
| 197 | const hasActiveProxies = computed(() => { |
| 198 | return Object.values(data.value.status.proxyTypeCount).some((c) => c > 0) |
| 199 | }) |
| 200 |
| 201 | const proxyCounts = computed(() => { |
| 202 | return Object.values(data.value.status.proxyTypeCount).reduce( |
| 203 | (sum, count) => sum + (count || 0), |
| 204 | 0, |
| 205 | ) |
| 206 | }) |
| 207 |
| 208 | const maxPortsPerClientLabel = computed(() => { |
| 209 | const value = data.value.config.maxPortsPerClient |
| 210 | return value === 0 ? 'no limit' : String(value) |
| 211 | }) |
| 212 |
| 213 | const formatTrafficTotal = () => { |
| 214 | const total = |
| 215 | data.value.status.totalTrafficIn + data.value.status.totalTrafficOut |
| 216 | return formatFileSize(total) |
| 217 | } |
| 218 |
| 219 | const fetchData = async () => { |
| 220 | try { |
| 221 | const json = await getServerInfo() |
| 222 | data.value = json |
| 223 | } catch { |
| 224 | ElMessage({ |
| 225 | showClose: true, |
| 226 | message: 'Get server info from frps failed!', |
| 227 | type: 'error', |
| 228 | }) |
| 229 | } |
| 230 | } |
| 231 |
| 232 | onMounted(() => { |
| 233 | fetchData() |
| 234 | }) |
| 235 | </script> |
| 236 |
| 237 | <style scoped> |
| 238 | .server-overview { |
| 239 | padding: 0; |
| 240 | } |
| 241 |
| 242 | .stats-row { |
| 243 | margin-bottom: 20px; |
| 244 | } |
| 245 |
| 246 | .charts-row { |
| 247 | margin-bottom: 20px; |
| 248 | } |
| 249 |
| 250 | .chart-card { |
| 251 | border-radius: 12px; |
| 252 | border: 1px solid #e4e7ed; |
| 253 | height: 100%; |
| 254 | } |
| 255 |
| 256 | html.dark .chart-card { |
| 257 | border-color: #3a3d5c; |
| 258 | background: #27293d; |
| 259 | } |
| 260 |
| 261 | .config-card { |
| 262 | border-radius: 12px; |
| 263 | border: 1px solid #e4e7ed; |
| 264 | margin-bottom: 20px; |
| 265 | } |
| 266 |
| 267 | html.dark .config-card { |
| 268 | border-color: #3a3d5c; |
| 269 | background: #27293d; |
| 270 | } |
| 271 |
| 272 | .card-header { |
| 273 | display: flex; |
| 274 | justify-content: space-between; |
| 275 | align-items: center; |
| 276 | } |
| 277 |
| 278 | .card-title { |
| 279 | font-size: 16px; |
| 280 | font-weight: 500; |
| 281 | color: #303133; |
| 282 | } |
| 283 |
| 284 | html.dark .card-title { |
| 285 | color: #e5e7eb; |
| 286 | } |
| 287 |
| 288 | .traffic-summary { |
| 289 | display: flex; |
| 290 | align-items: center; |
| 291 | justify-content: space-around; |
| 292 | min-height: 120px; |
| 293 | padding: 10px 0; |
| 294 | } |
| 295 |
| 296 | .traffic-item { |
| 297 | display: flex; |
| 298 | align-items: center; |
| 299 | gap: 16px; |
| 300 | } |
| 301 |
| 302 | .traffic-icon { |
| 303 | width: 48px; |
| 304 | height: 48px; |
| 305 | border-radius: 50%; |
| 306 | display: flex; |
| 307 | align-items: center; |
| 308 | justify-content: center; |
| 309 | font-size: 24px; |
| 310 | } |
| 311 |
| 312 | .traffic-item.in .traffic-icon { |
| 313 | background: rgba(84, 112, 198, 0.1); |
| 314 | color: #5470c6; |
| 315 | } |
| 316 |
| 317 | .traffic-item.out .traffic-icon { |
| 318 | background: rgba(145, 204, 117, 0.1); |
| 319 | color: #91cc75; |
| 320 | } |
| 321 |
| 322 | .traffic-info { |
| 323 | display: flex; |
| 324 | flex-direction: column; |
| 325 | } |
| 326 |
| 327 | .traffic-info .label { |
| 328 | font-size: 14px; |
| 329 | color: #909399; |
| 330 | } |
| 331 |
| 332 | .traffic-info .value { |
| 333 | font-size: 24px; |
| 334 | font-weight: 500; |
| 335 | color: #303133; |
| 336 | } |
| 337 |
| 338 | html.dark .traffic-info .value { |
| 339 | color: #e5e7eb; |
| 340 | } |
| 341 |
| 342 | .traffic-divider { |
| 343 | width: 1px; |
| 344 | height: 60px; |
| 345 | background: #e4e7ed; |
| 346 | } |
| 347 |
| 348 | html.dark .traffic-divider { |
| 349 | background: #3a3d5c; |
| 350 | } |
| 351 |
| 352 | .proxy-types-grid { |
| 353 | display: grid; |
| 354 | grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); |
| 355 | gap: 16px; |
| 356 | min-height: 120px; |
| 357 | align-content: center; |
| 358 | padding: 10px 0; |
| 359 | } |
| 360 |
| 361 | .proxy-type-item { |
| 362 | display: flex; |
| 363 | flex-direction: column; |
| 364 | align-items: center; |
| 365 | padding: 12px; |
| 366 | background: #f8f9fa; |
| 367 | border-radius: 8px; |
| 368 | } |
| 369 |
| 370 | html.dark .proxy-type-item { |
| 371 | background: #1e1e2d; |
| 372 | } |
| 373 |
| 374 | .proxy-type-name { |
| 375 | font-size: 12px; |
| 376 | color: #909399; |
| 377 | font-weight: 500; |
| 378 | margin-bottom: 4px; |
| 379 | } |
| 380 |
| 381 | .proxy-type-count { |
| 382 | font-size: 20px; |
| 383 | font-weight: 500; |
| 384 | color: #303133; |
| 385 | } |
| 386 |
| 387 | html.dark .proxy-type-count { |
| 388 | color: #e5e7eb; |
| 389 | } |
| 390 |
| 391 | .no-data { |
| 392 | grid-column: 1 / -1; |
| 393 | display: flex; |
| 394 | align-items: center; |
| 395 | justify-content: center; |
| 396 | height: 100%; |
| 397 | color: #909399; |
| 398 | font-size: 14px; |
| 399 | } |
| 400 |
| 401 | .config-grid { |
| 402 | display: grid; |
| 403 | grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); |
| 404 | gap: 16px; |
| 405 | } |
| 406 |
| 407 | .config-item { |
| 408 | display: flex; |
| 409 | flex-direction: column; |
| 410 | gap: 4px; |
| 411 | padding: 12px; |
| 412 | background: #f8f9fa; |
| 413 | border-radius: 8px; |
| 414 | transition: background 0.2s; |
| 415 | } |
| 416 |
| 417 | html.dark .config-item { |
| 418 | background: #1e1e2d; |
| 419 | } |
| 420 |
| 421 | .config-label { |
| 422 | font-size: 12px; |
| 423 | color: #909399; |
| 424 | font-weight: 500; |
| 425 | } |
| 426 |
| 427 | html.dark .config-label { |
| 428 | color: #9ca3af; |
| 429 | } |
| 430 |
| 431 | .config-value { |
| 432 | font-size: 14px; |
| 433 | color: #303133; |
| 434 | font-weight: 500; |
| 435 | word-break: break-all; |
| 436 | } |
| 437 |
| 438 | html.dark .config-value { |
| 439 | color: #e5e7eb; |
| 440 | } |
| 441 |
| 442 | @media (max-width: 768px) { |
| 443 | .chart-container { |
| 444 | height: 250px; |
| 445 | } |
| 446 |
| 447 | .config-grid { |
| 448 | grid-template-columns: repeat(2, 1fr); |
| 449 | } |
| 450 | } |
| 451 | </style> |