feat(kol): support multiple platform hints with shared tag renderer
Frontend CI / Frontend (push) Successful in 2m47s
Backend CI / Backend (push) Failing after 6m50s

Turn the KOL prompt platform hint into a multi-select backed by the
media platforms API, persist hints as a 、-joined string, and add a
reusable KolPlatformTags component so manage/generate/package/template/
workspace views and the generate-task drawer all render the hints
consistently with truncation and overflow handling.

Also auto-select the first available subscription prompt in
GenerateTaskDrawer when switching to the subscription-prompt target so
users land on a usable option without an extra click.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 01:48:04 +08:00
parent db95b8e4ee
commit 8991edabb5
10 changed files with 322 additions and 57 deletions
+42 -4
View File
@@ -1,13 +1,51 @@
import { aiPlatformCatalog } from '@geo/shared-types'
import type { MediaPlatform } from '@geo/shared-types'
export interface KolPlatformOption {
label: string
value: string
disabled?: boolean
}
export function buildKolPlatformOptions(defaultLabel: string): KolPlatformOption[] {
return [
export const KOL_PLATFORM_HINT_DEFAULT = '通用'
export function buildKolPlatformOptions(
defaultLabel: string,
platforms: MediaPlatform[] = [],
selectedValues: string[] = [],
): KolPlatformOption[] {
const defaultSelected = selectedValues.includes(KOL_PLATFORM_HINT_DEFAULT)
const options = [
{ label: defaultLabel, value: '通用' },
...aiPlatformCatalog.map((item) => ({ label: item.label, value: item.id })),
...platforms.map((item) => ({
label: item.name,
value: item.name,
disabled: defaultSelected,
})),
]
const knownValues = new Set(options.map((item) => item.value))
const customOptions = normalizeKolPlatformHints(selectedValues)
.filter((value) => !knownValues.has(value))
.map((value) => ({ label: value, value }))
return [...customOptions, ...options]
}
export function parseKolPlatformHints(value?: string | null): string[] {
return normalizeKolPlatformHints(String(value ?? '').split(/[、,;\n]+/))
}
export function normalizeKolPlatformHints(values?: Array<string | null | undefined>): string[] {
const next = Array.from(
new Set((values ?? []).map((item) => String(item ?? '').trim()).filter(Boolean)),
)
if (next.includes(KOL_PLATFORM_HINT_DEFAULT)) {
return [KOL_PLATFORM_HINT_DEFAULT]
}
return next
}
export function serializeKolPlatformHints(values?: Array<string | null | undefined>): string {
return normalizeKolPlatformHints(values).join('、')
}