Files
crawler-plugin/admin-frontend-vue/src/pages/records/RecordsDigitalHumanVersionPage.vue
T
huangzd1997 92af45a899 fix(后管表格): 操作列给 px 下限并统一可换行,店铺密钥整表 1538→1227px
三张截图同一个结构缺陷的两个方向:操作列 <td> 上直接 display:flex + overflow:hidden +
white-space:nowrap,而列宽是声明死的,超宽时的失败模式是"按钮静默消失"——DOM 里在、
事件也在,就是看不见点不到。
  - 写死 px(店铺密钥线上 160,三颗按钮实测需 215.5)⇒ 从右裁,删除整颗没了;
  - 写百分比(最低价 ASIN 9%,两颗需 114)⇒ 百分比跟容器一起缩,且 .asin-col-actions
    带 justify-content:flex-end 把溢出翻到左侧,于是"配置"被吃掉而"删除"看着完好。

flex-wrap 单独不够:900px 容器下 9% 只有 56.7px,连一颗 53px 按钮加 24px padding 都装不下,
换行之后照样裁。所以列必须有 px 下限。OPS_MIN_COL_PX 是 browser-use 在 100% 缩放下渲染
.btn.btn-sm 量的 offsetWidth(两字 53/四字 80/五字 93.5)+ gap 8 + td 左右 padding 24,
三元文案按较长分支计,不是按字数估的。

改动落在 18 处操作列里不达标的 6 处:UserSecrets 250→315、RecordsDigitalHuman 240→290、
DedupeRegistry 无声明→140、QueryAsin 与 SkipPrice 9%→140 并补 flex-wrap、
ShopKeys 270→245。另把店铺密钥整表 1538→1227px(代理 190→90、紫鸟令牌 220→160、
白名单状态 150→110 等按实测内容宽收窄):那页 100% 缩放下内容区只有 ~1280,
"操作"整列要横向滚动才看到,这才是"没显示全"的主账。

护栏扩到 5 条。一个真发现:旧护栏只扫 .ops-cell,扫不到 .asin-col-actions——这就是
1051d844 声称"扫过 8 个页面"却把最低价 ASIN 两页整个留在盲区的原因。现补上双向登记表
相等断言(新增页面不登记就红)。过程中护栏抓到我自己写的缺陷:<th[^>]*> 会连 <thead>
一起吃掉,再被新加的 HTML 注释里的"操作"两字喂饱,把"序号 52px"当成操作列宽度报出来;
已改为排除 <thead> + 解析前剥注释,并补一条内存反例自证(专喂"注释里写 flex-wrap 但代码
没设"和"百分比列"两种形状),防止尺子变恒绿。

验证:干净 worktree(2455b8fa + 只本批 7 个文件,git status 恰好 7 行 M)实跑前端 1765 例
0 红、vue-tsc rc=0、vite build rc=0;产物正反锚点已核 ShopKeys chunk 245px→1/旧值
270px→0、SkipPrice chunk 140px→1/旧值 9%→0。真浏览器复验 1280/1440/1516 三种容器下
三页 hScroll=0 且操作列不裁,900px 极端容器下仍不裁、只有文本列走 ellipsis(都有 title)。
主树混合态另跑 1769 例 0 红,差的 4 例是并行会话未提交的测试,与本批无关。
2026-10-08 20:59:49 +08:00

570 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/** 数字人版本管理页 · 像素复刻旧版 admin.html panel-digital-human-version(自绘:面板头+上传、三态状态色、最新★、操作矩阵、数字页码分页)。
* script 逻辑沿用现有 Vue 实现(确认文案/上传进度/下载取链接);确认走原生 confirm 对齐旧版。 */
import { formatDateTime } from '@/utils/datetime'
import { computed, onMounted, ref, watch } from 'vue'
import { ElMessage } 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 OldPagination from '@/components/OldPagination.vue'
import { digitalHumanStatusDisplay } from './digitalhuman-status-display.ts'
const loading = ref(false)
const items = ref<DigitalHumanVersion[]>([])
/** 分页(对齐 admin.js:6311 pageSize=20 + 数字页码 + 跳转;Java 列表接口不分页,前端分页呈现)。 */
const pageSize = ref(10)
const page = ref(1)
/** 版本号搜索(客户端过滤)。 */
const versionKeyword = ref('')
const filteredItems = computed(() => {
const kw = (versionKeyword.value || '').trim().toLowerCase()
if (!kw) return items.value
return items.value.filter((item) => `${item.version}`.toLowerCase().includes(kw))
})
const pagedItems = computed(() => {
const start = (page.value - 1) * pageSize.value
return filteredItems.value.slice(start, start + pageSize.value)
})
const totalPages = computed(() => Math.max(1, Math.ceil(filteredItems.value.length / pageSize.value)))
const jumpPage = ref('')
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
// 页码越界回钳见下方 watch(items)。
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '版本列表加载失败')
} finally {
loading.value = false
}
}
function changePage(next: number): void {
if (next < 1 || next > totalPages.value) return
page.value = next
}
function changeSize(size: number) {
pageSize.value = size
page.value = 1
}
// 版本号搜索导致数据收缩时回钳页码,避免停在空页。
watch(items, () => {
const last = Math.max(Math.ceil(filteredItems.value.length / pageSize.value), 1)
if (page.value > last) page.value = last
})
function goJump(): void {
const n = Number.parseInt(jumpPage.value, 10)
if (Number.isNaN(n)) {
ElMessage.warning('请输入页码')
return
}
changePage(Math.min(Math.max(n, 1), totalPages.value))
}
function onFileChange(file: File) {
form.value.file = file
}
async function submitUpload() {
const { valid, errors } = validateDigitalHumanUpload({ ...form.value, file: form.value.file })
if (!valid) {
ElMessage.warning(errors.version || errors.file || '请完善上传信息')
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) {
ElMessage.error(error instanceof Error ? error.message : '上传失败')
} finally {
uploading.value = false
}
}
async function release(row: DigitalHumanVersion) {
const text = releaseDigitalHumanConfirmText(row.version)
if (!text) return
// 对齐旧版:原生 confirm。
if (!window.confirm(text)) return
confirming.value = row.version
try {
await releaseDigitalHumanVersion(row.version)
ElMessage.success('已发布')
load()
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '发布失败')
} finally {
confirming.value = null
}
}
async function setLatest(row: DigitalHumanVersion) {
const text = setLatestDigitalHumanConfirmText(row.version)
if (!text) return
if (!window.confirm(text)) return
confirming.value = row.version
try {
await setLatestDigitalHumanVersion(row.version)
ElMessage.success('已设为最新')
load()
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '操作失败')
} finally {
confirming.value = null
}
}
/** 下载(对齐 admin.js downloadDigitalHumanVersion:RELEASED 恒显示,点击取链接并触发下载)。 */
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
if (!window.confirm(text)) return
confirming.value = row.version
try {
await deleteDigitalHumanVersion(row.version)
ElMessage.success('删除成功')
load()
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '删除失败')
} finally {
confirming.value = null
}
}
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>
<template>
<div class="dh-view">
<section class="panel-box">
<div class="dh-head">
<h3>版本列表</h3>
<div class="dh-head-tools">
<input v-model="versionKeyword" type="text" placeholder="搜索版本号" class="dh-keyword" />
<button class="btn" type="button" @click="uploadVisible = true">上传新版本</button>
</div>
</div>
<div class="table-scroll digital-human-version-table-scroll">
<table>
<thead>
<tr>
<th style="width: 80px">版本号</th>
<th style="width: 60px">状态</th>
<th style="width: 60px">最新</th>
<th style="width: 80px">文件大小</th>
<th style="width: 120px">MD5</th>
<th>更新日志</th>
<th style="width: 140px">发布时间</th>
<th style="width: 290px">操作</th>
</tr>
</thead>
<tbody>
<template v-if="pagedItems.length">
<tr v-for="row in pagedItems" :key="row.version + row.id">
<td><span class="mono-cell">{{ row.version }}</span></td>
<td>
<span class="st-pill" :class="`is-${statusOf(row).tag}`">{{ statusOf(row).text }}</span>
</td>
<td><span v-if="row.isLatest" class="star" title="最新版本">★</span><span v-else class="dim">—</span></td>
<td>{{ digitalHumanVersionFileSizeText(row.fileSize) }}</td>
<td><span :title="row.md5 || ''" class="mono-cell">{{ row.md5 ? `${row.md5.substring(0, 12)}...` : '—' }}</span></td>
<td>
<span :title="row.changelog || ''" class="changelog-cell">{{ digitalHumanChangelogShort(row.changelog) }}</span>
</td>
<td>{{ formatDateTime(row.releasedAt) }}</td>
<td class="ops-cell">
<button v-if="canReleaseDigitalHumanVersion(row.status)" class="btn btn-sm" type="button" :disabled="confirming === row.version" @click="release(row)">发布</button>
<button
v-if="!canReleaseDigitalHumanVersion(row.status) && canSetLatestDigitalHumanVersion(row.status) && !row.isLatest"
class="btn btn-sm"
type="button"
:disabled="confirming === row.version"
@click="setLatest(row)"
>
设为最新
</button>
<button v-if="canSetLatestDigitalHumanVersion(row.status)" class="btn btn-sm btn-secondary" type="button" :disabled="downloadingVersion === row.version" @click="download(row)">下载</button>
<button v-if="canDelete(row)" class="btn btn-sm btn-danger" type="button" :disabled="confirming === row.version" @click="remove(row)">删除</button>
</td>
</tr>
</template>
<tr v-else-if="loading">
<td colspan="8" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="8" class="empty-tip">{{ versionKeyword ? '暂无匹配版本' : '暂无版本记录' }}</td>
</tr>
</tbody>
</table>
</div>
<div v-if="filteredItems.length > pageSize" class="pagination">
<OldPagination :total="filteredItems.length" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
</div>
</section>
<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" :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>
</el-form-item>
<el-form-item label="最低客户端">
<el-input v-model="form.minClientVersion" placeholder="可选,客户端最低版本要求" />
</el-form-item>
<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>
</template>
</el-dialog>
</div>
</template>
<style scoped>
/* 像素复刻旧版 admin.html panel-digital-human-version(蓝白末层)。 */
.dh-view {
font-family: inherit;
color: #24384d;
}
.panel-box {
width: 100%;
min-width: 0;
padding: 20px 22px 24px;
border: 1px solid #d8e3ee;
border-radius: 14px;
background: linear-gradient(145deg, #ffffff, #f9fbfd);
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
}
h3 {
margin: 0;
font-size: 15px;
font-weight: 650;
color: #24384d;
letter-spacing: 0.2px;
}
.dh-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 16px;
}
.dh-head-tools {
display: flex;
align-items: center;
gap: 10px;
}
.dh-keyword {
width: 200px;
min-height: 42px;
padding: 6px 12px;
border: 1px solid #cbd9e6;
border-radius: 9px;
background: #f8fbfd;
color: #24384d;
font-size: 13.5px;
font-family: inherit;
color-scheme: light;
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.dh-keyword:hover {
border-color: #9fb7cd;
}
.dh-keyword:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-height: 42px;
padding: 9px 18px;
border: 1px solid #4f78a5;
border-radius: 9px;
background: linear-gradient(135deg, #5f85ad, #4f78a5);
color: #ffffff;
font-family: inherit;
font-size: 13.5px;
cursor: pointer;
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}
.btn:hover:not(:disabled) {
background: linear-gradient(135deg, #7094ba, #5d83ac);
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
}
.btn:disabled {
cursor: not-allowed;
opacity: 0.55;
}
.btn-secondary {
background: #ffffff;
color: #5b6f83;
border-color: #c7d7e5;
}
.btn-secondary:hover:not(:disabled) {
color: #2f5d8b;
border-color: #95b1cb;
background: #edf5fb;
}
.btn-danger {
background: linear-gradient(135deg, #c06d77, #b35f6a);
border-color: #b35f6a;
}
.btn-danger:hover:not(:disabled) {
background: linear-gradient(135deg, #cb7c84, #b96570);
}
.btn-sm {
min-height: 36px;
padding: 7px 12px;
}
.table-scroll {
width: 100%;
min-width: 0;
overflow-x: auto;
border: 1px solid #dbe5ee;
border-radius: 10px;
background: #ffffff;
}
.table-scroll table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.digital-human-version-table-scroll > table {
min-width: 1120px;
}
.table-scroll th,
.table-scroll td {
padding: 10px 12px;
text-align: left;
font-size: 13.5px;
line-height: 1.5;
border-bottom: 1px solid #e0e8ef;
vertical-align: middle;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.table-scroll th {
background: #edf4fa;
color: #4e6479;
border-bottom-color: #d5e1eb;
font-size: 12.5px;
font-weight: 600;
letter-spacing: 0.4px;
}
.table-scroll tbody tr:hover td {
background: #f1f7fb;
}
.table-scroll tbody tr:last-child td {
border-bottom: 0;
}
.mono-cell {
font-family: "Cascadia Mono", Consolas, monospace;
font-size: 12.5px;
}
.st-pill {
display: inline-flex;
align-items: center;
padding: 2px 10px;
border-radius: 999px;
font-size: 12px;
line-height: 1.7;
border: 1px solid transparent;
}
.st-pill.is-info {
color: #6b7280;
background: #f1f3f5;
border-color: #dfe3e8;
}
.st-pill.is-success {
color: #398a3f;
background: #eaf7ec;
border-color: #bfe3c5;
}
.st-pill.is-danger {
color: #b8454d;
background: #fbedee;
border-color: #ecc9cc;
}
.star {
color: #d64545;
font-weight: 700;
}
.changelog-cell {
display: block;
color: #5b6f83;
overflow: hidden;
text-overflow: ellipsis;
}
.ops-cell {
display: flex;
align-items: center;
gap: 8px;
white-space: nowrap;
flex-wrap: wrap;
}
.empty-tip {
padding: 44px 24px;
text-align: center;
color: #8293a5;
font-size: 13.5px;
}
.pagination {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin-top: 18px;
color: #5b6f83;
font-size: 13px;
}
.pagination button {
min-height: 30px;
padding: 4px 12px;
border: 1px solid #c7d7e5;
border-radius: 8px;
background: #ffffff;
color: #5b6f83;
font-family: inherit;
font-size: 13px;
cursor: pointer;
}
.pagination button:hover:not(:disabled) {
background: #edf5fb;
border-color: #95b1cb;
color: #2f5d8b;
}
.pagination button:disabled {
background: #eef3f7;
color: #9baaba;
cursor: not-allowed;
}
.page-nums {
display: inline-flex;
gap: 6px;
}
.num-page {
min-width: 30px;
padding: 4px 8px;
}
.num-page.is-active {
background: #2f5d8b;
border-color: #2f5d8b;
color: #ffffff;
}
.page-jump {
display: inline-flex;
align-items: center;
gap: 6px;
}
.page-jump input {
width: 56px;
min-height: 30px;
padding: 4px 8px;
border: 1px solid #cbd9e6;
border-radius: 8px;
background: #f8fbfd;
color: #24384d;
font-size: 13px;
font-family: inherit;
}
.dim {
color: #8293a5;
font-size: 12px;
}
.upload-desc {
margin: 0 0 12px;
color: #5b6f83;
font-size: 12.5px;
line-height: 1.6;
}
</style>