feat: read supported platforms from live backend

This commit is contained in:
kris
2026-03-23 08:49:32 +08:00
parent ac7fe786f3
commit 941e171455

View File

@@ -136,8 +136,18 @@ function safeArray(value) {
return Array.isArray(value) ? 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() { 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") { function normalizePlatformValue(value, fallback = "douyin") {
@@ -162,6 +172,10 @@ function getPlatformShortLabel(value) {
return getPlatformMeta(value)?.shortLabel || platformLabel(value); return getPlatformMeta(value)?.shortLabel || platformLabel(value);
} }
function getPlatformChips() {
return ["全平台", ...getRuntimePlatformValues().map((value) => getPlatformShortLabel(value))];
}
function isWorkbenchPlatform(value) { function isWorkbenchPlatform(value) {
return Boolean(getPlatformMeta(value)?.workbenchReady); return Boolean(getPlatformMeta(value)?.workbenchReady);
} }
@@ -2415,7 +2429,7 @@ function renderTopbar() {
topPills[2].textContent = `任务 ${formatNumber(appState.dashboard?.recent_jobs?.length || 0)}`; topPills[2].textContent = `任务 ${formatNumber(appState.dashboard?.recent_jobs?.length || 0)}`;
} }
if (platforms) { if (platforms) {
platforms.innerHTML = ACTIVE_PLATFORM_CHIPS.map((label, index) => `<span class="chip ${index === 0 ? "active" : ""}">${escapeHtml(label)}</span>`).join(""); platforms.innerHTML = getPlatformChips().map((label, index) => `<span class="chip ${index === 0 ? "active" : ""}">${escapeHtml(label)}</span>`).join("");
} }
} }