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

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

View File

@@ -77,23 +77,37 @@ function App() {
}
const handleSwitchProvider = async (id: string) => {
const success = await window.electronAPI.switchProvider(id)
if (success) {
setCurrentProviderId(id)
setMessageModal({
show: true,
title: '切换成功',
message: '供应商已成功切换!',
type: 'success'
})
} else {
setMessageModal({
show: true,
title: '切换失败',
message: '切换失败,请检查配置',
type: 'error'
})
}
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)
setMessageModal({
show: true,
title: '切换成功',
message: '供应商已成功切换!',
type: 'success'
})
} else {
setMessageModal({
show: true,
title: '切换失败',
message: '切换失败,请检查配置',
type: 'error'
})
}
setConfirmModal(null)
}
})
}
const handleEditProvider = async (provider: Provider) => {