613c75d041
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 1m54s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 2m5s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 2m33s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m18s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 5m22s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 6m27s
CI/CD Pipeline / Integration Tests (push) Successful in 3m28s
CI/CD Pipeline / Unit Tests (push) Failing after 10m19s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 14m30s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 33s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 35s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 1m42s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m51s
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
24 lines
748 B
TypeScript
24 lines
748 B
TypeScript
import { ACCEPTED_EXTENSIONS, MAX_FILE_SIZE } from "./constants"
|
|
|
|
/**
|
|
* 验证音频文件
|
|
* @returns 错误信息,null 表示验证通过
|
|
*/
|
|
export const validateFile = (file: File): string | null => {
|
|
const ext = file.name.split(".").pop()?.toLowerCase()
|
|
if (!ext || !ACCEPTED_EXTENSIONS.includes(ext)) {
|
|
return "不支持的音频格式,请上传 MP3、WAV 或 M4A 文件"
|
|
}
|
|
if (file.size > MAX_FILE_SIZE) {
|
|
return "文件大小超过 10MB,请压缩后重试"
|
|
}
|
|
return null
|
|
}
|
|
|
|
/** 格式化录制时间 mm:ss */
|
|
export const formatRecordTime = (seconds: number): string => {
|
|
const m = Math.floor(seconds / 60)
|
|
const s = seconds % 60
|
|
return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`
|
|
}
|