fix: soften missing douyin video routes in web v4

This commit is contained in:
kris
2026-03-23 07:49:04 +08:00
parent 54afca2bf4
commit d7132fe932

View File

@@ -578,15 +578,24 @@ async function loadKnowledgeDocuments(knowledgeBases) {
async function loadDouyinAccount(accountId) {
if (!accountId) return;
appState.selectedAccountId = accountId;
const supportsAccountVideos = backendSupports("/v2/douyin/accounts/{account_id}/videos");
const [workspace, videos] = await Promise.all([
storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/workspace`),
storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/videos?limit=80`).catch(() => ({
items: [],
meta: {},
top_scored_video_ids: [],
latest_video_ids: [],
high_score_threshold: 60
}))
supportsAccountVideos
? storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/videos?limit=80`).catch(() => ({
items: [],
meta: {},
top_scored_video_ids: [],
latest_video_ids: [],
high_score_threshold: 60
}))
: Promise.resolve({
items: [],
meta: {},
top_scored_video_ids: [],
latest_video_ids: [],
high_score_threshold: 60
})
]);
appState.selectedWorkspace = workspace;
appState.selectedVideos = videos;
@@ -849,7 +858,9 @@ function getSelectedAccount() {
function getHighScoreVideos(limit = 3) {
const items = safeArray(appState.selectedVideos?.items);
return items
const fallback = safeArray(getSelectedAccount()?.video_summary?.videos);
const pool = items.length ? items : fallback;
return pool
.slice()
.sort((a, b) => Number(b.score?.performance_score || 0) - Number(a.score?.performance_score || 0))
.slice(0, limit);
@@ -857,7 +868,9 @@ function getHighScoreVideos(limit = 3) {
function getLatestVideos(limit = 3) {
const items = safeArray(appState.selectedVideos?.items);
return items
const fallback = safeArray(getSelectedAccount()?.video_summary?.videos);
const pool = items.length ? items : fallback;
return pool
.slice()
.sort((a, b) => new Date(b.published_at || 0).getTime() - new Date(a.published_at || 0).getTime())
.slice(0, limit);
@@ -1511,6 +1524,8 @@ function renderDiscoveryScreen() {
const reports = safeArray(appState.selectedWorkspace?.recent_reports);
const linkedAccounts = safeArray(appState.selectedWorkspace?.linked_accounts);
const videos = safeArray(appState.selectedVideos?.items);
const fallbackVideos = safeArray(selected?.video_summary?.videos);
const effectiveVideos = videos.length ? videos : fallbackVideos;
const topVideos = getHighScoreVideos(3);
const latestVideos = getLatestVideos(2);
const similarCandidates = safeArray(appState.lastSimilaritySearch?.candidates).slice(0, 5);
@@ -1533,7 +1548,7 @@ function renderDiscoveryScreen() {
<div class="filter">平台抖音</div>
<div class="filter">账号数${escapeHtml(formatNumber(accounts.length))}</div>
<div class="filter">报告${escapeHtml(formatNumber(reports.length))}</div>
<div class="filter">作品${escapeHtml(formatNumber(videos.length))}</div>
<div class="filter">作品${escapeHtml(formatNumber(effectiveVideos.length))}</div>
</div>
</div>
<div class="side-stack">
@@ -1671,7 +1686,7 @@ function renderDiscoveryScreen() {
</div>
</div>
<div class="panel pad" style="box-shadow:none; margin-top:16px;">
<div class="panel-head"><div><h3>最新作品</h3><div class="panel-subtitle"></div></div><span class="tag">${escapeHtml(formatNumber(videos.length))} </span></div>
<div class="panel-head"><div><h3>最新作品</h3><div class="panel-subtitle"></div></div><span class="tag">${escapeHtml(formatNumber(effectiveVideos.length))} </span></div>
<div class="list">
${latestVideos.map((video) => `
<div class="task-item">
@@ -2755,6 +2770,11 @@ function openAnalyzeSelectedAccountAction() {
function openAnalyzeTopVideosAction() {
const account = requireSelectedAccountRow();
if (!backendSupports("/v2/douyin/accounts/{account_id}/videos/analyze-top")) {
rememberAction("当前后端暂不支持", "这套 live collector 还没有接入高分作品批量分析。", "orange");
renderAll();
return;
}
openActionModal({
title: "分析高分作品",
description: "对当前对标账号的高分作品批量补分析。",