新增询问窗口

This commit is contained in:
xuncha
2026-03-16 17:21:59 +08:00
parent 999ddaeb9a
commit f2b1b07f58
7 changed files with 206 additions and 17 deletions

View File

@@ -327,8 +327,19 @@ function App() {
setUpdateInfo(null)
}
const handleWindowCloseAction = async (action: 'tray' | 'quit' | 'cancel') => {
const handleWindowCloseAction = async (
action: 'tray' | 'quit' | 'cancel',
rememberChoice = false
) => {
setShowCloseDialog(false)
if (rememberChoice && action !== 'cancel') {
try {
await configService.setWindowCloseBehavior(action)
} catch (error) {
console.error('保存关闭偏好失败:', error)
}
}
try {
await window.electronAPI.window.respondCloseConfirm(action)
} catch (error) {
@@ -617,8 +628,7 @@ function App() {
<WindowCloseDialog
open={showCloseDialog}
canMinimizeToTray={canMinimizeToTray}
onTray={() => handleWindowCloseAction('tray')}
onQuit={() => handleWindowCloseAction('quit')}
onSelect={(action, rememberChoice) => handleWindowCloseAction(action, rememberChoice)}
onCancel={() => handleWindowCloseAction('cancel')}
/>