添加切换供应商的确认对话框

- 切换供应商前显示确认对话框
- 防止误操作导致的意外切换
- 提升用户操作安全性
This commit is contained in:
farion1231
2025-08-06 07:45:54 +08:00
parent 779e24ee49
commit 558103171e

View File

@@ -77,6 +77,17 @@ function App() {
}
const handleSwitchProvider = async (id: string) => {
const provider = providers[id]
if (!provider) return
// 如果是当前供应商,直接返回
if (id === currentProviderId) return
setConfirmModal({
show: true,
title: '切换供应商',
message: `确定要切换到"${provider.name}"吗?`,
onConfirm: async () => {
const success = await window.electronAPI.switchProvider(id)
if (success) {
setCurrentProviderId(id)
@@ -94,6 +105,9 @@ function App() {
type: 'error'
})
}
setConfirmModal(null)
}
})
}
const handleEditProvider = async (provider: Provider) => {