56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
/** 数字人版本 DTO(任务 131):数字人版本行/状态类型;与软件版本 DTO 分离,纯逻辑。 */
|
||
|
||
export type DigitalHumanVersionStatus = 'DRAFT' | 'RELEASED' | 'DEPRECATED'
|
||
|
||
/** 数字人版本行(GET /api/digital-human/versions,Java DigitalHumanVersionVo camel)。 */
|
||
export interface DigitalHumanVersion {
|
||
id: number
|
||
version: string
|
||
fileSize?: number
|
||
md5?: string
|
||
changelog?: string
|
||
minClientVersion?: string
|
||
isLatest?: boolean
|
||
status: DigitalHumanVersionStatus
|
||
downloadUrl?: string
|
||
createdBy?: string
|
||
createdAt?: string
|
||
releasedAt?: string
|
||
}
|
||
|
||
export interface DigitalHumanVersionList {
|
||
items: DigitalHumanVersion[]
|
||
}
|
||
|
||
export function emptyDigitalHumanVersionList(): DigitalHumanVersionList {
|
||
return { items: [] }
|
||
}
|
||
|
||
/** 状态归一(对齐 admin.js:6337 三态:DRAFT 草稿 / RELEASED 已发布 / 其余一律已废弃)。 */
|
||
export function normalizeDigitalHumanStatus(value: unknown): DigitalHumanVersionStatus {
|
||
const text = typeof value === 'string' ? value.trim().toUpperCase() : ''
|
||
if (text === 'RELEASED') return 'RELEASED'
|
||
if (text === 'DRAFT') return 'DRAFT'
|
||
return 'DEPRECATED'
|
||
}
|
||
|
||
/** 文件大小展示(对齐 admin.js:6340 固定两位小数 MB;空/0 显示 -)。 */
|
||
export function digitalHumanVersionFileSizeText(fileSize: number | null | undefined): string {
|
||
if (typeof fileSize !== 'number' || !Number.isFinite(fileSize) || fileSize <= 0) return '-'
|
||
return `${(fileSize / 1024 / 1024).toFixed(2)} MB`
|
||
}
|
||
|
||
/** 更新说明 50 字符截断(对齐 admin.js:6342-6343;空显示 -)。 */
|
||
export function digitalHumanChangelogShort(changelog: string | null | undefined): string {
|
||
const text = (changelog || '').trim() || '-'
|
||
if (text === '-') return text
|
||
if (text.length > 50) return `${text.substring(0, 50)}...`
|
||
return text
|
||
}
|
||
|
||
/** 删除数字人版本确认文案(对齐 admin.js:6356)。 */
|
||
export function digitalHumanDeleteConfirmText(version: string): string {
|
||
const v = (version || '').trim()
|
||
return v ? `确认删除版本 ${v} 吗?该操作会删除对应文件,无法恢复。` : ''
|
||
}
|