8882e24fd4
CI/CD Pipeline / Check if frontend-only change (push) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (push) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (push) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (push) Has been cancelled
CI/CD Pipeline / PR Build API Image (push) Has been cancelled
CI/CD Pipeline / PR Build Web Image (push) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
CI/CD Pipeline / Canary Release to Production (push) Has been cancelled
CI/CD Pipeline / CI Gate (push) Has been cancelled
Squash merge of PR #968 ## 变更说明 DuplicationDetail 查重详情页三阶段重构,主文件 323→110 行(-66%) ### Phase 1: 常量/工具 - : RISK_DESC / RISK_TAG_VARIANT / RISK_LABEL / ToastState - : formatTime / formatSize / formatDuration / getRiskLevel ### Phase 2: UI 组件 - : 风险评估卡片(圆环 + 查重率 + 描述) - : 基本信息卡片(6 行元数据) - : 重复片段列表区域 - : 单个重复片段卡片 ### Phase 3: 业务 Hook - : 查询 + 重试 + Toast + 导航
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
/** 根据查重率获取风险等级 */
|
||
export const getRiskLevel = (rate?: number): "low" | "medium" | "high" => {
|
||
if (rate === undefined) return "low"
|
||
if (rate <= 10) return "low"
|
||
if (rate <= 30) return "medium"
|
||
return "high"
|
||
}
|
||
|
||
/** 格式化时间(秒 → mm:ss) */
|
||
export const formatTime = (seconds: number) => {
|
||
const m = Math.floor(seconds / 60)
|
||
const s = Math.floor(seconds % 60)
|
||
return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`
|
||
}
|
||
|
||
/** 格式化文件大小 */
|
||
export const formatSize = (bytes: number) => {
|
||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)} KB`
|
||
if (bytes < 1024 * 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(1)} MB`
|
||
return `${(bytes / 1024 / 1024 / 1024).toFixed(2)} GB`
|
||
}
|
||
|
||
/** 格式化时长 */
|
||
export const formatDuration = (seconds?: number) => {
|
||
if (!seconds) return "-"
|
||
const totalSec = Math.round(seconds)
|
||
const m = Math.floor(totalSec / 60)
|
||
const s = totalSec % 60
|
||
return m > 0 ? `${m}分${s}秒` : `${s}秒`
|
||
}
|