diff --git a/src/pages/admin.tsx b/src/pages/admin.tsx index 268c3a3..2bc5e10 100644 --- a/src/pages/admin.tsx +++ b/src/pages/admin.tsx @@ -21,10 +21,10 @@ import { verticalListSortingStrategy, } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; +import { Alert, Avatar, Button, Card, Checkbox, Chip, Input, Label, Skeleton, Switch, Table, TextArea, TextField } from '@heroui/react'; import { AlertCircle, AlertTriangle, - Check, CheckCircle, ChevronDown, ChevronUp, @@ -37,61 +37,19 @@ import { User, Users, Video, + X, } from 'lucide-react'; import { GripVertical, Palette } from 'lucide-react'; -import { Alert, Avatar, Button, Card, Checkbox, Chip, Input, Label, Skeleton, Switch, Table, TextArea, TextField } from '@heroui/react'; import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { AdminConfig, AdminConfigResult } from '@/lib/admin.types'; import { getAuthInfoFromBrowserCookie } from '@/lib/auth'; import DataMigration from '@/components/DataMigration'; -import ThemeManager from '@/components/ThemeManager'; import PageLayout from '@/components/PageLayout'; +import ThemeManager from '@/components/ThemeManager'; import { AppDialog, AppFilterSelect } from '@/components/ui/HeroPrimitives'; -// 统一按钮样式系统 -const buttonStyles = { - // 主要操作按钮(蓝色)- 用于配置、设置、确认等 - primary: 'px-3 py-1.5 text-sm font-medium bg-accent hover:bg-accent-strong text-accent-foreground rounded-xl transition-colors', - // 成功操作按钮(绿色)- 用于添加、启用、保存等 - success: 'px-3 py-1.5 text-sm font-medium bg-accent hover:bg-accent-strong text-accent-foreground rounded-xl transition-colors', - // 危险操作按钮(红色)- 用于删除、禁用、重置等 - danger: 'px-3 py-1.5 text-sm font-medium bg-danger hover:bg-danger/90 text-white rounded-xl transition-colors', - // 次要操作按钮(灰色)- 用于取消、关闭等 - secondary: 'px-3 py-1.5 text-sm font-medium bg-surface-secondary hover:bg-surface-tertiary text-foreground border border-border rounded-xl transition-colors', - // 警告操作按钮(黄色)- 用于批量禁用等 - warning: 'px-3 py-1.5 text-sm font-medium bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-600 dark:hover:bg-yellow-700 text-white rounded-lg transition-colors', - // 小尺寸主要按钮 - primarySmall: 'px-2 py-1 text-xs font-medium bg-accent hover:bg-accent-strong text-accent-foreground rounded-lg transition-colors', - // 小尺寸成功按钮 - successSmall: 'px-2 py-1 text-xs font-medium bg-accent hover:bg-accent-strong text-accent-foreground rounded-lg transition-colors', - // 小尺寸危险按钮 - dangerSmall: 'px-2 py-1 text-xs font-medium bg-red-600 hover:bg-red-700 dark:bg-red-600 dark:hover:bg-red-700 text-white rounded-md transition-colors', - // 小尺寸次要按钮 - secondarySmall: 'px-2 py-1 text-xs font-medium bg-surface-secondary hover:bg-surface-tertiary text-foreground border border-border rounded-lg transition-colors', - // 小尺寸警告按钮 - warningSmall: 'px-2 py-1 text-xs font-medium bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-600 dark:hover:bg-yellow-700 text-white rounded-md transition-colors', - // 圆角小按钮(用于表格操作) - roundedPrimary: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-accent/10 text-accent hover:bg-accent/15 transition-colors', - roundedSuccess: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-accent/10 text-accent hover:bg-accent/15 transition-colors', - roundedDanger: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-red-100 text-red-800 hover:bg-red-200 dark:bg-red-900/40 dark:hover:bg-red-900/60 dark:text-red-200 transition-colors', - roundedSecondary: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-surface-secondary text-foreground hover:bg-surface-tertiary transition-colors', - roundedWarning: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 hover:bg-yellow-200 dark:bg-yellow-900/40 dark:hover:bg-yellow-900/60 dark:text-yellow-200 transition-colors', - roundedPurple: 'inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium bg-accent/10 text-accent hover:bg-accent/15 transition-colors', - // 禁用状态 - disabled: 'px-3 py-1.5 text-sm font-medium bg-gray-400 dark:bg-gray-600 cursor-not-allowed text-white rounded-lg transition-colors', - disabledSmall: 'px-2 py-1 text-xs font-medium bg-gray-400 dark:bg-gray-600 cursor-not-allowed text-white rounded-md transition-colors', - // 开关按钮样式 - toggleOn: 'bg-accent', - toggleOff: 'bg-surface-tertiary', - toggleThumb: 'bg-surface', - toggleThumbOn: 'translate-x-6', - toggleThumbOff: 'translate-x-1', - // 快速操作按钮样式 - quickAction: 'px-3 py-1.5 text-xs font-medium text-muted bg-surface border border-border hover:bg-surface-secondary rounded-lg transition-colors', -}; - const AdminTable = ({ ariaLabel, minWidth = 'min-w-[900px]', @@ -545,6 +503,83 @@ interface LiveDataSource { from: 'config' | 'custom'; } +type ValidationResult = { + status: 'valid' | 'invalid' | 'no_results' | 'validating' | null; + message: string; + details?: { + responseTime?: number; + resultCount?: number; + error?: string; + searchKeyword?: string; + }; +}; + +const SourceValidationSummary = ({ result }: { result: ValidationResult }) => { + if (!result.status) return null; + + const statusMeta = { + valid: { + chipColor: 'success' as const, + icon: CheckCircle, + label: '检测通过', + }, + validating: { + chipColor: 'accent' as const, + icon: Settings, + label: '检测中', + }, + no_results: { + chipColor: 'warning' as const, + icon: AlertTriangle, + label: '无搜索结果', + }, + invalid: { + chipColor: 'danger' as const, + icon: AlertCircle, + label: '检测失败', + }, + }[result.status]; + + const StatusIcon = statusMeta.icon; + + return ( +
Key 已用于数据关联,不能编辑。
+Key 已用于直播源关联,不能编辑。
+