feat: read supported platforms from live backend
This commit is contained in:
@@ -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) => `<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("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user