diff --git a/backend/app/youtube_manage.py b/backend/app/youtube_manage.py
index 0659b83..5302031 100644
--- a/backend/app/youtube_manage.py
+++ b/backend/app/youtube_manage.py
@@ -106,16 +106,21 @@ def list_managed_channels() -> list[dict[str, Any]]:
rows = db.list_shorts_channels()
out = []
for ch in rows:
+ sn = _snippet_from_channel_row(ch) or {}
out.append(
{
"id": ch.get("id"),
"name": ch.get("name"),
- "youtube_channel_id": ch.get("youtube_channel_id"),
+ "youtube_channel_id": ch.get("youtube_channel_id") or sn.get("youtube_channel_id") or "",
"enabled": bool(ch.get("enabled")),
"authorized": bool(str(ch.get("refresh_token") or "").strip()),
"daily_min": ch.get("daily_min"),
"daily_max": ch.get("daily_max"),
"privacy": ch.get("privacy"),
+ "title": sn.get("title") or ch.get("name"),
+ "custom_url": sn.get("custom_url") or "",
+ "thumb_url": sn.get("thumb_url") or "",
+ "yt_profile": sn or None,
}
)
return out
diff --git a/frontend/src/app/youtube/page.tsx b/frontend/src/app/youtube/page.tsx
index 2a24d03..cf332bf 100644
--- a/frontend/src/app/youtube/page.tsx
+++ b/frontend/src/app/youtube/page.tsx
@@ -24,6 +24,7 @@ import { useConfirm } from "@/components/ConfirmDialog";
import { useToast } from "@/components/Toast";
import { YouTubeLiveBadge } from "@/components/YouTubeLiveBadge";
import { YtAssignPanel } from "@/components/YtAssignPanel";
+import { YtChannelProfileSnippet } from "@/components/YtChannelProfileSnippet";
import { fetchJson, fmtTs } from "@/lib/api";
import { shortsLiveRef } from "@/lib/youtubeLive";
@@ -38,6 +39,10 @@ type ManagedChannel = {
authorized?: boolean;
daily_min?: number;
daily_max?: number;
+ title?: string;
+ thumb_url?: string;
+ custom_url?: string;
+ yt_profile?: any;
};
type YtVideo = {
@@ -315,18 +320,31 @@ export default function YouTubePage() {
) : (
<>
+
+ {channels.map((c) => {
+ const active = c.id === channelPk;
+ return (
+
+ );
+ })}
+
-
{channelPk ?
: null}
);
}
@@ -202,6 +182,26 @@ export function YtAssignPanel({ channels }: { channels: ManagedChannel[] }) {
() => new Set((selected?.featured || []).map((f) => String(f.pool_url_id))),
[selected]
);
+ const channelById = useMemo(() => {
+ const m: Record = {};
+ for (const c of channels) m[c.id] = c;
+ return m;
+ }, [channels]);
+
+ function profileFor(pk: string): YtProfileSnippet | undefined {
+ if (profiles[pk]) return profiles[pk];
+ const ch = channelById[pk];
+ if (ch?.yt_profile) return ch.yt_profile;
+ if (ch?.thumb_url || ch?.title) {
+ return {
+ title: ch.title,
+ thumb_url: ch.thumb_url,
+ custom_url: ch.custom_url,
+ youtube_channel_id: ch.youtube_channel_id,
+ };
+ }
+ return undefined;
+ }
const loadGroups = useCallback(async () => {
setBusy(true);
@@ -566,7 +566,8 @@ export function YtAssignPanel({ channels }: { channels: ManagedChannel[] }) {
{availableChannels.map((c) => (
))}
@@ -619,7 +620,7 @@ export function YtAssignPanel({ channels }: { channels: ManagedChannel[] }) {
}`}
>
>> 0;
+ return { letter, color: AVATAR_COLORS[h % AVATAR_COLORS.length] };
+}
+
+function LetterAvatar({ name }: { name: string }) {
+ const { letter, color } = letterStyle(name);
+ return (
+
+ {letter}
+
+ );
+}
+
+/** Compact card header matching Google 授权页:头像 + YouTube 昵称。 */
export function YtChannelProfileSnippet({
profile,
fallbackName,
@@ -53,27 +84,40 @@ export function YtChannelProfileSnippet({
trailing?: ReactNode;
className?: string;
}) {
- const title = String(profile?.title || fallbackName || "未命名").trim() || "未命名";
+ const ytName = String(profile?.title || "").trim();
+ const localName = String(fallbackName || "").trim();
+ const title = ytName || localName || "未命名";
const handle = handleOf(profile, fallbackChannelId);
const thumb = thumbOf(profile);
const stats = profile?.statistics;
+ const [imgBroken, setImgBroken] = useState(false);
+ const showPhoto = Boolean(thumb) && !imgBroken;
+ const alias = localName && ytName && localName.toLowerCase() !== ytName.toLowerCase() ? localName : "";
return (
-
- {thumb ? (
+
+ {showPhoto ? (
// eslint-disable-next-line @next/next/no-img-element
-

+

setImgBroken(true)}
+ />
) : (
-
+
)}
-
{title}
+
+ {title}
+
{liveChannelPk ?
: null}
{trailing}
- {handle ?
{handle}
: null}
-
+ {handle ?
{handle}
: null}
+ {alias ?
内部备注 {alias}
: null}
+
订阅 {stats?.subscriberCount ?? "—"} · 视频 {stats?.videoCount ?? "—"} · 播放 {stats?.viewCount ?? "—"}