feat(工作台): 视频详情首行改「查看视频」可点击链接,不显示具体视频地址

This commit is contained in:
maogeigei committed 2026-09-01 15:11:32 +08:00
1 parent eb73c89b90
commit 1e2b8378c0
3 files changed
+9 -8

No files matched your search

@@ -49,7 +49,7 @@ async function main() {
let pass = 0, fail = 0;
const check = (name, cond, extra = '') => { cond ? pass++ : fail++; console.log((cond ? 'PASS' : 'FAIL') + ' | ' + name + (cond ? '' : ' ← ' + extra)); };
await cdp(ws, 'Page.navigate', { url: 'http://localhost:8900/?v=titlebar#/video/680' });
await cdp(ws, 'Page.navigate', { url: 'http://localhost:8900/?v=tb' + Date.now() + '#/video/680' });
await waitFor(ws, `!!document.querySelector('.video-info')`, 15000, '视频详情渲染');
const r = await evalJs(ws, `(() => {
@@ -57,15 +57,13 @@ async function main() {
const rows = card ? [...card.querySelectorAll('.info-row')] : [];
const toolbarTitle = document.querySelector('.page-toolbar .page-title');
const r0 = rows[0];
const firstLabel = r0 ? r0.querySelector('.info-label').textContent.trim() : '';
const firstLink = r0 ? r0.querySelector('a') : null;
const rowLabels = rows.slice(1).map((row) => [...row.querySelectorAll('.info-label')].map((l) => l.textContent.trim()));
return {
toolbarTitle: toolbarTitle ? toolbarTitle.textContent.trim() : '',
rowCount: rows.length,
firstLabel,
firstText: r0 ? r0.textContent.trim() : '',
firstHref: firstLink ? (firstLink.getAttribute('data-ext') || firstLink.getAttribute('href')) : null,
firstText: r0 ? r0.textContent.trim().slice(0, 60) : '',
rowLabels,
hasRenderErr: document.body.textContent.includes('渲染失败') || document.body.textContent.includes('not defined')
};
@@ -73,8 +71,9 @@ async function main() {
check('toolbar 显示视频标题名称(非静态"视频详情"): ' + r.toolbarTitle, !!r.toolbarTitle && r.toolbarTitle !== '视频详情' && r.toolbarTitle.length > 2, r.toolbarTitle);
check('信息卡共 4 组行', r.rowCount === 4);
check('首行标签=「视频地址」: ' + r.firstLabel, r.firstLabel === '视频地址', r.firstLabel);
check('首行含可点击链接(https): ' + (r.firstHref || '').slice(0, 40), !!r.firstHref && /^https?:/.test(r.firstHref), r.firstHref || '');
check('首行显示「查看视频」字样: ' + r.firstText, r.firstText.includes('查看视频'), r.firstText);
check('首行不含具体 URL 明文', !/https?:\/\//.test(r.firstText), r.firstText);
check('首行链接可点击(https): ' + (r.firstHref || '').slice(0, 40), !!r.firstHref && /^https?:/.test(r.firstHref), r.firstHref || '');
check('第2行=账号/视频ID/时长/发布时间', JSON.stringify(r.rowLabels[0]) === JSON.stringify(['账号', '视频ID', '时长', '发布时间']), JSON.stringify(r.rowLabels[0]));
check('第3行=点赞/评论/分享/收藏', JSON.stringify(r.rowLabels[1]) === JSON.stringify(['点赞', '评论', '分享', '收藏']), JSON.stringify(r.rowLabels[1]));
check('第4行=标签', JSON.stringify(r.rowLabels[2]) === JSON.stringify(['标签']), JSON.stringify(r.rowLabels[2]));
@@ -531,7 +531,7 @@ async function renderVideoDetail(view, id) {
const analysisToMd = (obj) => Object.entries(obj || {}).map(([k, val]) => `# ${k}\n\n${val}`).join('\n\n---\n\n');
function load() {
const urlVal = v.video_url ? `<a class="link" data-ext="${esc(v.video_url)}" title="打开视频网页">${esc(v.video_url)}</a>` : '无';
const viewLink = v.video_url ? `<a class="link" data-ext="${esc(v.video_url)}" title="打开视频网页">查看视频 ↗</a>` : '无';
const scriptMd = parse.content || null;
const deconstructMd = parse.analysis ? analysisToMd(parse.analysis) : null;
const analysisMd = analysis && analysis.content ? analysis.content : null;
@@ -545,7 +545,7 @@ async function renderVideoDetail(view, id) {
<div class="page-toolbar">${toolbarBack()}<span class="page-title">${esc(cleanTitle(v.video_title) || '视频详情')}</span></div>
<div class="detail-body">
<div class="info-card video-info">
<div class="info-row">${infoGrid('视频地址', urlVal, true, true)}</div>
<div class="info-row"><div class="info-item info-wide">${viewLink}</div></div>
<div class="info-row">${infoGrid('账号', v.account_name)}${infoGrid('视频ID', v.aweme_id)}${infoGrid('时长', fmtDuration(v.duration))}${infoGrid('发布时间', v.publish_time)}</div>
<div class="info-row">${infoGrid('点赞', fmtWan(v.like_display || v.like_count))}${infoGrid('评论', fmtWan(v.comment_count))}${infoGrid('分享', fmtWan(v.share_count))}${infoGrid('收藏', fmtWan(v.collect_count))}</div>
<div class="info-row">${infoGrid('标签', v.tags, true)}</div>