Selaa lähdekoodia

🗑️ chore(admin-shadcn): 移除admin-shadcn相关组件和页面

- 删除MinioUploader上传组件及相关依赖
- 移除MainLayout主布局组件和菜单配置
- 删除FilesPage文件管理页面
- 删除UsersPage用户管理页面
- 移除相关路由配置和类型定义
yourname 3 kuukautta sitten
vanhempi
sitoutus
6f04892e2b

+ 0 - 484
src/client/admin-shadcn/components/MinioUploader.tsx

@@ -1,484 +0,0 @@
-import React, { useState, useCallback } from 'react';
-import { Button } from '@/client/components/ui/button';
-import { Card, CardContent } from '@/client/components/ui/card';
-import { Progress } from '@/client/components/ui/progress';
-import { Badge } from '@/client/components/ui/badge';
-import { toast } from 'sonner';
-import { Upload, X, CheckCircle, Loader2, FileText } from 'lucide-react';
-import { uploadMinIOWithPolicy, MinioProgressEvent } from '@/client/utils/minio';
-
-interface MinioUploaderProps {
-  /** 上传路径 */
-  uploadPath: string;
-  /** 允许的文件类型,如['image/*', '.pdf'] */
-  accept?: string;
-  /** 最大文件大小(MB) */
-  maxSize?: number;
-  /** 是否允许多文件上传 */
-  multiple?: boolean;
-  /** 上传成功回调 */
-  onUploadSuccess?: (fileKey: string, fileUrl: string, file: File) => void;
-  /** 上传失败回调 */
-  onUploadError?: (error: Error, file: File) => void;
-  /** 自定义上传按钮文本 */
-  buttonText?: string;
-  /** 自定义提示文本 */
-  tipText?: string;
-  /** 上传模式:拖放模式或传统模式 */
-  uploadMode?: 'dragdrop' | 'traditional';
-  /** 是否显示已上传文件列表 */
-  showUploadList?: boolean;
-  /** 已上传文件列表标题 */
-  uploadListTitle?: string;
-  /** 组件尺寸模式 */
-  size?: 'default' | 'compact' | 'minimal';
-  /** 显示模式:卡片模式或完整模式 */
-  displayMode?: 'full' | 'card';
-}
-
-// 定义上传文件状态
-interface UploadFile {
-  uid: string;
-  name: string;
-  size: number;
-  type?: string;
-  status: 'uploading' | 'success' | 'error';
-  percent: number;
-  error?: string;
-  url?: string;
-}
-
-const MinioUploader: React.FC<MinioUploaderProps> = ({
-  uploadPath = '/',
-  accept,
-  maxSize = 500, // 默认最大500MB
-  multiple = false,
-  onUploadSuccess,
-  onUploadError,
-  buttonText = '点击或拖拽上传文件',
-  tipText = '支持单文件或多文件上传,单个文件大小不超过500MB',
-  uploadMode = 'dragdrop',
-  showUploadList = true,
-  uploadListTitle = '上传进度',
-  size = 'default',
-  displayMode = 'full'
-}) => {
-  const [fileList, setFileList] = useState<UploadFile[]>([]);
-  const [uploadingFiles, setUploadingFiles] = useState<Set<string>>(new Set());
-  const [dragActive, setDragActive] = useState(false);
-
-  // 根据尺寸模式获取样式配置
-  const getSizeConfig = () => {
-    switch (size) {
-      case 'minimal':
-        return {
-          container: 'p-3',
-          icon: 'h-8 w-8',
-          title: 'text-sm',
-          description: 'text-xs',
-          button: 'h-8 px-3 text-xs',
-          spacing: 'space-y-2',
-          fileList: 'space-y-2',
-          cardPadding: 'p-3',
-          progressHeight: 'h-1'
-        };
-      case 'compact':
-        return {
-          container: 'p-4',
-          icon: 'h-10 w-10',
-          title: 'text-base',
-          description: 'text-sm',
-          button: 'h-9 px-4 text-sm',
-          spacing: 'space-y-3',
-          fileList: 'space-y-3',
-          cardPadding: 'p-4',
-          progressHeight: 'h-2'
-        };
-      default:
-        return {
-          container: 'p-6',
-          icon: 'h-12 w-12',
-          title: 'text-lg',
-          description: 'text-sm',
-          button: 'h-10 px-4',
-          spacing: 'space-y-4',
-          fileList: 'space-y-4',
-          cardPadding: 'p-6',
-          progressHeight: 'h-2'
-        };
-    }
-  };
-
-  // 处理上传进度
-  const handleProgress = useCallback((uid: string, event: MinioProgressEvent) => {
-    setFileList(prev => 
-      prev.map(item => {
-        if (item.uid === uid) {
-          return {
-            ...item,
-            status: event.stage === 'error' ? 'error' : 'uploading',
-            percent: event.progress,
-            error: event.stage === 'error' ? event.message : undefined
-          };
-        }
-        return item;
-      })
-    );
-  }, []);
-
-  // 处理上传成功
-  const handleComplete = useCallback((uid: string, result: { fileKey: string; fileUrl: string }, file: File) => {
-    setFileList(prev => 
-      prev.map(item => {
-        if (item.uid === uid) {
-          return {
-            ...item,
-            status: 'success',
-            percent: 100,
-            url: result.fileUrl,
-          };
-        }
-        return item;
-      })
-    );
-    
-    setUploadingFiles(prev => {
-      const newSet = new Set(prev);
-      newSet.delete(uid);
-      return newSet;
-    });
-    
-    // toast.success(`文件 "${file.name}" 上传成功`);
-    onUploadSuccess?.(result.fileKey, result.fileUrl, file);
-  }, [onUploadSuccess]);
-
-  // 处理上传失败
-  const handleError = useCallback((uid: string, error: Error, file: File) => {
-    setFileList(prev => 
-      prev.map(item => {
-        if (item.uid === uid) {
-          return {
-            ...item,
-            status: 'error',
-            percent: 0,
-            error: error.message || '上传失败'
-          };
-        }
-        return item;
-      })
-    );
-    
-    setUploadingFiles(prev => {
-      const newSet = new Set(prev);
-      newSet.delete(uid);
-      return newSet;
-    });
-    
-    // toast.error(`文件 "${file.name}" 上传失败: ${error.message}`);
-    onUploadError?.(error, file);
-  }, [onUploadError]);
-
-  // 自定义上传逻辑
-  const handleUpload = async (file: File) => {
-    const uid = Date.now().toString() + Math.random().toString(36).substr(2, 9);
-    
-    // 添加到文件列表
-    setFileList(prev => [
-      ...prev,
-      {
-        uid,
-        name: file.name,
-        size: file.size,
-        type: file.type,
-        status: 'uploading',
-        percent: 0,
-      }
-    ]);
-    
-    // 添加到上传中集合
-    setUploadingFiles(prev => new Set(prev).add(uid));
-    
-    try {
-      // 验证文件大小
-      const fileSizeMB = file.size / (1024 * 1024);
-      if (fileSizeMB > maxSize) {
-        throw new Error(`文件大小超过 ${maxSize}MB 限制`);
-      }
-      
-      // 调用minio上传方法
-      const result = await uploadMinIOWithPolicy(
-        uploadPath,
-        file,
-        file.name,
-        {
-          onProgress: (event) => handleProgress(uid, event),
-          signal: new AbortController().signal
-        }
-      );
-      
-      handleComplete(uid, result, file);
-    } catch (error) {
-      handleError(uid, error instanceof Error ? error : new Error('未知错误'), file);
-    }
-  };
-
-  // 处理文件选择
-  const handleFileSelect = (files: FileList) => {
-    if (!files || files.length === 0) return;
-
-    const fileArray = Array.from(files);
-    
-    if (!multiple && fileArray.length > 1) {
-      toast.error('不支持多文件上传');
-      return;
-    }
-
-    fileArray.forEach(file => handleUpload(file));
-  };
-
-  // 处理拖拽
-  const handleDrag = (e: React.DragEvent) => {
-    e.preventDefault();
-    e.stopPropagation();
-    
-    if (e.type === 'dragenter' || e.type === 'dragover') {
-      setDragActive(true);
-    } else if (e.type === 'dragleave') {
-      setDragActive(false);
-    }
-  };
-
-  const handleDrop = (e: React.DragEvent) => {
-    e.preventDefault();
-    e.stopPropagation();
-    setDragActive(false);
-    
-    const files = e.dataTransfer.files;
-    handleFileSelect(files);
-  };
-
-  // 处理文件移除
-  const handleRemove = (uid: string) => {
-    setFileList(prev => prev.filter(item => item.uid !== uid));
-  };
-
-  // 渲染上传状态
-  const renderUploadStatus = (item: UploadFile) => {
-    switch (item.status) {
-      case 'uploading':
-        return (
-          <div className="flex items-center gap-2">
-            <Loader2 className="h-4 w-4 animate-spin" />
-            <span className="text-sm">{Math.round(item.percent)}%</span>
-          </div>
-        );
-      case 'success':
-        return (
-          <div className="flex items-center gap-2">
-            <CheckCircle className="h-4 w-4 text-green-500" />
-            <Badge variant="outline" className="bg-green-50 text-green-700 border-green-200">
-              上传成功
-            </Badge>
-          </div>
-        );
-      case 'error':
-        return (
-          <div className="flex items-center gap-2">
-            <div className="h-4 w-4 text-red-500">×</div>
-            <Badge variant="outline" className="bg-red-50 text-red-700 border-red-200">
-              {item.error || '上传失败'}
-            </Badge>
-          </div>
-        );
-      default:
-        return null;
-    }
-  };
-
-  // 渲染文件图标
-  const renderFileIcon = (type?: string, iconSize: 'small' | 'normal' = 'normal') => {
-    const sizeClass = iconSize === 'small' ? 'h-4 w-4' : 'h-8 w-8';
-    
-    if (type?.startsWith('image/')) {
-      return <FileText className={`${sizeClass} text-blue-500`} />;
-    } else if (type?.startsWith('video/')) {
-      return <FileText className={`${sizeClass} text-red-500`} />;
-    } else if (type?.startsWith('audio/')) {
-      return <FileText className={`${sizeClass} text-purple-500`} />;
-    } else if (type?.includes('pdf')) {
-      return <FileText className={`${sizeClass} text-red-500`} />;
-    } else if (type?.includes('word')) {
-      return <FileText className={`${sizeClass} text-blue-600`} />;
-    } else if (type?.includes('excel') || type?.includes('sheet')) {
-      return <FileText className={`${sizeClass} text-green-500`} />;
-    } else {
-      return <FileText className={`${sizeClass} text-gray-500`} />;
-    }
-  };
-
-  const sizeConfig = getSizeConfig();
-
-  // 卡片模式渲染
-  if (displayMode === 'card') {
-    return (
-      <div className="h-full flex items-center justify-center">
-        <button
-          type="button"
-          className={`flex flex-col items-center justify-center w-full h-full text-muted-foreground hover:text-primary transition-colors cursor-pointer
-            ${size === 'minimal' ? 'text-xs' : 'text-sm'}`}
-          onClick={() => {
-            const input = document.createElement('input');
-            input.type = 'file';
-            input.accept = accept || '';
-            input.multiple = multiple;
-            input.onchange = (e) => {
-              const files = (e.target as HTMLInputElement).files;
-              if (files) handleFileSelect(files);
-            };
-            input.click();
-          }}
-        >
-          <Upload className={`${size === 'minimal' ? 'h-6 w-6 mb-1' : 'h-8 w-8 mb-2'}`} />
-          <span>{buttonText}</span>
-        </button>
-      </div>
-    );
-  }
-
-  return (
-    <div className={sizeConfig.spacing}>
-      {/* 上传区域 - 根据模式显示不同界面 */}
-      {uploadMode === 'dragdrop' ? (
-        <div
-          className={`relative border-2 border-dashed rounded-lg transition-all ${
-            dragActive
-              ? 'border-primary bg-primary/5'
-              : 'border-gray-300 hover:border-primary/50'
-          } ${sizeConfig.container}`}
-          onDragEnter={handleDrag}
-          onDragLeave={handleDrag}
-          onDragOver={handleDrag}
-          onDrop={handleDrop}
-        >
-          <div className={`flex flex-col items-center justify-center ${sizeConfig.spacing}`}>
-            <Upload className={`${sizeConfig.icon} ${dragActive ? 'text-primary' : 'text-gray-400'}`} />
-            <div className="text-center">
-              <p className={`${sizeConfig.title} font-medium`}>{buttonText}</p>
-              {size !== 'minimal' && (
-                <p className={`${sizeConfig.description} text-gray-500 mt-1`}>{tipText}</p>
-              )}
-            </div>
-            <Button
-              type="button"
-              variant="outline"
-              size={size === 'minimal' ? 'sm' : size === 'compact' ? 'sm' : 'default'}
-              onClick={() => {
-                const input = document.createElement('input');
-                input.type = 'file';
-                input.accept = accept || '';
-                input.multiple = multiple;
-                input.onchange = (e) => {
-                  const files = (e.target as HTMLInputElement).files;
-                  if (files) handleFileSelect(files);
-                };
-                input.click();
-              }}
-            >
-              <Upload className="h-4 w-4 mr-2" />
-              选择文件
-            </Button>
-          </div>
-        </div>
-      ) : (
-        <Card>
-          <CardContent className={sizeConfig.cardPadding}>
-            <div className={`flex flex-col items-center justify-center ${sizeConfig.spacing}`}>
-              <Upload className={`${sizeConfig.icon} text-gray-400`} />
-              <div className="text-center">
-                <p className={`${sizeConfig.title} font-medium`}>{buttonText}</p>
-                {size !== 'minimal' && (
-                  <p className={`${sizeConfig.description} text-gray-500 mt-1`}>{tipText}</p>
-                )}
-              </div>
-              <Button
-                type="button"
-                variant="outline"
-                size={size === 'minimal' ? 'sm' : size === 'compact' ? 'sm' : 'default'}
-                onClick={() => {
-                  const input = document.createElement('input');
-                  input.type = 'file';
-                  input.accept = accept || '';
-                  input.multiple = multiple;
-                  input.onchange = (e) => {
-                    const files = (e.target as HTMLInputElement).files;
-                    if (files) handleFileSelect(files);
-                  };
-                  input.click();
-                }}
-              >
-                <Upload className="h-4 w-4 mr-2" />
-                选择文件
-              </Button>
-            </div>
-          </CardContent>
-        </Card>
-      )}
-
-      {/* 上传进度列表 */}
-      {showUploadList && fileList.length > 0 && (
-        <Card>
-          <CardContent className={sizeConfig.cardPadding}>
-            <h3 className={`${sizeConfig.title} font-semibold mb-3`}>{uploadListTitle}</h3>
-            <div className={sizeConfig.fileList}>
-              {fileList.map(item => (
-                <div key={item.uid} className={`flex items-center space-x-3 p-3 border rounded-lg ${size === 'minimal' ? 'text-sm' : ''}`}>
-                  <div className="flex-shrink-0">
-                    {renderFileIcon(item.type, size === 'minimal' ? 'small' : 'normal')}
-                  </div>
-                  <div className="flex-1 min-w-0">
-                    <div className="flex justify-between items-center mb-1">
-                      <p className={`${size === 'minimal' ? 'text-xs' : 'text-sm'} font-medium truncate`}>{item.name}</p>
-                      <div className="flex items-center space-x-1">
-                        {renderUploadStatus(item)}
-                        <Button
-                          variant="ghost"
-                          size={size === 'minimal' ? 'icon' : 'sm'}
-                          onClick={() => handleRemove(item.uid)}
-                          disabled={item.status === 'uploading'}
-                          className={size === 'minimal' ? 'h-6 w-6' : ''}
-                        >
-                          <X className={size === 'minimal' ? 'h-3 w-3' : 'h-4 w-4'} />
-                        </Button>
-                      </div>
-                    </div>
-                    {item.status === 'uploading' && (
-                      <div className="space-y-1">
-                        <Progress value={item.percent} className={sizeConfig.progressHeight} />
-                        {size !== 'minimal' && (
-                          <p className={`${sizeConfig.description} text-gray-500`}>
-                            {Math.round(item.percent)}% - {formatFileSize(item.size * (item.percent / 100))} / {formatFileSize(item.size)}
-                          </p>
-                        )}
-                      </div>
-                    )}
-                  </div>
-                </div>
-              ))}
-            </div>
-          </CardContent>
-        </Card>
-      )}
-    </div>
-  );
-};
-
-// 辅助函数:格式化文件大小
-const formatFileSize = (bytes: number): string => {
-  if (bytes === 0) return '0 Bytes';
-  const k = 1024;
-  const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
-  const i = Math.floor(Math.log(bytes) / Math.log(k));
-  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
-};
-
-export default MinioUploader;

+ 0 - 256
src/client/admin-shadcn/layouts/MainLayout.tsx

@@ -1,256 +0,0 @@
-import { useState, useEffect, useMemo } from 'react';
-import {
-  Outlet,
-  useLocation,
-} from 'react-router';
-import {
-  Bell,
-  Menu,
-  User,
-  ChevronDown
-} from 'lucide-react';
-import { useAuth } from '../hooks/AuthProvider';
-import { useMenu, type MenuItem } from '../menu';
-import { getGlobalConfig } from '@/client/utils/utils';
-import { Button } from '@/client/components/ui/button';
-import { Input } from '@/client/components/ui/input';
-import { Avatar, AvatarFallback, AvatarImage } from '@/client/components/ui/avatar';
-import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/client/components/ui/dropdown-menu';
-import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/client/components/ui/sheet';
-import { ScrollArea } from '@/client/components/ui/scroll-area';
-import { cn } from '@/client/lib/utils';
-import { Badge } from '@/client/components/ui/badge';
-/**
- * 主布局组件
- * 包含侧边栏、顶部导航和内容区域
- */
-export const MainLayout = () => {
-  const { user } = useAuth();
-  const [showBackTop, setShowBackTop] = useState(false);
-  const location = useLocation();
-  const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
-  
-  // 使用菜单hook
-  const {
-    menuItems,
-    userMenuItems,
-    collapsed,
-    setCollapsed,
-    handleMenuClick
-  } = useMenu();
-  
-  // 获取当前选中的菜单项
-  const selectedKey = useMemo(() => {
-    const findSelectedKey = (items: MenuItem[]): string | null => {
-      for (const item of items) {
-        if (!item) continue;
-        if (item.path === location.pathname) return item.key || null;
-        if (item.children) {
-          const childKey = findSelectedKey(item.children);
-          if (childKey) return childKey;
-        }
-      }
-      return null;
-    };
-    
-    return findSelectedKey(menuItems) || '';
-  }, [location.pathname, menuItems]);
-  
-  // 检测滚动位置,控制回到顶部按钮显示
-  useEffect(() => {
-    const handleScroll = () => {
-      setShowBackTop(window.pageYOffset > 300);
-    };
-    
-    window.addEventListener('scroll', handleScroll);
-    return () => window.removeEventListener('scroll', handleScroll);
-  }, []);
-  
-  // 回到顶部
-  const scrollToTop = () => {
-    window.scrollTo({
-      top: 0,
-      behavior: 'smooth'
-    });
-  };
-
-  // 应用名称 - 从CONFIG中获取或使用默认值
-  const appName = getGlobalConfig('APP_NAME') || '应用Starter';
-  
-
-  // 侧边栏内容
-  const SidebarContent = () => (
-    <div className="flex h-full flex-col">
-      <div className="p-4 border-b">
-        <h2 className="text-lg font-semibold truncate">
-          {collapsed ? '应用' : appName}
-        </h2>
-        {!collapsed && (
-          <div className="mt-4">
-            <Input
-              placeholder="搜索菜单..."
-              className="h-8"
-            />
-          </div>
-        )}
-      </div>
-      
-      <ScrollArea className="flex-1">
-        <nav className="p-2">
-          {menuItems.map((item) => (
-            <div key={item.key}>
-              <Button
-                variant={selectedKey === item.key ? "default" : "ghost"}
-                className={cn(
-                  "w-full justify-start mb-1",
-                  selectedKey === item.key && "bg-primary text-primary-foreground"
-                )}
-                onClick={() => {
-                  handleMenuClick(item);
-                  setIsMobileMenuOpen(false);
-                }}
-              >
-                {item.icon}
-                {!collapsed && <span className="ml-2">{item.label}</span>}
-              </Button>
-              
-              {item.children && !collapsed && (
-                <div className="ml-4">
-                  {item.children.map((child) => (
-                    <Button
-                      key={child.key}
-                      variant={selectedKey === child.key ? "default" : "ghost"}
-                      className={cn(
-                        "w-full justify-start mb-1 text-sm",
-                        selectedKey === child.key && "bg-primary text-primary-foreground"
-                      )}
-                      onClick={() => {
-                        handleMenuClick(child);
-                        setIsMobileMenuOpen(false);
-                      }}
-                    >
-                      {child.icon && <span className="ml-2">{child.icon}</span>}
-                      <span className={child.icon ? "ml-2" : "ml-6"}>{child.label}</span>
-                    </Button>
-                  ))}
-                </div>
-              )}
-            </div>
-          ))}
-        </nav>
-      </ScrollArea>
-    </div>
-  );
-
-  return (
-    <div className="flex h-screen bg-background">
-      {/* Desktop Sidebar */}
-      <aside className={cn(
-        "hidden md:block border-r bg-background transition-all duration-200",
-        collapsed ? "w-16" : "w-64"
-      )}>
-        <SidebarContent />
-      </aside>
-
-      {/* Mobile Sidebar */}
-      <Sheet open={isMobileMenuOpen} onOpenChange={setIsMobileMenuOpen}>
-        <SheetContent side="left" className="w-64 p-0">
-          <SheetHeader className="p-4">
-            <SheetTitle>{appName}</SheetTitle>
-          </SheetHeader>
-          <SidebarContent />
-        </SheetContent>
-      </Sheet>
-
-      <div className="flex-1 flex flex-col overflow-hidden">
-        {/* Header */}
-        <header className="flex h-16 items-center justify-between border-b bg-background px-4">
-          <div className="flex items-center gap-2">
-            <Button
-              variant="ghost"
-              size="icon"
-              className="md:hidden"
-              onClick={() => setIsMobileMenuOpen(true)}
-            >
-              <Menu className="h-4 w-4" />
-            </Button>
-            <Button
-              variant="ghost"
-              size="icon"
-              className="hidden md:block"
-              onClick={() => setCollapsed(!collapsed)}
-            >
-              <Menu className="h-4 w-4" />
-            </Button>
-          </div>
-
-          <div className="flex items-center gap-4">
-            <Button variant="ghost" size="icon" className="relative">
-              <Bell className="h-4 w-4" />
-              <Badge className="absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center text-xs">
-                5
-              </Badge>
-            </Button>
-
-            <DropdownMenu>
-              <DropdownMenuTrigger asChild>
-                <Button variant="ghost" className="relative h-8 w-8 rounded-full">
-                  <Avatar className="h-8 w-8">
-                    <AvatarImage
-                      src={user?.avatarFile?.fullUrl || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?q=80&w=40&auto=format&fit=crop'}
-                      alt={user?.username || 'User'}
-                    />
-                    <AvatarFallback>
-                      <User className="h-4 w-4" />
-                    </AvatarFallback>
-                  </Avatar>
-                </Button>
-              </DropdownMenuTrigger>
-              <DropdownMenuContent className="w-56" align="end" forceMount>
-                <DropdownMenuLabel className="font-normal">
-                  <div className="flex flex-col space-y-1">
-                    <p className="text-sm font-medium leading-none">
-                      {user?.nickname || user?.username}
-                    </p>
-                    <p className="text-xs leading-none text-muted-foreground">
-                      {user?.email}
-                    </p>
-                  </div>
-                </DropdownMenuLabel>
-                <DropdownMenuSeparator />
-                {userMenuItems.map((item) => (
-                  item.type === 'separator' ? (
-                    <DropdownMenuSeparator key={item.key} />
-                  ) : (
-                    <DropdownMenuItem key={item.key} onClick={item.onClick}>
-                      {item.icon && item.icon}
-                      <span>{item.label}</span>
-                    </DropdownMenuItem>
-                  )
-                ))}
-              </DropdownMenuContent>
-            </DropdownMenu>
-          </div>
-        </header>
-
-        {/* Main Content */}
-        <main className="flex-1 overflow-auto p-4">
-          <div className="max-w-7xl mx-auto">
-            <Outlet />
-          </div>
-          
-          {/* Back to top button */}
-          {showBackTop && (
-            <Button
-              size="icon"
-              className="fixed bottom-4 right-4 rounded-full shadow-lg"
-              onClick={scrollToTop}
-            >
-              <ChevronDown className="h-4 w-4 rotate-180" />
-            </Button>
-          )}
-        </main>
-      </div>
-    </div>
-  );
-};

+ 0 - 156
src/client/admin-shadcn/menu.tsx

@@ -1,156 +0,0 @@
-import React from 'react';
-import { useNavigate } from 'react-router';
-import { useAuth } from './hooks/AuthProvider';
-import {
-  Users,
-  Settings,
-  User,
-  LogOut,
-  BarChart3,
-  LayoutDashboard,
-  File
-} from 'lucide-react';
-
-export interface MenuItem {
-  key: string;
-  label: string;
-  icon?: React.ReactNode;
-  children?: MenuItem[];
-  path?: string;
-  permission?: string;
-  onClick?: () => void;
-}
-
-/**
- * 菜单搜索 Hook
- * 封装菜单搜索相关逻辑
- */
-export const useMenuSearch = (menuItems: MenuItem[]) => {
-  const [searchText, setSearchText] = React.useState('');
-
-  // 过滤菜单项
-  const filteredMenuItems = React.useMemo(() => {
-    if (!searchText) return menuItems;
-    
-    const filterItems = (items: MenuItem[]): MenuItem[] => {
-      return items
-        .map(item => {
-          // 克隆对象避免修改原数据
-          const newItem = { ...item };
-          if (newItem.children) {
-            newItem.children = filterItems(newItem.children);
-          }
-          return newItem;
-        })
-        .filter(item => {
-          // 保留匹配项或其子项匹配的项
-          const match = item.label.toLowerCase().includes(searchText.toLowerCase());
-          if (match) return true;
-          if (item.children?.length) return true;
-          return false;
-        });
-    };
-    
-    return filterItems(menuItems);
-  }, [menuItems, searchText]);
-
-  // 清除搜索
-  const clearSearch = () => {
-    setSearchText('');
-  };
-
-  return {
-    searchText,
-    setSearchText,
-    filteredMenuItems,
-    clearSearch
-  };
-};
-
-export const useMenu = () => {
-  const navigate = useNavigate();
-  const { logout: handleLogout } = useAuth();
-  const [collapsed, setCollapsed] = React.useState(false);
-
-  // 基础菜单项配置
-  const menuItems: MenuItem[] = [
-    {
-      key: 'dashboard',
-      label: '控制台',
-      icon: <LayoutDashboard className="h-4 w-4" />,
-      path: '/admin/dashboard'
-    },
-    {
-      key: 'users',
-      label: '用户管理',
-      icon: <Users className="h-4 w-4" />,
-      path: '/admin/users',
-      permission: 'user:manage'
-    },
-    {
-      key: 'files',
-      label: '文件管理',
-      icon: <File  className="h-4 w-4" />,
-      path: '/admin/files',
-      permission: 'file:manage'
-    },
-    {
-      key: 'analytics',
-      label: '数据分析',
-      icon: <BarChart3 className="h-4 w-4" />,
-      path: '/admin/analytics',
-      permission: 'analytics:view'
-    },
-    {
-      key: 'settings',
-      label: '系统设置',
-      icon: <Settings className="h-4 w-4" />,
-      path: '/admin/settings',
-      permission: 'settings:manage'
-    },
-  ];
-
-  // 用户菜单项
-  const userMenuItems = [
-    {
-      key: 'profile',
-      label: '个人资料',
-      icon: <User className="mr-2 h-4 w-4" />,
-      onClick: () => navigate('/admin/profile')
-    },
-    {
-      key: 'settings',
-      label: '账户设置',
-      icon: <Settings className="mr-2 h-4 w-4" />,
-      onClick: () => navigate('/admin/account-settings')
-    },
-    {
-      type: 'separator',
-      key: 'divider',
-    },
-    {
-      key: 'logout',
-      label: '退出登录',
-      icon: <LogOut className="mr-2 h-4 w-4" />,
-      onClick: () => handleLogout()
-    }
-  ];
-
-  // 处理菜单点击
-  const handleMenuClick = (item: MenuItem) => {
-    if (item.path) {
-      navigate(item.path);
-    }
-    if (item.onClick) {
-      item.onClick();
-    }
-  };
-
-  return {
-    menuItems,
-    userMenuItems,
-    collapsed,
-    setCollapsed,
-    handleMenuClick,
-  };
-};

+ 0 - 468
src/client/admin-shadcn/pages/Files.tsx

@@ -1,468 +0,0 @@
-import React, { useState } from 'react';
-import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
-import { Button } from '@/client/components/ui/button';
-import { Input } from '@/client/components/ui/input';
-import { Card, CardContent, CardHeader, CardTitle } from '@/client/components/ui/card';
-import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/client/components/ui/dialog';
-import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/client/components/ui/form';
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/client/components/ui/table';
-import { Badge } from '@/client/components/ui/badge';
-import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/client/components/ui/alert-dialog';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { toast } from 'sonner';
-import { Eye, Download, Edit, Trash2, Search, FileText, Upload } from 'lucide-react';
-import { fileClient } from '@/client/api';
-import type { InferResponseType, InferRequestType } from 'hono/client';
-import dayjs from 'dayjs';
-import MinioUploader from '@/client/admin-shadcn/components/MinioUploader';
-import { UpdateFileDto } from '@/server/modules/files/file.schema';
-import * as z from 'zod';
-
-// 定义类型
-type FileItem = InferResponseType<typeof fileClient.$get, 200>['data'][0];
-type FileListResponse = InferResponseType<typeof fileClient.$get, 200>;
-type UpdateFileRequest = InferRequestType<typeof fileClient[':id']['$put']>['json'];
-type FileFormData = z.infer<typeof UpdateFileDto>;
-
-export const FilesPage: React.FC = () => {
-  const [isModalOpen, setIsModalOpen] = useState(false);
-  const [isUploadModalOpen, setIsUploadModalOpen] = useState(false);
-  const [editingFile, setEditingFile] = useState<FileItem | null>(null);
-  const [searchText, setSearchText] = useState('');
-  const [pagination, setPagination] = useState({
-    current: 1,
-    pageSize: 10,
-    total: 0,
-  });
-  const [deleteFileId, setDeleteFileId] = useState<number | null>(null);
-  const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
-
-  const queryClient = useQueryClient();
-  
-  // 表单初始化
-  const form = useForm<FileFormData>({
-    resolver: zodResolver(UpdateFileDto),
-    defaultValues: {
-      name: '',
-      description: '',
-    },
-  });
-
-  // 获取文件列表数据
-  const fetchFiles = async ({ page, pageSize }: { page: number; pageSize: number }): Promise<FileListResponse> => {
-    const response = await fileClient.$get({ query: { page, pageSize, keyword: searchText } });
-    if (!response.ok) throw new Error('Failed to fetch files');
-    return await response.json() as FileListResponse;
-  };
-
-  const { data, isLoading, error } = useQuery({
-    queryKey: ['files', pagination.current, pagination.pageSize, searchText],
-    queryFn: () => fetchFiles({ page: pagination.current, pageSize: pagination.pageSize }),
-  });
-
-  // 更新文件记录
-  const updateFile = useMutation({
-    mutationFn: ({ id, data }: { id: number; data: UpdateFileRequest }) =>
-      fileClient[':id'].$put({ param: { id: id.toString() }, json: data }),
-    onSuccess: () => {
-      toast.success('文件记录更新成功');
-      queryClient.invalidateQueries({ queryKey: ['files'] });
-      setIsModalOpen(false);
-      setEditingFile(null);
-    },
-    onError: (error: Error) => {
-      toast.error(`操作失败: ${error.message}`);
-    }
-  });
-
-  // 删除文件记录
-  const deleteFile = useMutation({
-    mutationFn: (id: number) => fileClient[':id'].$delete({ param: { id: id.toString() } }),
-    onSuccess: () => {
-      toast.success('文件记录删除成功');
-      queryClient.invalidateQueries({ queryKey: ['files'] });
-    },
-    onError: (error: Error) => {
-      toast.error(`删除失败: ${error.message}`);
-    }
-  });
-
-  // 处理文件下载
-  const handleDownload = (record: FileItem) => {
-    const a = document.createElement('a');
-    a.href = record.fullUrl;
-    a.download = record.name;
-    document.body.appendChild(a);
-    a.click();
-    document.body.removeChild(a);
-  };
-
-  // 处理文件预览
-  const handlePreview = (record: FileItem) => {
-    if (isPreviewable(record.type)) {
-      window.open(record.fullUrl, '_blank');
-    } else {
-      toast.warning('该文件类型不支持预览');
-    }
-  };
-
-  // 检查是否为可预览的文件类型
-  const isPreviewable = (fileType: string | null) => {
-    if (!fileType) return false;
-    return fileType.startsWith('image/') || fileType.startsWith('video/');
-  };
-
-  // 处理上传成功回调
-  const handleUploadSuccess = (fileKey: string, fileUrl: string, file: File) => {
-    toast.success('文件上传成功');
-    queryClient.invalidateQueries({ queryKey: ['files'] });
-  };
-
-  // 处理上传失败回调
-  const handleUploadError = (error: Error, file: File) => {
-    toast.error(`上传失败: ${error instanceof Error ? error.message : '未知错误'}`);
-  };
-
-  // 显示编辑弹窗
-  const showEditModal = (record: FileItem) => {
-    setEditingFile(record);
-    setIsModalOpen(true);
-    form.reset({
-      name: record.name,
-      description: record.description || '',
-    });
-  };
-
-  // 处理表单提交
-  const handleFormSubmit = async (data: FileFormData) => {
-    if (editingFile) {
-      await updateFile.mutateAsync({ 
-        id: editingFile.id, 
-        data: {
-          name: data.name,
-          description: data.description,
-        }
-      });
-    }
-  };
-
-  // 处理删除确认
-  const handleDeleteConfirm = () => {
-    if (deleteFileId) {
-      deleteFile.mutate(deleteFileId);
-      setIsDeleteDialogOpen(false);
-      setDeleteFileId(null);
-    }
-  };
-
-  const handleSearch = () => {
-    setPagination({ ...pagination, current: 1 });
-  };
-
-  // 格式化文件大小
-  const formatFileSize = (bytes: number | null) => {
-    if (!bytes || bytes === 0) return '0 Bytes';
-    const k = 1024;
-    const sizes = ['Bytes', 'KB', 'MB', 'GB'];
-    const i = Math.floor(Math.log(bytes) / Math.log(k));
-    return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
-  };
-
-  // 分页数据
-  const tablePagination = data?.pagination || pagination;
-
-  if (error) {
-    return (
-      <div className="p-6">
-        <Card>
-          <CardContent className="text-center py-8">
-            <FileText className="h-12 w-12 mx-auto text-gray-400 mb-4" />
-            <p className="text-gray-600">获取文件列表失败</p>
-          </CardContent>
-        </Card>
-      </div>
-    );
-  }
-
-  return (
-    <div className="p-6 space-y-6">
-      <div className="flex justify-between items-center">
-        <h1 className="text-3xl font-bold">文件管理</h1>
-        <Button onClick={() => setIsUploadModalOpen(true)}>
-          <Upload className="h-4 w-4 mr-2" />
-          上传文件
-        </Button>
-      </div>
-      
-      <Card>
-        <CardHeader>
-          <CardTitle>文件列表</CardTitle>
-        </CardHeader>
-        <CardContent>
-          <div className="mb-4 flex gap-4">
-            <div className="flex-1">
-              <Input
-                placeholder="搜索文件名称或类型"
-                value={searchText}
-                onChange={(e) => setSearchText(e.target.value)}
-                onKeyPress={(e) => e.key === 'Enter' && handleSearch()}
-                className="max-w-sm"
-              />
-            </div>
-            <Button onClick={handleSearch}>
-              <Search className="h-4 w-4 mr-2" />
-              搜索
-            </Button>
-          </div>
-
-          <div className="overflow-x-auto">
-            <Table>
-              <TableHeader>
-                <TableRow>
-                  <TableHead className="w-16">ID</TableHead>
-                  <TableHead>预览</TableHead>
-                  <TableHead>文件名称</TableHead>
-                  <TableHead>文件类型</TableHead>
-                  <TableHead>文件大小</TableHead>
-                  <TableHead>上传时间</TableHead>
-                  <TableHead>上传用户</TableHead>
-                  <TableHead className="text-right">操作</TableHead>
-                </TableRow>
-              </TableHeader>
-              <TableBody>
-                {isLoading ? (
-                  <TableRow>
-                    <TableCell colSpan={7} className="text-center">
-                      <div className="flex justify-center items-center py-8">
-                        <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
-                      </div>
-                    </TableCell>
-                  </TableRow>
-                ) : data?.data?.length === 0 ? (
-                  <TableRow>
-                    <TableCell colSpan={7} className="text-center py-8">
-                      <FileText className="h-12 w-12 mx-auto text-gray-400 mb-4" />
-                      <p className="text-gray-600">暂无文件</p>
-                    </TableCell>
-                  </TableRow>
-                ) : (
-                  data?.data?.map((file) => (
-                    <TableRow key={file.id}>
-                      <TableCell className="font-medium">{file.id}</TableCell>
-                      <TableCell>
-                        {isPreviewable(file.type) ? (
-                          <img
-                            src={file.fullUrl}
-                            alt={file.name}
-                            className="w-12 h-12 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
-                            onClick={() => handlePreview(file)}
-                            title="点击查看大图"
-                          />
-                        ) : (
-                          <div className="w-12 h-12 flex items-center justify-center bg-gray-100 rounded border">
-                            <FileText className="h-6 w-6 text-gray-400" />
-                          </div>
-                        )}
-                      </TableCell>
-                      <TableCell>
-                        <div className="max-w-xs truncate" title={file.name}>
-                          {file.name}
-                        </div>
-                      </TableCell>
-                      <TableCell>
-                        <Badge variant="secondary">{file.type}</Badge>
-                      </TableCell>
-                      <TableCell>{formatFileSize(file.size)}</TableCell>
-                      <TableCell>
-                        {file.uploadTime ? dayjs(file.uploadTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
-                      </TableCell>
-                      <TableCell>
-                        {file.uploadUser ? (file.uploadUser.nickname || file.uploadUser.username) : '-'}
-                      </TableCell>
-                      <TableCell className="text-right">
-                        <div className="flex justify-end gap-2">
-                          <Button
-                            variant="ghost"
-                            size="sm"
-                            onClick={() => handlePreview(file)}
-                            disabled={!isPreviewable(file.type)}
-                            title={isPreviewable(file.type) ? '预览文件' : '该文件类型不支持预览'}
-                          >
-                            <Eye className="h-4 w-4" />
-                          </Button>
-                          <Button
-                            variant="ghost"
-                            size="sm"
-                            onClick={() => handleDownload(file)}
-                            title="下载文件"
-                          >
-                            <Download className="h-4 w-4" />
-                          </Button>
-                          <Button
-                            variant="ghost"
-                            size="sm"
-                            onClick={() => showEditModal(file)}
-                            title="编辑文件信息"
-                          >
-                            <Edit className="h-4 w-4" />
-                          </Button>
-                          <Button
-                            variant="ghost"
-                            size="sm"
-                            onClick={() => {
-                              setDeleteFileId(file.id);
-                              setIsDeleteDialogOpen(true);
-                            }}
-                            className="text-red-600 hover:text-red-700"
-                            title="删除文件"
-                          >
-                            <Trash2 className="h-4 w-4" />
-                          </Button>
-                        </div>
-                      </TableCell>
-                    </TableRow>
-                  ))
-                )}
-              </TableBody>
-            </Table>
-          </div>
-
-          {/* 分页 */}
-          {tablePagination.total > 0 && (
-            <div className="flex justify-between items-center mt-4">
-              <div className="text-sm text-gray-600">
-                显示 {((tablePagination.current - 1) * tablePagination.pageSize + 1)}-
-                {Math.min(tablePagination.current * tablePagination.pageSize, tablePagination.total)} 条,
-                共 {tablePagination.total} 条
-              </div>
-              <div className="flex gap-2">
-                <Button
-                  variant="outline"
-                  size="sm"
-                  disabled={tablePagination.current <= 1}
-                  onClick={() => setPagination({ ...pagination, current: tablePagination.current - 1 })}
-                >
-                  上一页
-                </Button>
-                <span className="px-3 py-1 text-sm">
-                  第 {tablePagination.current} 页
-                </span>
-                <Button
-                  variant="outline"
-                  size="sm"
-                  disabled={tablePagination.current >= Math.ceil(tablePagination.total / tablePagination.pageSize)}
-                  onClick={() => setPagination({ ...pagination, current: tablePagination.current + 1 })}
-                >
-                  下一页
-                </Button>
-              </div>
-            </div>
-          )}
-        </CardContent>
-      </Card>
-
-      {/* 上传文件对话框 */}
-      <Dialog open={isUploadModalOpen} onOpenChange={setIsUploadModalOpen}>
-        <DialogContent className="sm:max-w-[600px]">
-          <DialogHeader>
-            <DialogTitle>上传文件</DialogTitle>
-            <DialogDescription>
-              选择要上传的文件,支持拖拽上传
-            </DialogDescription>
-          </DialogHeader>
-          
-          <div className="py-4">
-            <MinioUploader
-              uploadPath="/files"
-              maxSize={500}
-              multiple={false}
-              onUploadSuccess={(fileKey, fileUrl, file) => {
-                handleUploadSuccess(fileKey, fileUrl, file);
-                setIsUploadModalOpen(false);
-              }}
-              onUploadError={handleUploadError}
-              buttonText="点击或拖拽上传文件"
-              tipText="支持单文件上传,单个文件大小不超过500MB"
-              size="default"
-            />
-          </div>
-          
-          <DialogFooter>
-            <Button variant="outline" onClick={() => setIsUploadModalOpen(false)}>
-              取消
-            </Button>
-          </DialogFooter>
-        </DialogContent>
-      </Dialog>
-
-      {/* 编辑对话框 */}
-      <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>
-        <DialogContent className="sm:max-w-[500px]">
-          <DialogHeader>
-            <DialogTitle>编辑文件信息</DialogTitle>
-            <DialogDescription>
-              修改文件的基本信息
-            </DialogDescription>
-          </DialogHeader>
-          <Form {...form}>
-            <form onSubmit={form.handleSubmit(handleFormSubmit)} className="space-y-4">
-              <FormField
-                control={form.control}
-                name="name"
-                render={({ field }) => (
-                  <FormItem>
-                    <FormLabel>文件名称</FormLabel>
-                    <FormControl>
-                      <Input placeholder="请输入文件名称" {...field} />
-                    </FormControl>
-                    <FormMessage />
-                  </FormItem>
-                )}
-              />
-              <FormField
-                control={form.control}
-                name="description"
-                render={({ field }) => (
-                  <FormItem>
-                    <FormLabel>文件描述</FormLabel>
-                    <FormControl>
-                      <Input placeholder="请输入文件描述" {...field} />
-                    </FormControl>
-                    <FormMessage />
-                  </FormItem>
-                )}
-              />
-              <DialogFooter>
-                <Button type="button" variant="outline" onClick={() => setIsModalOpen(false)}>
-                  取消
-                </Button>
-                <Button type="submit" disabled={updateFile.isPending}>
-                  {updateFile.isPending ? '保存中...' : '保存'}
-                </Button>
-              </DialogFooter>
-            </form>
-          </Form>
-        </DialogContent>
-      </Dialog>
-
-      {/* 删除确认对话框 */}
-      <AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
-        <AlertDialogContent>
-          <AlertDialogHeader>
-            <AlertDialogTitle>确认删除</AlertDialogTitle>
-            <AlertDialogDescription>
-              确定要删除这个文件记录吗?此操作不可恢复。
-            </AlertDialogDescription>
-          </AlertDialogHeader>
-          <AlertDialogFooter>
-            <AlertDialogCancel>取消</AlertDialogCancel>
-            <AlertDialogAction onClick={handleDeleteConfirm} className="bg-red-600 hover:bg-red-700">
-              确认删除
-            </AlertDialogAction>
-          </AlertDialogFooter>
-        </AlertDialogContent>
-      </AlertDialog>
-    </div>
-  );
-};

+ 0 - 686
src/client/admin-shadcn/pages/Users.tsx

@@ -1,686 +0,0 @@
-import React, { useState } from 'react';
-import { useQuery } from '@tanstack/react-query';
-import { format } from 'date-fns';
-import { Plus, Search, Edit, Trash2 } from 'lucide-react';
-import { userClient } from '@/client/api';
-import type { InferRequestType, InferResponseType } from 'hono/client';
-import { Button } from '@/client/components/ui/button';
-import { Input } from '@/client/components/ui/input';
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/client/components/ui/card';
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/client/components/ui/table';
-import { Badge } from '@/client/components/ui/badge';
-import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/client/components/ui/dialog';
-import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/client/components/ui/form';
-import { DataTablePagination } from '@/client/admin-shadcn/components/DataTablePagination';
-import AvatarSelector from '@/client/admin-shadcn/components/AvatarSelector';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { toast } from 'sonner';
-import { Skeleton } from '@/client/components/ui/skeleton';
-import { Switch } from '@/client/components/ui/switch';
-import { DisabledStatus } from '@/share/types';
-import { CreateUserDto, UpdateUserDto } from '@/server/modules/users/user.schema';
-
-// 使用RPC方式提取类型
-type CreateUserRequest = InferRequestType<typeof userClient.$post>['json'];
-type UpdateUserRequest = InferRequestType<typeof userClient[':id']['$put']>['json'];
-type UserResponse = InferResponseType<typeof userClient.$get, 200>['data'][0];
-
-// 直接使用后端定义的 schema
-const createUserFormSchema = CreateUserDto;
-const updateUserFormSchema = UpdateUserDto;
-
-type CreateUserFormData = CreateUserRequest;
-type UpdateUserFormData = UpdateUserRequest;
-
-export const UsersPage = () => {
-  const [searchParams, setSearchParams] = useState({
-    page: 1,
-    limit: 10,
-    search: ''
-  });
-  const [isModalOpen, setIsModalOpen] = useState(false);
-  const [editingUser, setEditingUser] = useState<any>(null);
-  const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
-  const [userToDelete, setUserToDelete] = useState<number | null>(null);
-  // Avatar selector is now integrated, no separate state needed
-
-  const [isCreateForm, setIsCreateForm] = useState(true);
-  
-  const createForm = useForm<CreateUserFormData>({
-    resolver: zodResolver(createUserFormSchema),
-    defaultValues: {
-      username: '',
-      nickname: undefined,
-      email: null,
-      phone: null,
-      name: null,
-      password: '',
-      isDisabled: DisabledStatus.ENABLED,
-    },
-  });
-
-  const updateForm = useForm<UpdateUserFormData>({
-    resolver: zodResolver(updateUserFormSchema),
-    defaultValues: {
-      username: undefined,
-      nickname: undefined,
-      email: null,
-      phone: null,
-      name: null,
-      password: undefined,
-      isDisabled: undefined,
-    },
-  });
-
-  const { data: usersData, isLoading, refetch } = useQuery({
-    queryKey: ['users', searchParams],
-    queryFn: async () => {
-      const res = await userClient.$get({
-        query: {
-          page: searchParams.page,
-          pageSize: searchParams.limit,
-          keyword: searchParams.search
-        }
-      });
-      if (res.status !== 200) {
-        throw new Error('获取用户列表失败');
-      }
-      return await res.json();
-    }
-  });
-
-  const users = usersData?.data || [];
-  const totalCount = usersData?.pagination?.total || 0;
-
-  // 处理搜索
-  const handleSearch = (e: React.FormEvent) => {
-    e.preventDefault();
-    setSearchParams(prev => ({ ...prev, page: 1 }));
-  };
-
-  // 处理分页
-  const handlePageChange = (page: number, limit: number) => {
-    setSearchParams(prev => ({ ...prev, page, limit }));
-  };
-
-  // 打开创建用户对话框
-  const handleCreateUser = () => {
-    setEditingUser(null);
-    setIsCreateForm(true);
-    createForm.reset({
-      username: '',
-      nickname: null,
-      email: null,
-      phone: null,
-      name: null,
-      password: '',
-      isDisabled: DisabledStatus.ENABLED,
-    });
-    setIsModalOpen(true);
-  };
-
-  // 打开编辑用户对话框
-  const handleEditUser = (user: UserResponse) => {
-    setEditingUser(user);
-    setIsCreateForm(false);
-    updateForm.reset({
-      username: user.username,
-      nickname: user.nickname,
-      email: user.email,
-      phone: user.phone,
-      name: user.name,
-      avatarFileId: user.avatarFileId,
-      isDisabled: user.isDisabled,
-    });
-    setIsModalOpen(true);
-  };
-
-  // 处理创建表单提交
-  const handleCreateSubmit = async (data: CreateUserFormData) => {
-    try {
-      const res = await userClient.$post({
-        json: data
-      });
-      if (res.status !== 201) {
-        throw new Error('创建用户失败');
-      }
-      toast.success('用户创建成功');
-      setIsModalOpen(false);
-      refetch();
-    } catch (error) {
-      console.error('创建用户失败:', error);
-      toast.error('创建失败,请重试');
-    }
-  };
-
-  // 处理更新表单提交
-  const handleUpdateSubmit = async (data: UpdateUserFormData) => {
-    if (!editingUser) return;
-    
-    try {
-      const res = await userClient[':id']['$put']({
-        param: { id: editingUser.id },
-        json: data
-      });
-      if (res.status !== 200) {
-        throw new Error('更新用户失败');
-      }
-      toast.success('用户更新成功');
-      setIsModalOpen(false);
-      refetch();
-    } catch (error) {
-      console.error('更新用户失败:', error);
-      toast.error('更新失败,请重试');
-    }
-  };
-
-  // 处理删除用户
-  const handleDeleteUser = (id: number) => {
-    setUserToDelete(id);
-    setDeleteDialogOpen(true);
-  };
-
-  const confirmDelete = async () => {
-    if (!userToDelete) return;
-    
-    try {
-      const res = await userClient[':id']['$delete']({
-        param: { id: userToDelete }
-      });
-      if (res.status !== 204) {
-        throw new Error('删除用户失败');
-      }
-      toast.success('用户删除成功');
-      refetch();
-    } catch (error) {
-      console.error('删除用户失败:', error);
-      toast.error('删除失败,请重试');
-    } finally {
-      setDeleteDialogOpen(false);
-      setUserToDelete(null);
-    }
-  };
-
-  // 渲染加载骨架
-  if (isLoading) {
-    return (
-      <div className="space-y-4">
-        <div className="flex justify-between items-center">
-          <h1 className="text-2xl font-bold">用户管理</h1>
-          <Button disabled>
-            <Plus className="mr-2 h-4 w-4" />
-            创建用户
-          </Button>
-        </div>
-        
-        <Card>
-          <CardHeader>
-            <Skeleton className="h-6 w-1/4" />
-          </CardHeader>
-          <CardContent>
-            <div className="space-y-2">
-              <Skeleton className="h-4 w-full" />
-              <Skeleton className="h-4 w-full" />
-              <Skeleton className="h-4 w-full" />
-            </div>
-          </CardContent>
-        </Card>
-      </div>
-    );
-  }
-
-  return (
-    <div className="space-y-4">
-      <div className="flex justify-between items-center">
-        <h1 className="text-2xl font-bold">用户管理</h1>
-        <Button onClick={handleCreateUser}>
-          <Plus className="mr-2 h-4 w-4" />
-          创建用户
-        </Button>
-      </div>
-
-      <Card>
-        <CardHeader>
-          <CardTitle>用户列表</CardTitle>
-          <CardDescription>
-            管理系统中的所有用户,共 {totalCount} 位用户
-          </CardDescription>
-        </CardHeader>
-        <CardContent>
-          <div className="mb-4">
-            <form onSubmit={handleSearch} className="flex gap-2">
-              <div className="relative flex-1 max-w-sm">
-                <Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
-                <Input
-                  placeholder="搜索用户名、昵称或邮箱..."
-                  value={searchParams.search}
-                  onChange={(e) => setSearchParams(prev => ({ ...prev, search: e.target.value }))}
-                  className="pl-8"
-                />
-              </div>
-              <Button type="submit" variant="outline">
-                搜索
-              </Button>
-            </form>
-          </div>
-
-          <div className="rounded-md border">
-            <Table>
-              <TableHeader>
-                <TableRow>
-                  <TableHead>头像</TableHead>
-                  <TableHead>用户名</TableHead>
-                  <TableHead>昵称</TableHead>
-                  <TableHead>邮箱</TableHead>
-                  <TableHead>真实姓名</TableHead>
-                  <TableHead>角色</TableHead>
-                  <TableHead>状态</TableHead>
-                  <TableHead>创建时间</TableHead>
-                  <TableHead className="text-right">操作</TableHead>
-                </TableRow>
-              </TableHeader>
-              <TableBody>
-                {users.map((user) => (
-                  <TableRow key={user.id}>
-                    <TableCell>
-                      <div className="w-10 h-10">
-                        {user.avatarFile?.fullUrl ? (
-                          <img
-                            src={user.avatarFile.fullUrl}
-                            alt={user.username}
-                            className="w-10 h-10 rounded-full object-cover"
-                          />
-                        ) : (
-                          <div className="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center">
-                            <span className="text-sm font-medium text-gray-500">
-                              {user.username?.charAt(0)?.toUpperCase() || 'U'}
-                            </span>
-                          </div>
-                        )}
-                      </div>
-                    </TableCell>
-                    <TableCell className="font-medium">{user.username}</TableCell>
-                    <TableCell>{user.nickname || '-'}</TableCell>
-                    <TableCell>{user.email || '-'}</TableCell>
-                    <TableCell>{user.name || '-'}</TableCell>
-                    <TableCell>
-                      <Badge
-                        variant={user.roles?.some((role: any) => role.name === 'admin') ? 'destructive' : 'default'}
-                        className="capitalize"
-                      >
-                        {user.roles?.some((role: any) => role.name === 'admin') ? '管理员' : '普通用户'}
-                      </Badge>
-                    </TableCell>
-                    <TableCell>
-                      <Badge
-                        variant={user.isDisabled === 1 ? 'secondary' : 'default'}
-                      >
-                        {user.isDisabled === 1 ? '禁用' : '启用'}
-                      </Badge>
-                    </TableCell>
-                    <TableCell>
-                      {format(new Date(user.createdAt), 'yyyy-MM-dd HH:mm')}
-                    </TableCell>
-                    <TableCell className="text-right">
-                      <div className="flex justify-end gap-2">
-                        <Button
-                          variant="ghost"
-                          size="icon"
-                          onClick={() => handleEditUser(user)}
-                        >
-                          <Edit className="h-4 w-4" />
-                        </Button>
-                        <Button
-                          variant="ghost"
-                          size="icon"
-                          onClick={() => handleDeleteUser(user.id)}
-                        >
-                          <Trash2 className="h-4 w-4" />
-                        </Button>
-                      </div>
-                    </TableCell>
-                  </TableRow>
-                ))}
-              </TableBody>
-            </Table>
-          </div>
-
-          <DataTablePagination
-            currentPage={searchParams.page}
-            totalCount={totalCount}
-            pageSize={searchParams.limit}
-            onPageChange={handlePageChange}
-          />
-        </CardContent>
-      </Card>
-
-      {/* 创建/编辑用户对话框 */}
-      <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>
-        <DialogContent className="sm:max-w-[500px] max-h-[90vh] overflow-y-auto">
-          <DialogHeader>
-            <DialogTitle>
-              {editingUser ? '编辑用户' : '创建用户'}
-            </DialogTitle>
-            <DialogDescription>
-              {editingUser ? '编辑现有用户信息' : '创建一个新的用户账户'}
-            </DialogDescription>
-          </DialogHeader>
-          
-          {isCreateForm ? (
-            <Form {...createForm}>
-              <form onSubmit={createForm.handleSubmit(handleCreateSubmit)} className="space-y-4">
-                <FormField
-                  control={createForm.control}
-                  name="username"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel className="flex items-center">
-                        用户名
-                        <span className="text-red-500 ml-1">*</span>
-                      </FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入用户名" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="nickname"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>昵称</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入昵称" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="email"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>邮箱</FormLabel>
-                      <FormControl>
-                        <Input type="email" placeholder="请输入邮箱" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="phone"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>手机号</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入手机号" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="name"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>真实姓名</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入真实姓名" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="password"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel className="flex items-center">
-                        密码
-                        <span className="text-red-500 ml-1">*</span>
-                      </FormLabel>
-                      <FormControl>
-                        <Input type="password" placeholder="请输入密码" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="avatarFileId"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>头像</FormLabel>
-                      <FormControl>
-                        <AvatarSelector
-                          value={field.value || undefined}
-                          onChange={(value) => field.onChange(value)}
-                          maxSize={2}
-                          uploadPath="/avatars"
-                          uploadButtonText="上传头像"
-                          previewSize="medium"
-                          placeholder="选择头像"
-                        />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={createForm.control}
-                  name="isDisabled"
-                  render={({ field }) => (
-                    <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
-                      <div className="space-y-0.5">
-                        <FormLabel className="text-base">用户状态</FormLabel>
-                        <FormDescription>
-                          禁用后用户将无法登录系统
-                        </FormDescription>
-                      </div>
-                      <FormControl>
-                        <Switch
-                          checked={field.value === 1}
-                          onCheckedChange={(checked) => field.onChange(checked ? 1 : 0)}
-                        />
-                      </FormControl>
-                    </FormItem>
-                  )}
-                />
-
-                <DialogFooter>
-                  <Button type="button" variant="outline" onClick={() => setIsModalOpen(false)}>
-                    取消
-                  </Button>
-                  <Button type="submit">
-                    创建用户
-                  </Button>
-                </DialogFooter>
-              </form>
-            </Form>
-          ) : (
-            <Form {...updateForm}>
-              <form onSubmit={updateForm.handleSubmit(handleUpdateSubmit)} className="space-y-4">
-                <FormField
-                  control={updateForm.control}
-                  name="username"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel className="flex items-center">
-                        用户名
-                        <span className="text-red-500 ml-1">*</span>
-                      </FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入用户名" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="nickname"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>昵称</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入昵称" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="email"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>邮箱</FormLabel>
-                      <FormControl>
-                        <Input type="email" placeholder="请输入邮箱" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="phone"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>手机号</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入手机号" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="name"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>真实姓名</FormLabel>
-                      <FormControl>
-                        <Input placeholder="请输入真实姓名" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="password"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>新密码</FormLabel>
-                      <FormControl>
-                        <Input type="password" placeholder="留空则不修改密码" {...field} />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="avatarFileId"
-                  render={({ field }) => (
-                    <FormItem>
-                      <FormLabel>头像</FormLabel>
-                      <FormControl>
-                        <AvatarSelector
-                          value={field.value || undefined}
-                          onChange={(value) => field.onChange(value)}
-                          maxSize={2}
-                          uploadPath="/avatars"
-                          uploadButtonText="上传头像"
-                          previewSize="medium"
-                          placeholder="选择头像"
-                        />
-                      </FormControl>
-                      <FormMessage />
-                    </FormItem>
-                  )}
-                />
-
-                <FormField
-                  control={updateForm.control}
-                  name="isDisabled"
-                  render={({ field }) => (
-                    <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
-                      <div className="space-y-0.5">
-                        <FormLabel className="text-base">用户状态</FormLabel>
-                        <FormDescription>
-                          禁用后用户将无法登录系统
-                        </FormDescription>
-                      </div>
-                      <FormControl>
-                        <Switch
-                          checked={field.value === 1}
-                          onCheckedChange={(checked) => field.onChange(checked ? 1 : 0)}
-                        />
-                      </FormControl>
-                    </FormItem>
-                  )}
-                />
-
-                <DialogFooter>
-                  <Button type="button" variant="outline" onClick={() => setIsModalOpen(false)}>
-                    取消
-                  </Button>
-                  <Button type="submit">
-                    更新用户
-                  </Button>
-                </DialogFooter>
-              </form>
-            </Form>
-          )}
-        </DialogContent>
-      </Dialog>
-
-      {/* Avatar selector is now integrated within the form */}
-
-      {/* 删除确认对话框 */}
-      <Dialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
-        <DialogContent>
-          <DialogHeader>
-            <DialogTitle>确认删除</DialogTitle>
-            <DialogDescription>
-              确定要删除这个用户吗?此操作无法撤销。
-            </DialogDescription>
-          </DialogHeader>
-          <DialogFooter>
-            <Button variant="outline" onClick={() => setDeleteDialogOpen(false)}>
-              取消
-            </Button>
-            <Button variant="destructive" onClick={confirmDelete}>
-              删除
-            </Button>
-          </DialogFooter>
-        </DialogContent>
-      </Dialog>
-    </div>
-  );
-};

+ 0 - 60
src/client/admin-shadcn/routes.tsx

@@ -1,60 +0,0 @@
-import React from 'react';
-import { createBrowserRouter, Navigate } from 'react-router';
-import { ProtectedRoute } from './components/ProtectedRoute';
-import { MainLayout } from './layouts/MainLayout';
-import { ErrorPage } from './components/ErrorPage';
-import { NotFoundPage } from './components/NotFoundPage';
-import { DashboardPage } from './pages/Dashboard';
-import { UsersPage } from './pages/Users';
-import { LoginPage } from './pages/Login';
-import { FilesPage } from './pages/Files';
-
-export const router = createBrowserRouter([
-  {
-    path: '/',
-    element: <Navigate to="/admin" replace />
-  },
-  {
-    path: '/admin/login',
-    element: <LoginPage />
-  },
-  {
-    path: '/admin',
-    element: (
-      <ProtectedRoute>
-        <MainLayout />
-      </ProtectedRoute>
-    ),
-    children: [
-      {
-        index: true,
-        element: <Navigate to="/admin/dashboard" />
-      },
-      {
-        path: 'dashboard',
-        element: <DashboardPage />,
-        errorElement: <ErrorPage />
-      },
-      {
-        path: 'users',
-        element: <UsersPage />,
-        errorElement: <ErrorPage />
-      },
-      {
-        path: 'files',
-        element: <FilesPage />,
-        errorElement: <ErrorPage />
-      },
-      {
-        path: '*',
-        element: <NotFoundPage />,
-        errorElement: <ErrorPage />
-      },
-    ],
-  },
-  {
-    path: '*',
-    element: <NotFoundPage />,
-    errorElement: <ErrorPage />
-  },
-]);