From dacad1587ad2c92d31247c2a5073926a61e2d6e9 Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Sat, 4 Apr 2026 00:25:18 +0800 Subject: [PATCH] refactor(ui): clean up unused imports and variables in UI components --- src/components/Layout/Sidebar.tsx | 2 +- src/pages/Materials.tsx | 9 ++++----- src/pages/Roles.tsx | 2 +- tsconfig.tsbuildinfo | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 tsconfig.tsbuildinfo diff --git a/src/components/Layout/Sidebar.tsx b/src/components/Layout/Sidebar.tsx index 84f8f74..068fe68 100644 --- a/src/components/Layout/Sidebar.tsx +++ b/src/components/Layout/Sidebar.tsx @@ -103,7 +103,7 @@ const menuItems: MenuItem[] = [ ] export default function Sidebar({ collapsed, onCollapse }: SidebarProps) { - const { hasAnyRole, roles } = useAuthStore() + const { hasAnyRole } = useAuthStore() const [expandedItems, setExpandedItems] = useState(['学习资料']) // 切换展开状态 diff --git a/src/pages/Materials.tsx b/src/pages/Materials.tsx index 720860a..5d55e36 100644 --- a/src/pages/Materials.tsx +++ b/src/pages/Materials.tsx @@ -30,7 +30,7 @@ import { import { PaginationNavigator } from '@/components/ui/pagination' import { Label } from '@/components/ui/label' import { Textarea } from '@/components/ui/textarea' -import { Loader2, Plus, Pencil, Trash2, Search, FileText, Download, Eye } from 'lucide-react' +import { Loader2, Plus, Pencil, Trash2, Search, Download, Eye } from 'lucide-react' import { format } from 'date-fns' // 文件类型配置 @@ -66,7 +66,7 @@ export default function Materials() { // 创建/编辑对话框 const [dialogOpen, setDialogOpen] = useState(false) const [editingMaterial, setEditingMaterial] = useState(null) - const [formData, setFormData] = useState({ + const [formData, setFormData] = useState({ subject_id: '', title: '', description: '', @@ -117,8 +117,7 @@ export default function Materials() { const loadSubjects = useCallback(async () => { try { const response = await subjectsApi.getSubjects() - const data = response.data.data - // 后端返回 { list: [...] } 结构 + const data = response.data.data as MaterialSubject[] | { list: MaterialSubject[] } | undefined const list = Array.isArray(data) ? data : (data?.list || []) setSubjects(list) } catch (error) { @@ -416,7 +415,7 @@ export default function Materials() { {totalPages > 1 && (
diff --git a/src/pages/Roles.tsx b/src/pages/Roles.tsx index 0588079..49626fc 100644 --- a/src/pages/Roles.tsx +++ b/src/pages/Roles.tsx @@ -12,7 +12,7 @@ import { TableHeader, TableRow, } from '@/components/ui/table' -import { RefreshCw, Loader2, Users, Shield, Check } from 'lucide-react' +import { RefreshCw, Loader2, Users, Check } from 'lucide-react' // 角色颜色映射 const roleColors: Record = { diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo new file mode 100644 index 0000000..9403ede --- /dev/null +++ b/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"fileNames":[],"fileInfos":[],"root":[],"version":"5.9.3"} \ No newline at end of file