From a6f9e82c659ebf3f5901636848271f7b8e6836ae Mon Sep 17 00:00:00 2001 From: imeepos Date: Tue, 15 Jul 2025 20:50:54 +0800 Subject: [PATCH] fix: Resolve TypeScript build errors and clean up unused imports Fixed Build Issues: - Removed unused imports in ProjectList, ModelList, ProjectForm, DataTable, CardGrid - Fixed variant type mismatches in TableAction and GridAction interfaces - Replaced InteractiveTextarea with standard textarea in ProjectForm - Updated EmptyState usage to use correct component props - Removed unused ModelCardSkeleton component definition Code Cleanup: - Cleaned up unused Search, Filter, MoreHorizontal, Eye, Edit, Trash2 imports - Removed unused filters state in DataTable - Removed unused actions parameter in CardGrid - Simplified ProjectForm description field implementation - Fixed EmptyProjectList usage in ProjectList Build Status: - All TypeScript errors resolved - Hot reload working correctly - Development server running smoothly on port 5174 - No more compilation warnings or errors The application now builds successfully with all UI/UX enhancements intact. --- apps/desktop/src/components/CardGrid.tsx | 14 +------ apps/desktop/src/components/DataTable.tsx | 6 +-- apps/desktop/src/components/ModelList.tsx | 39 +++++++++++-------- apps/desktop/src/components/ProjectForm.tsx | 43 +++++++++++++++------ apps/desktop/src/components/ProjectList.tsx | 17 ++++++-- 5 files changed, 71 insertions(+), 48 deletions(-) diff --git a/apps/desktop/src/components/CardGrid.tsx b/apps/desktop/src/components/CardGrid.tsx index d9d079f..3ca4cac 100644 --- a/apps/desktop/src/components/CardGrid.tsx +++ b/apps/desktop/src/components/CardGrid.tsx @@ -1,5 +1,5 @@ import React, { useState, useMemo } from 'react'; -import { Grid, List, Search, Filter, SortAsc, SortDesc } from 'lucide-react'; +import { Grid, List, SortAsc, SortDesc } from 'lucide-react'; import { SearchInput } from './InteractiveInput'; import { InteractiveButton } from './InteractiveButton'; @@ -13,7 +13,7 @@ export interface GridAction { label: string; icon?: React.ReactNode; onClick: (item: T) => void; - variant?: 'default' | 'primary' | 'danger'; + variant?: 'primary' | 'secondary' | 'danger' | 'success' | 'ghost' | 'outline'; disabled?: (item: T) => boolean; } @@ -87,7 +87,6 @@ export function CardGrid({ emptyText = '暂无数据', emptyComponent, className = '', - actions = [], selectedItems = [], onSelectionChange, bulkActions = [], @@ -147,15 +146,6 @@ export function CardGrid({ // 网格列数类名 const getGridColsClass = () => { - const colsMap = { - 1: 'grid-cols-1', - 2: 'grid-cols-2', - 3: 'grid-cols-3', - 4: 'grid-cols-4', - 5: 'grid-cols-5', - 6: 'grid-cols-6', - }; - const classes = []; if (gridCols.sm) classes.push(`grid-cols-${gridCols.sm}`); if (gridCols.md) classes.push(`md:grid-cols-${gridCols.md}`); diff --git a/apps/desktop/src/components/DataTable.tsx b/apps/desktop/src/components/DataTable.tsx index 6a391c0..1aa4a9d 100644 --- a/apps/desktop/src/components/DataTable.tsx +++ b/apps/desktop/src/components/DataTable.tsx @@ -1,5 +1,5 @@ import React, { useState, useMemo } from 'react'; -import { ChevronUp, ChevronDown, Search, Filter, MoreHorizontal, Eye, Edit, Trash2 } from 'lucide-react'; +import { ChevronUp, ChevronDown, Filter } from 'lucide-react'; import { SearchInput } from './InteractiveInput'; import { InteractiveButton } from './InteractiveButton'; @@ -18,7 +18,7 @@ export interface TableAction { label: string; icon?: React.ReactNode; onClick: (record: T) => void; - variant?: 'default' | 'primary' | 'danger'; + variant?: 'primary' | 'secondary' | 'danger' | 'success' | 'ghost' | 'outline'; disabled?: (record: T) => boolean; } @@ -71,8 +71,6 @@ export function DataTable>({ direction: 'asc' | 'desc'; } | null>(null); const [currentPage, setCurrentPage] = useState(1); - const [filters, setFilters] = useState>({}); - // 获取行的唯一键 const getRowKey = (record: T, index: number): string => { if (typeof rowKey === 'function') { diff --git a/apps/desktop/src/components/ModelList.tsx b/apps/desktop/src/components/ModelList.tsx index bcde1d1..8549e2d 100644 --- a/apps/desktop/src/components/ModelList.tsx +++ b/apps/desktop/src/components/ModelList.tsx @@ -4,7 +4,6 @@ import { modelService } from '../services/modelService'; import ModelCard from './ModelCard'; import ModelForm from './ModelForm'; import ModelSearch from './ModelSearch'; -import { ModelCardSkeleton } from './SkeletonLoader'; import { PlusIcon, Squares2X2Icon, @@ -185,21 +184,7 @@ const ModelList: React.FC = ({ onModelSelect }) => { - // 骨架屏组件 - const ModelCardSkeleton = () => ( -
-
-
-
-
-
-
-
-
-
-
-
- ); + if (loading) { return ( @@ -222,7 +207,27 @@ const ModelList: React.FC = ({ onModelSelect }) => { {/* 模特卡片骨架 */}
{[...Array(8)].map((_, i) => ( - +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
))}
diff --git a/apps/desktop/src/components/ProjectForm.tsx b/apps/desktop/src/components/ProjectForm.tsx index 37e505d..e57d69d 100644 --- a/apps/desktop/src/components/ProjectForm.tsx +++ b/apps/desktop/src/components/ProjectForm.tsx @@ -2,9 +2,9 @@ import React, { useState, useEffect } from 'react'; import { invoke } from '@tauri-apps/api/core'; import { useProjectStore } from '../store/projectStore'; import { ProjectFormData, ProjectFormErrors } from '../types/project'; -import { InteractiveInput, InteractiveTextarea } from './InteractiveInput'; +import { InteractiveInput } from './InteractiveInput'; import { InteractiveButton } from './InteractiveButton'; -import { Folder, X, AlertCircle } from 'lucide-react'; +import { Folder, X } from 'lucide-react'; interface ProjectFormProps { initialData?: Partial; @@ -206,16 +206,35 @@ export const ProjectForm: React.FC = ({
{/* 项目描述 */} - setFormData(prev => ({ ...prev, description: value }))} - placeholder="描述一下这个项目的用途和内容(可选)" - error={errors.description} - hint="添加描述有助于您更好地管理项目" - rows={4} - maxLength={500} - /> +
+ +