From 941e171455549cf88473eb4d8530fb84f5dce41b Mon Sep 17 00:00:00 2001 From: kris Date: Mon, 23 Mar 2026 08:49:32 +0800 Subject: [PATCH] feat: read supported platforms from live backend --- web/storyforge-web-v4/assets/app.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/web/storyforge-web-v4/assets/app.js b/web/storyforge-web-v4/assets/app.js index b82754f..9c01dab 100644 --- a/web/storyforge-web-v4/assets/app.js +++ b/web/storyforge-web-v4/assets/app.js @@ -136,8 +136,18 @@ function safeArray(value) { return Array.isArray(value) ? value : []; } +function getRuntimePlatformValues() { + const fromDashboard = safeArray(appState.dashboard?.supported_platforms) + .map((item) => normalizePlatformValue(item, "")) + .filter((item) => item && PLATFORM_REGISTRY[item]); + if (fromDashboard.length) { + return fromDashboard; + } + return ACTIVE_PLATFORMS.map((item) => item.value); +} + function getPlatformOptions() { - return ACTIVE_PLATFORMS.map((item) => ({ value: item.value, label: item.label })); + return getRuntimePlatformValues().map((value) => ({ value, label: getPlatformMeta(value)?.label || value })); } function normalizePlatformValue(value, fallback = "douyin") { @@ -162,6 +172,10 @@ function getPlatformShortLabel(value) { return getPlatformMeta(value)?.shortLabel || platformLabel(value); } +function getPlatformChips() { + return ["全平台", ...getRuntimePlatformValues().map((value) => getPlatformShortLabel(value))]; +} + function isWorkbenchPlatform(value) { return Boolean(getPlatformMeta(value)?.workbenchReady); } @@ -2415,7 +2429,7 @@ function renderTopbar() { topPills[2].textContent = `任务 ${formatNumber(appState.dashboard?.recent_jobs?.length || 0)}`; } if (platforms) { - platforms.innerHTML = ACTIVE_PLATFORM_CHIPS.map((label, index) => `${escapeHtml(label)}`).join(""); + platforms.innerHTML = getPlatformChips().map((label, index) => `${escapeHtml(label)}`).join(""); } }