douyinWEB/frontend/src/components/OauthClientBadge.tsx
eric b752943d22 Group Shorts channels and upcoming uploads by OAuth Client A/B/C/D.
Same-named channels are split into account sections with colored Client badges on cards, schedule rows, and job lists.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 19:43:24 -05:00

58 lines
1.8 KiB
TypeScript

"use client";
/** Distinct A/B/C/D OAuth client tags for same-named YouTube channels. */
const PROFILE_STYLE: Record<string, string> = {
A: "border-sky-400/50 bg-sky-500/25 text-sky-100",
B: "border-violet-400/50 bg-violet-500/25 text-violet-100",
C: "border-amber-400/50 bg-amber-500/25 text-amber-100",
D: "border-rose-400/50 bg-rose-500/25 text-rose-100",
};
export function normalizeOauthProfileId(raw?: string | null): string {
return String(raw || "").trim().toUpperCase();
}
export function OauthClientBadge({
profileId,
label,
size = "md",
className = "",
}: {
profileId?: string | null;
label?: string | null;
size?: "sm" | "md" | "lg";
className?: string;
}) {
const id = normalizeOauthProfileId(profileId);
if (!id) {
return (
<span
className={`inline-flex shrink-0 items-center rounded border border-white/15 bg-white/5 font-semibold tracking-wide text-slate-400 ${
size === "lg" ? "px-2 py-0.5 text-xs" : size === "sm" ? "px-1.5 py-0 text-[10px]" : "px-1.5 py-0.5 text-[10px]"
} ${className}`}
title="未绑定 OAuth 配置档"
>
Client —
</span>
);
}
const style = PROFILE_STYLE[id] || "border-teal-400/40 bg-teal-500/20 text-teal-100";
const sizeCls =
size === "lg" ? "px-2.5 py-1 text-xs" : size === "sm" ? "px-1.5 py-0 text-[10px]" : "px-2 py-0.5 text-[11px]";
return (
<span
className={`inline-flex shrink-0 items-center rounded border font-bold tracking-wide ${style} ${sizeCls} ${className}`}
title={label || `OAuth 配置档 ${id}`}
>
Client {id}
</span>
);
}
export function channelLabelWithProfile(name?: string | null, profileId?: string | null): string {
const n = String(name || "").trim() || "未命名";
const id = normalizeOauthProfileId(profileId);
return id ? `${n} · Client ${id}` : n;
}