添加切换供应商的确认对话框
- 切换供应商前显示确认对话框 - 防止误操作导致的意外切换 - 提升用户操作安全性
This commit is contained in:
@@ -77,6 +77,17 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSwitchProvider = async (id: string) => {
|
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)
|
const success = await window.electronAPI.switchProvider(id)
|
||||||
if (success) {
|
if (success) {
|
||||||
setCurrentProviderId(id)
|
setCurrentProviderId(id)
|
||||||
@@ -94,6 +105,9 @@ function App() {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
setConfirmModal(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleEditProvider = async (provider: Provider) => {
|
const handleEditProvider = async (provider: Provider) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user