align(数字人版本): 分页(前端20/页)、上传进度(正在上传N%)、状态三态(草稿/已发布/已废弃)、文件大小固定两位MB、说明50字截断、RELEASED恒显下载点击取链接、确认文案/按钮名/仅zip校验/弹窗描述对齐(对齐 admin.js loadDigitalHumanVersions/downloadDigitalHumanVersion/上传段)

This commit is contained in:
2026-09-05 23:28:41 +08:00
parent 207f48f7d8
commit 553aca34f7
13 changed files with 251 additions and 58 deletions
@@ -1,36 +1,53 @@
<script setup lang="ts">
/** 数字人版本管理页(module 13 task 261 对齐 admin panel-digital-human-version)。 */
/** 数字人版本管理页(module 13 task 261 对齐 admin panel-digital-human-version;本轮补齐分页/三态/上传进度/下载语义)。 */
import { formatDateTime } from '@/utils/datetime'
import { formatFileSize } from './version-format.ts'
import { md5Short } from './digitalhuman-format.ts'
import { onMounted, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
deleteDigitalHumanVersion,
fetchDigitalHumanDownloadUrl,
fetchDigitalHumanVersions,
releaseDigitalHumanVersion,
setLatestDigitalHumanVersion,
uploadDigitalHumanVersion,
} from './digitalhuman-api.ts'
import type { DigitalHumanVersion } from './digitalhuman-dto.ts'
import {
digitalHumanChangelogShort,
digitalHumanDeleteConfirmText,
digitalHumanVersionFileSizeText,
} from './digitalhuman-dto.ts'
import { validateDigitalHumanUpload } from './digitalhuman-upload-model.ts'
import { canReleaseDigitalHumanVersion, releaseDigitalHumanConfirmText } from './digitalhuman-release.ts'
import { canSetLatestDigitalHumanVersion, setLatestDigitalHumanConfirmText } from './digitalhuman-latest.ts'
import { digitalHumanStatusDisplay, latestBadgeText } from './digitalhuman-status-display.ts'
import { digitalHumanStatusDisplay } from './digitalhuman-status-display.ts'
const loading = ref(false)
const items = ref<DigitalHumanVersion[]>([])
/** 分页(对齐 admin.js:6311 pageSize=20 + 数字页码 + 跳转;Java 列表接口不分页,前端分页呈现)。 */
const pageSize = 20
const page = ref(1)
const pagedItems = computed(() => {
const start = (page.value - 1) * pageSize
return items.value.slice(start, start + pageSize)
})
const uploadVisible = ref(false)
const uploading = ref(false)
const uploadProgress = ref<number | null>(null)
const form = ref({ version: '', file: null as { name?: string; size?: number } | null, changelog: '', minClientVersion: '' })
const confirming = ref<string | null>(null)
const downloadingVersion = ref<string | null>(null)
async function load() {
loading.value = true
try {
items.value = (await fetchDigitalHumanVersions()).items
// 数据收缩后页码越界回钳。
const last = Math.max(Math.ceil(items.value.length / pageSize), 1)
if (page.value > last) page.value = last
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '版本列表加载失败')
} finally {
@@ -49,14 +66,19 @@ async function submitUpload() {
return
}
uploading.value = true
uploadProgress.value = 0
const version = (form.value.version || '').trim()
try {
await uploadDigitalHumanVersion(
{ version, file: form.value.file, changelog: form.value.changelog, minClientVersion: form.value.minClientVersion },
form.value.file?.name,
(percent) => {
uploadProgress.value = percent
},
)
ElMessage.success(`上传成功!版本:${version}(状态:草稿,请在列表中点击“发布”按钮)`)
uploadVisible.value = false
uploadProgress.value = null
form.value = { version: '', file: null, changelog: '', minClientVersion: '' }
load()
} catch (error) {
@@ -100,10 +122,33 @@ async function setLatest(row: DigitalHumanVersion) {
}
}
/** 下载(对齐 admin.js downloadDigitalHumanVersionRELEASED 恒显示,点击取链接并触发下载)。 */
async function download(row: DigitalHumanVersion) {
if (!row.version) return
downloadingVersion.value = row.version
try {
const url = await fetchDigitalHumanDownloadUrl(row.version)
const anchor = document.createElement('a')
anchor.href = url
anchor.download = `ShuFuDigitalHuman-${row.version}.zip`
anchor.target = '_blank'
anchor.rel = 'noopener'
document.body.appendChild(anchor)
anchor.click()
document.body.removeChild(anchor)
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '下载失败')
} finally {
downloadingVersion.value = null
}
}
async function remove(row: DigitalHumanVersion) {
const text = digitalHumanDeleteConfirmText(row.version)
if (!text) return
confirming.value = row.version
try {
await ElMessageBox.confirm(`确定删除数字人版本 ${row.version} 吗?此操作不可恢复。`, '删除版本', {
await ElMessageBox.confirm(text, '删除版本', {
type: 'warning',
confirmButtonText: '删除',
cancelButtonText: '取消',
@@ -123,6 +168,10 @@ function canDelete(row: DigitalHumanVersion): boolean {
return row.isLatest !== true
}
function statusOf(row: DigitalHumanVersion): { text: string; tag: 'info' | 'success' | 'danger' } {
return digitalHumanStatusDisplay(row.status)
}
onMounted(load)
</script>
@@ -131,20 +180,20 @@ onMounted(load)
<div class="page-heading">
<div>
<h2>数字人版本管理</h2>
<p>管理数字人客户端的草稿/已发布版本</p>
<p>管理数字人客户端的草稿/已发布/已废弃版本</p>
</div>
<div class="actions">
<el-button type="primary" @click="uploadVisible = true">上传数字人版本</el-button>
<el-button type="primary" @click="uploadVisible = true">上传草稿状态</el-button>
</div>
</div>
<el-card shadow="never">
<el-table v-loading="loading" :data="items" stripe border empty-text="暂无数字人版本">
<el-table v-loading="loading" :data="pagedItems" stripe border empty-text="暂无数字人版本">
<el-table-column prop="version" label="版本号" min-width="150" />
<el-table-column label="状态" width="100">
<template #default="{ row }">
<el-tag :type="(digitalHumanStatusDisplay((row as DigitalHumanVersion).status).tag as 'success' | 'info')" size="small">
{{ digitalHumanStatusDisplay((row as DigitalHumanVersion).status).text }}
<el-tag :type="statusOf(row as DigitalHumanVersion).tag" size="small">
{{ statusOf(row as DigitalHumanVersion).text }}
</el-tag>
</template>
</el-table-column>
@@ -155,37 +204,51 @@ onMounted(load)
</template>
</el-table-column>
<el-table-column label="文件大小" width="100">
<template #default="{ row }">{{ (row as DigitalHumanVersion).fileSize != null ? formatFileSize((row as DigitalHumanVersion).fileSize!) : '—' }}</template>
<template #default="{ row }">{{ digitalHumanVersionFileSizeText((row as DigitalHumanVersion).fileSize) }}</template>
</el-table-column>
<el-table-column label="MD5" width="130">
<template #default="{ row }">
<span :title="(row as DigitalHumanVersion).md5 || ''">{{ md5Short((row as DigitalHumanVersion).md5) || '—' }}</span>
<span :title="(row as DigitalHumanVersion).md5 || ''">{{ (row as DigitalHumanVersion).md5 ? `${((row as DigitalHumanVersion).md5 || '').substring(0, 12)}...` : '—' }}</span>
</template>
</el-table-column>
<el-table-column label="更新说明" min-width="180">
<template #default="{ row }">
<span :title="(row as DigitalHumanVersion).changelog || ''">{{ digitalHumanChangelogShort((row as DigitalHumanVersion).changelog) }}</span>
</template>
</el-table-column>
<el-table-column prop="changelog" label="更新说明" min-width="180" show-overflow-tooltip />
<el-table-column label="发布时间" min-width="170">
<template #default="{ row }">{{ formatDateTime((row as DigitalHumanVersion).releasedAt) }}</template>
</el-table-column>
<el-table-column label="操作" width="210" fixed="right">
<el-table-column label="操作" width="240" fixed="right">
<template #default="{ row }">
<el-button v-if="canReleaseDigitalHumanVersion((row as DigitalHumanVersion).status)" text type="warning" size="small" :loading="confirming === (row as DigitalHumanVersion).version" @click="release(row as DigitalHumanVersion)">发布</el-button>
<el-button v-if="!canReleaseDigitalHumanVersion((row as DigitalHumanVersion).status) && canSetLatestDigitalHumanVersion((row as DigitalHumanVersion).status) && !(row as DigitalHumanVersion).isLatest" text type="primary" size="small" :loading="confirming === (row as DigitalHumanVersion).version" @click="setLatest(row as DigitalHumanVersion)">设最新</el-button>
<el-button v-if="(row as DigitalHumanVersion).downloadUrl" text type="success" size="small">
<el-link type="success" :href="(row as DigitalHumanVersion).downloadUrl" target="_blank">下载</el-link>
</el-button>
<el-button v-if="!canReleaseDigitalHumanVersion((row as DigitalHumanVersion).status) && canSetLatestDigitalHumanVersion((row as DigitalHumanVersion).status) && !(row as DigitalHumanVersion).isLatest" text type="primary" size="small" :loading="confirming === (row as DigitalHumanVersion).version" @click="setLatest(row as DigitalHumanVersion)">最新</el-button>
<el-button v-if="canSetLatestDigitalHumanVersion((row as DigitalHumanVersion).status)" text type="success" size="small" :loading="downloadingVersion === (row as DigitalHumanVersion).version" @click="download(row as DigitalHumanVersion)">下载</el-button>
<el-button v-if="canDelete(row as DigitalHumanVersion)" text type="danger" size="small" :loading="confirming === (row as DigitalHumanVersion).version" @click="remove(row as DigitalHumanVersion)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="table-footer">
<span> {{ items.length.toLocaleString() }} </span>
<el-pagination
background
layout="prev, pager, next, jumper"
:total="items.length"
:page-size="pageSize"
:current-page="page"
@current-change="(p: number) => { page = p }"
/>
</div>
</el-card>
<el-dialog v-model="uploadVisible" title="上传数字人版本" width="560px">
<p class="upload-desc">上传数字人程序 ZIP 包,系统会自动计算 MD5 并存储到 OSS。上传后状态为草稿,需要手动发布。</p>
<el-form label-width="110px">
<el-form-item label="版本号" required>
<el-input v-model="form.version" placeholder=" 1.0.2" />
</el-form-item>
<el-form-item label="压缩包" required>
<el-upload :auto-upload="false" :limit="1" accept=".zip,.rar,.7z" :on-change="(file: any) => onFileChange(file.raw)" :on-remove="() => (form.file = null)">
<el-upload :auto-upload="false" :limit="1" accept=".zip" :on-change="(file: any) => onFileChange(file.raw)" :on-remove="() => (form.file = null)">
<el-button>选择文件</el-button>
</el-upload>
<div v-if="form.file" class="dim">{{ form.file.name }}</div>
@@ -196,10 +259,11 @@ onMounted(load)
<el-form-item label="更新说明">
<el-input v-model="form.changelog" type="textarea" :rows="3" placeholder="可选" />
</el-form-item>
<el-alert v-if="uploading && uploadProgress != null" :title="`正在上传:${uploadProgress}%`" type="info" :closable="false" show-icon />
</el-form>
<template #footer>
<el-button @click="uploadVisible = false">取消</el-button>
<el-button type="primary" :loading="uploading" @click="submitUpload">上传</el-button>
<el-button type="primary" :loading="uploading" @click="submitUpload">上传草稿状态</el-button>
</template>
</el-dialog>
</div>
@@ -210,4 +274,7 @@ onMounted(load)
.actions { display: flex; align-items: center; gap: 10px; }
.dim { color: var(--el-text-color-secondary); font-size: 12px; }
.star { color: #e6a23c; font-weight: 700; }
.upload-desc { margin: 0 0 12px; color: var(--el-text-color-secondary); font-size: 12.5px; line-height: 1.6; }
.table-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; }
.table-footer span { color: var(--el-text-color-secondary); font-size: 12.5px; }
</style>
@@ -11,13 +11,39 @@ export async function fetchDigitalHumanVersions(): Promise<DigitalHumanVersionLi
return parseDigitalHumanVersions(data)
}
/** 上传数字人版本(multipart:字段 + file)。 */
export async function uploadDigitalHumanVersion(form: DigitalHumanUploadForm, filename = ''): Promise<void> {
/** 上传数字人版本(multipart:字段 + file)onProgress 接收 0-100 进度(对齐 admin.js:6543-6550 正在上传 N%。 */
export async function uploadDigitalHumanVersion(
form: DigitalHumanUploadForm,
filename = '',
onProgress?: (percent: number) => void,
): Promise<void> {
const body = new FormData()
const fields = buildDigitalHumanUploadFields(form)
Object.entries(fields).forEach(([key, value]) => body.append(key, value))
if (form.file) body.append('file', form.file as unknown as Blob, filename || (form.file.name || 'dh.zip'))
await http.post<unknown>(`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/upload`, body)
await http.post<unknown>(`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/upload`, body, {
onUploadProgress: (event) => {
if (!onProgress) return
const total = event.total || 0
onProgress(total > 0 ? Math.min(Math.round((event.loaded / total) * 100), 100) : 0)
},
})
}
/** 获取数字人版本下载链接(对齐 admin.js downloadDigitalHumanVersion:点击才取链接)。 */
export async function fetchDigitalHumanDownloadUrl(version: string): Promise<string> {
const { data } = await http.get<unknown>(
`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/${encodeURIComponent(version)}/download-url`,
)
const core = data as { data?: unknown } | null | undefined
const payload = (core && core.data) || data
if (typeof payload === 'string') return payload
if (payload && typeof payload === 'object') {
const record = payload as Record<string, unknown>
const url = record.downloadUrl ?? record.url ?? record.download_url
if (typeof url === 'string' && url) return url
}
throw new Error('Java 后端未返回下载链接')
}
/** 发布数字人版本:POST /{version}/release。 */
@@ -1,6 +1,6 @@
/** 数字人版本 DTO(任务 131):数字人版本行/状态类型;与软件版本 DTO 分离,纯逻辑。 */
export type DigitalHumanVersionStatus = 'DRAFT' | 'RELEASED'
export type DigitalHumanVersionStatus = 'DRAFT' | 'RELEASED' | 'DEPRECATED'
/** 数字人版本行(GET /api/digital-human/versionsJava DigitalHumanVersionVo camel)。 */
export interface DigitalHumanVersion {
@@ -26,8 +26,30 @@ export function emptyDigitalHumanVersionList(): DigitalHumanVersionList {
return { items: [] }
}
/** 状态归一:非受控一律回 DRAFT。 */
/** 状态归一(对齐 admin.js:6337 三态:DRAFT 草稿 / RELEASED 已发布 / 其余一律已废弃)。 */
export function normalizeDigitalHumanStatus(value: unknown): DigitalHumanVersionStatus {
const text = typeof value === 'string' ? value.trim().toUpperCase() : ''
return text === 'RELEASED' ? 'RELEASED' : 'DRAFT'
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} 吗?该操作会删除对应文件,无法恢复。` : ''
}
@@ -4,8 +4,8 @@ export function canSetLatestDigitalHumanVersion(status: unknown): boolean {
return typeof status === 'string' && status.trim().toUpperCase() === 'RELEASED'
}
/** 设为最新确认文案;空版本返回 null。 */
/** 设为最新确认文案(对齐 admin.js:6350;空版本返回 null。 */
export function setLatestDigitalHumanConfirmText(version: string): string | null {
const v = (version || '').trim()
return v ? `定将数字人版本 ${v} 设为最新吗?` : null
return v ? `认将版本 ${v} 设为最新吗?客户端会自动检测更新。` : null
}
@@ -5,8 +5,8 @@ export function canReleaseDigitalHumanVersion(status: unknown): boolean {
return typeof status === 'string' && status.trim().toUpperCase() === 'DRAFT'
}
/** 发布确认文案;空版本返回 null。 */
/** 发布确认文案(对齐 admin.js:6347;空版本返回 null。 */
export function releaseDigitalHumanConfirmText(version: string): string | null {
const v = (version || '').trim()
return v ? `发布数字人版本 ${v} 吗?` : null
return v ? `发布版本 ${v} 吗?` : null
}
@@ -1,9 +1,12 @@
/** 数字人版本状态展示(任务 134):态到文案/标签映射与最新徽标;纯逻辑。 */
/** 数字人版本状态展示(任务 134):态到文案/标签映射与最新徽标;纯逻辑。 */
import { normalizeDigitalHumanStatus, type DigitalHumanVersionStatus } from './digitalhuman-dto.ts'
export function digitalHumanStatusDisplay(status: unknown): { text: string; tag: string } {
/** 三态映射(对齐 admin.js:6337-6338:草稿 #999 / 已发布绿 / 已废弃红)。 */
export function digitalHumanStatusDisplay(status: unknown): { text: string; tag: 'info' | 'success' | 'danger' } {
const normalized: DigitalHumanVersionStatus = normalizeDigitalHumanStatus(status)
return normalized === 'RELEASED' ? { text: '已发布', tag: 'success' } : { text: '草稿', tag: 'info' }
if (normalized === 'RELEASED') return { text: '已发布', tag: 'success' }
if (normalized === 'DRAFT') return { text: '草稿', tag: 'info' }
return { text: '已废弃', tag: 'danger' }
}
export function latestBadgeText(isLatest: boolean): string {
@@ -13,13 +13,14 @@ export interface DigitalHumanUploadErrors {
file?: string
}
/** 校验上传表单(版本号必填非空、文件已选且非空)。 */
/** 校验上传表单(版本号必填非空、文件已选且非空、仅支持 zip——对齐 admin.js:6520-6523)。 */
export function validateDigitalHumanUpload(form: DigitalHumanUploadForm): { valid: boolean; errors: DigitalHumanUploadErrors } {
const errors: DigitalHumanUploadErrors = {}
if (!(form.version || '').trim()) errors.version = '版本号不能为空'
const file = form.file
if (!file) errors.file = '请选择程序压缩包'
else if (typeof file.size === 'number' && file.size <= 0) errors.file = '压缩包为空或无效'
else if (file.name && !file.name.toLowerCase().endsWith('.zip')) errors.file = '仅支持 .zip 格式'
return { valid: Object.keys(errors).length === 0, errors }
}
@@ -0,0 +1,71 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
digitalHumanChangelogShort,
digitalHumanVersionFileSizeText,
normalizeDigitalHumanStatus,
} from '../src/pages/records/digitalhuman-dto.ts'
import { digitalHumanStatusDisplay } from '../src/pages/records/digitalhuman-status-display.ts'
import { releaseDigitalHumanConfirmText } from '../src/pages/records/digitalhuman-release.ts'
import { setLatestDigitalHumanConfirmText } from '../src/pages/records/digitalhuman-latest.ts'
import { validateDigitalHumanUpload } from '../src/pages/records/digitalhuman-upload-model.ts'
/** 对齐 admin.js:6331-6358/6520-6550:三态、固定两位MB、50字符说明、下载按钮条件、确认文案、zip 校验、上传进度。 */
test('align_digital_human_status_three_states', () => {
assert.equal(normalizeDigitalHumanStatus('DRAFT'), 'DRAFT')
assert.equal(normalizeDigitalHumanStatus('RELEASED'), 'RELEASED')
assert.equal(normalizeDigitalHumanStatus('DEPRECATED'), 'DEPRECATED')
assert.equal(normalizeDigitalHumanStatus('unknown'), 'DEPRECATED')
assert.equal(normalizeDigitalHumanStatus(''), 'DEPRECATED')
assert.deepEqual(digitalHumanStatusDisplay('DRAFT'), { text: '草稿', tag: 'info' })
assert.deepEqual(digitalHumanStatusDisplay('RELEASED'), { text: '已发布', tag: 'success' })
assert.deepEqual(digitalHumanStatusDisplay('DEPRECATED'), { text: '已废弃', tag: 'danger' })
})
test('align_digital_human_file_size_fixed_two_decimals_mb', () => {
assert.equal(digitalHumanVersionFileSizeText(2 * 1024 * 1024), '2.00 MB')
assert.equal(digitalHumanVersionFileSizeText(1.5 * 1024 * 1024), '1.50 MB')
assert.equal(digitalHumanVersionFileSizeText(undefined), '-')
assert.equal(digitalHumanVersionFileSizeText(0), '-')
})
test('align_digital_human_changelog_50_char_truncate', () => {
assert.equal(digitalHumanChangelogShort(''), '-')
assert.equal(digitalHumanChangelogShort('短说明'), '短说明')
const long = 'x'.repeat(60)
assert.equal(digitalHumanChangelogShort(long), 'x'.repeat(50) + '...')
})
test('align_digital_human_confirm_texts', () => {
assert.equal(releaseDigitalHumanConfirmText('1.0.1'), '确认发布版本 1.0.1 吗?')
assert.equal(setLatestDigitalHumanConfirmText('1.0.1'), '确认将版本 1.0.1 设为最新吗?客户端会自动检测更新。')
})
test('align_digital_human_upload_zip_only', () => {
// 仅 zip + 对应错误文案(对齐 admin.js:6520-6523)。
const { errors } = validateDigitalHumanUpload({ version: '1.0.1', file: { name: 'pkg.rar', size: 100 } })
assert.equal(errors.file, '仅支持 .zip 格式')
assert.equal(validateDigitalHumanUpload({ version: '1.0.1', file: { name: 'pkg.zip', size: 100 } }).valid, true)
})
test('align_digital_human_api_download_url', () => {
const api = readSource('src/pages/records/digitalhuman-api.ts')
assert.match(api, /download-url/, '含下载链接端点')
assert.match(api, /onUploadProgress/, '上传带进度回调')
})
test('align_digital_human_page_wiring', () => {
const page = readSource('src/pages/records/RecordsDigitalHumanVersionPage.vue')
assert.match(page, /pageSize\s*=\s*20|:page-size="20"/, '分页大小 20')
assert.match(page, /el-pagination/, '分页组件')
assert.match(page, /设为最新/, '按钮名对齐“设为最新”')
assert.match(page, /上传(草稿状态)/, '上传按钮名对齐')
assert.match(page, /上传数字人程序 ZIP 包,系统会自动计算 MD5 并存储到 OSS。上传后状态为草稿,需要手动发布/, '上传弹窗描述对齐')
assert.match(page, /正在上传/, '上传进度文案')
assert.match(page, /digitalHumanDeleteConfirmText/, '删除确认文案走对齐模型')
assert.match(page, /downloadUrl|fetchDigitalHumanDownloadUrl/, 'RELEASED 下载按钮点击取链接')
assert.match(page, /已废弃/, '状态三态接入')
assert.match(page, /digitalHumanChangelogShort/, '更新说明 50 字符截断')
})
+9 -9
View File
@@ -11,9 +11,9 @@ test('test_task_131_dh_version_dto_normal_primary_path', () => {
})
test('test_task_131_dh_version_dto_normal_variant_input', () => {
// 正常变体:未知状态回 DRAFT
assert.equal(normalizeDigitalHumanStatus('weird'), 'DRAFT')
assert.equal(normalizeDigitalHumanStatus(''), 'DRAFT')
// 正常变体:未知状态回 已废弃(对齐 admin.js:6337 三态)
assert.equal(normalizeDigitalHumanStatus('weird'), 'DEPRECATED')
assert.equal(normalizeDigitalHumanStatus(''), 'DEPRECATED')
})
test('test_task_131_dh_version_dto_repeated_is_idempotent', () => {
@@ -22,8 +22,8 @@ test('test_task_131_dh_version_dto_repeated_is_idempotent', () => {
})
test('test_task_131_dh_version_dto_boundary_empty_input', () => {
// 边界空值:非字符串按 DRAFT
assert.equal(normalizeDigitalHumanStatus(null as unknown as string), 'DRAFT')
// 边界空值:非字符串按 已废弃
assert.equal(normalizeDigitalHumanStatus(null as unknown as string), 'DEPRECATED')
})
test('test_task_131_dh_version_dto_boundary_single_item', () => {
@@ -32,14 +32,14 @@ test('test_task_131_dh_version_dto_boundary_single_item', () => {
})
test('test_task_131_dh_version_dto_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:版本类型定义里 status 为受控枚举。
// 边界上限/缺字段:版本类型定义里 status 为三态受控枚举。
const mod = readSource('src/pages/records/digitalhuman-dto.ts')
assert.match(mod, /'DRAFT' \| 'RELEASED'/)
assert.match(mod, /'DRAFT' \| 'RELEASED' \| 'DEPRECATED'/)
})
test('test_task_131_dh_version_dto_invalid_input_rejected', () => {
// 异常输入:非受控状态被拒绝为 DRAFT
assert.equal(normalizeDigitalHumanStatus(1 as unknown as string), 'DRAFT')
// 异常输入:非受控状态归为 已废弃(对齐 admin.js 三态兜底)
assert.equal(normalizeDigitalHumanStatus(1 as unknown as string), 'DEPRECATED')
})
test('test_task_131_dh_version_dto_dependency_failure_returns_actionable_message', () => {
+4 -4
View File
@@ -20,8 +20,8 @@ test('test_task_134_dh_status_display_repeated_is_idempotent', () => {
})
test('test_task_134_dh_status_display_boundary_empty_input', () => {
// 边界空值:非受控状态按草稿展示
assert.deepEqual(digitalHumanStatusDisplay(''), { text: '草稿', tag: 'info' })
// 边界空值:非受控状态按 已废弃 展示(对齐 admin.js 三态)
assert.deepEqual(digitalHumanStatusDisplay(''), { text: '已废弃', tag: 'danger' })
})
test('test_task_134_dh_status_display_boundary_single_item', () => {
@@ -35,8 +35,8 @@ test('test_task_134_dh_status_display_boundary_limit_or_missing_field', () => {
})
test('test_task_134_dh_status_display_invalid_input_rejected', () => {
// 异常输入:非字符串按草稿
assert.deepEqual(digitalHumanStatusDisplay(null as unknown as string), { text: '草稿', tag: 'info' })
// 异常输入:非字符串按 已废弃
assert.deepEqual(digitalHumanStatusDisplay(null as unknown as string), { text: '已废弃', tag: 'danger' })
})
test('test_task_134_dh_status_display_dependency_failure_returns_actionable_message', () => {
+1 -1
View File
@@ -6,7 +6,7 @@ import { canReleaseDigitalHumanVersion, releaseDigitalHumanConfirmText } from '.
test('test_task_135_dh_release_normal_primary_path', () => {
// 正常主路径:草稿版本可发布并给出确认文案。
assert.equal(canReleaseDigitalHumanVersion('DRAFT'), true)
assert.equal(releaseDigitalHumanConfirmText('1.0.0'), '确发布数字人版本 1.0.0 吗?')
assert.equal(releaseDigitalHumanConfirmText('1.0.0'), '确发布版本 1.0.0 吗?')
})
test('test_task_135_dh_release_normal_variant_input', () => {
+1 -1
View File
@@ -6,7 +6,7 @@ import { canSetLatestDigitalHumanVersion, setLatestDigitalHumanConfirmText } fro
test('test_task_136_dh_set_latest_normal_primary_path', () => {
// 正常主路径:已发布版本可设为最新并给确认文案。
assert.equal(canSetLatestDigitalHumanVersion('RELEASED'), true)
assert.equal(setLatestDigitalHumanConfirmText('2.0.0'), '确定将数字人版本 2.0.0 设为最新吗?')
assert.equal(setLatestDigitalHumanConfirmText('2.0.0'), '确认将版本 2.0.0 设为最新吗?客户端会自动检测更新。')
})
test('test_task_136_dh_set_latest_normal_variant_input', () => {
+11 -8
View File
@@ -32,29 +32,32 @@ test('test_task_261_dh_normal_repeated_operation_is_idempotent', () => {
test('test_task_261_dh_boundary_empty_input', () => {
assert.equal(latestBadgeText(true), '最新')
assert.equal(latestBadgeText(false), '')
assert.equal(digitalHumanStatusDisplay('').text, '草稿', '未知状态归一草稿')
// 未知状态归一 已废弃(对齐 admin.js 三态)。
assert.equal(digitalHumanStatusDisplay('').text, '已废弃')
})
test('test_task_261_dh_boundary_single_item', () => {
const page = readSource('src/pages/records/RecordsDigitalHumanVersionPage.vue')
assert.match(page, /formatFileSize/, '文件大小走共享格式化')
assert.match(page, /md5Short/, 'MD5 截展示')
assert.match(page, /digitalHumanVersionFileSizeText/, '文件大小固定两位 MB(对齐 admin')
assert.match(page, /substring\(0, 12\)/, 'MD5 截 12 位展示')
assert.match(page, /canReleaseDigitalHumanVersion/, '发布按钮按状态显隐')
})
test('test_task_261_dh_boundary_limit_or_missing_field', () => {
// 边界上限:文件大小格式化(复用了版本页 formatFileSize)。
const fmt = readSource('src/pages/records/version-format.ts')
assert.match(fmt, /formatFileSize/)
// 边界上限:文件大小固定 (bytes/1024/1024).toFixed(2)+' MB'(对齐 admin.js:6340)。
const dto = readSource('src/pages/records/digitalhuman-dto.ts')
assert.match(dto, /1024 \/ 1024\)\.toFixed\(2\)/, '固定两位小数 MB')
})
test('test_task_261_dh_invalid_input_rejected', () => {
// 异常:删除需二次确认;删除走后端 DELETE;删除失败有兜底。
// 异常:删除需二次确认(对齐 admin.js:6356 文案);删除走后端 DELETE;删除失败有兜底。
const page = readSource('src/pages/records/RecordsDigitalHumanVersionPage.vue')
assert.match(page, /此操作不可恢复/, '删除需危险二次确认')
assert.match(page, /digitalHumanDeleteConfirmText/, '删除确认文案走对齐模型')
assert.match(page, /删除失败/, '删除失败有兜底文案')
const api = readSource('src/pages/records/digitalhuman-api.ts')
assert.match(api, /http\.delete/, '删除调用 DELETE 适配')
const dto = readSource('src/pages/records/digitalhuman-dto.ts')
assert.match(dto, /确认删除版本 .* 吗?该操作会删除对应文件,无法恢复/, '删除文案对齐 admin')
})
test('test_task_261_dh_dependency_failure_returns_actionable_message', () => {