import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { App, Button, Skeleton, Switch } from "antd"; import { AlertTriangle, Clapperboard, Coins, ListChecks, LockKeyhole, MonitorCog, PlugZap, RadioTower, RefreshCw, ShieldCheck, Sparkles } from "lucide-react"; import { cn } from "@/lib/utils"; import { getAdminFeatureAvailability, updateAdminFeatureAvailability } from "@/services/api/auth"; import { useUserStore, type FeatureAvailability } from "@/stores/use-user-store"; import { useAdminContext } from "../admin-context"; import { AdminStatusBadge } from "./admin-ui"; type FeatureKey = "shortDramaEnabled" | "taskCenterEnabled" | "creditsEnabled" | "customChannelsEnabled" | "frontendModelsEnabled" | "pluginCenterEnabled" | "systemPluginsVisibleToUsers"; type FeatureSelectionKey = FeatureKey | "desktopLocalChannelsEnabled"; type FeatureRow = { key: FeatureKey; title: string; eyebrow: string; description: string; enabledImpact: string; disabledImpact: string; icon: ReactNode; dependsOn?: FeatureKey; }; const editableFeatureKeys: FeatureKey[] = ["shortDramaEnabled", "taskCenterEnabled", "creditsEnabled", "customChannelsEnabled", "frontendModelsEnabled", "pluginCenterEnabled", "systemPluginsVisibleToUsers"]; const workspaceFeatureRows: FeatureRow[] = [ { key: "shortDramaEnabled", title: "短剧创作", eyebrow: "项目与短剧入口", description: "控制短剧入口、项目列表、项目详情和项目接口。关闭不会删除已有项目数据。", enabledImpact: "普通用户可以继续进入短剧与项目工作区。", disabledImpact: "隐藏短剧入口并拦截项目列表、详情和项目接口,已有数据保留。", icon: