增加前端格式检查配置

This commit is contained in:
yml2213
2026-06-08 06:40:33 +08:00
parent 79ea3a476c
commit 500f511185
150 changed files with 7254 additions and 4013 deletions
+5 -7
View File
@@ -54,7 +54,7 @@ class ApiMonitor {
*/
getSuccessRate(): number {
if (this.metrics.length === 0) return 100
const successCount = this.metrics.filter((m) => m.success).length
const successCount = this.metrics.filter(m => m.success).length
return Math.round((successCount / this.metrics.length) * 100)
}
@@ -62,9 +62,7 @@ class ApiMonitor {
* 获取最慢的请求
*/
getSlowestRequests(count = 5): RequestMetrics[] {
return [...this.metrics]
.sort((a, b) => b.duration - a.duration)
.slice(0, count)
return [...this.metrics].sort((a, b) => b.duration - a.duration).slice(0, count)
}
/**
@@ -73,7 +71,7 @@ class ApiMonitor {
getStatsByUrl(): Record<string, { count: number; avgDuration: number; successRate: number }> {
const urlStats: Record<string, RequestMetrics[]> = {}
this.metrics.forEach((metric) => {
this.metrics.forEach(metric => {
if (!urlStats[metric.url]) {
urlStats[metric.url] = []
}
@@ -84,7 +82,7 @@ class ApiMonitor {
Object.entries(urlStats).forEach(([url, metrics]) => {
const totalDuration = metrics.reduce((sum, m) => sum + m.duration, 0)
const successCount = metrics.filter((m) => m.success).length
const successCount = metrics.filter(m => m.success).length
result[url] = {
count: metrics.length,
@@ -113,7 +111,7 @@ class ApiMonitor {
console.log('成功率:', this.getSuccessRate(), '%')
console.log('最慢的 5 个请求:')
console.table(
this.getSlowestRequests(5).map((m) => ({
this.getSlowestRequests(5).map(m => ({
方法: m.method,
URL: m.url,
: `${m.duration}ms`,