diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index c4e869c..c27b6d5 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -27,6 +27,7 @@ function App() { message: string type: 'success' | 'error' | 'info' } | null>(null) + const [isLoading, setIsLoading] = useState(false) // 加载供应商列表 useEffect(() => { @@ -88,7 +89,10 @@ function App() { title: '切换供应商', message: `确定要切换到"${provider.name}"吗?`, onConfirm: async () => { + setIsLoading(true) const success = await window.electronAPI.switchProvider(id) + setIsLoading(false) + if (success) { setCurrentProviderId(id) setMessageModal({ @@ -160,6 +164,7 @@ function App() { onSwitch={handleSwitchProvider} onDelete={handleDeleteProvider} onEdit={setEditingProviderId} + isLoading={isLoading} /> {configPath && ( diff --git a/src/renderer/components/ProviderList.tsx b/src/renderer/components/ProviderList.tsx index 89e42eb..8413db6 100644 --- a/src/renderer/components/ProviderList.tsx +++ b/src/renderer/components/ProviderList.tsx @@ -8,6 +8,7 @@ interface ProviderListProps { onSwitch: (id: string) => void onDelete: (id: string) => void onEdit: (id: string) => void + isLoading?: boolean } const ProviderList: React.FC = ({ @@ -15,7 +16,8 @@ const ProviderList: React.FC = ({ currentProviderId, onSwitch, onDelete, - onEdit + onEdit, + isLoading = false }) => { return (
@@ -52,20 +54,21 @@ const ProviderList: React.FC = ({