fix: 修复新建项目无响应问题
- 替换 prompt() 为 InputDialog Vue 模态组件 - 替换 alert()/confirm() 为 Electron showMessageBox IPC - 添加 dialog:showMessage / dialog:showConfirm IPC 通道
This commit is contained in:
@@ -85,6 +85,28 @@ ipcMain.handle('dialog:saveFile', async (_event, options) => {
|
||||
return null
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:showMessage', async (_event, options) => {
|
||||
const result = await dialog.showMessageBox(mainWindow, {
|
||||
type: options?.type || 'info',
|
||||
buttons: options?.buttons || ['确定'],
|
||||
title: options?.title || 'Web2App',
|
||||
message: options?.message || ''
|
||||
})
|
||||
return result.response
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:showConfirm', async (_event, options) => {
|
||||
const result = await dialog.showMessageBox(mainWindow, {
|
||||
type: 'question',
|
||||
buttons: ['取消', '确定'],
|
||||
defaultId: 1,
|
||||
cancelId: 0,
|
||||
title: options?.title || 'Web2App',
|
||||
message: options?.message || '确认?'
|
||||
})
|
||||
return result.response === 1
|
||||
})
|
||||
|
||||
ipcMain.handle('dir:readTree', async (_event, dirPath) => {
|
||||
return readDirectoryTree(dirPath)
|
||||
})
|
||||
|
||||
@@ -5,7 +5,9 @@ contextBridge.exposeInMainWorld('api', {
|
||||
selectDirectory: () => ipcRenderer.invoke('dialog:selectDirectory'),
|
||||
selectFile: (options) => ipcRenderer.invoke('dialog:selectFile', options),
|
||||
selectIcon: () => ipcRenderer.invoke('dialog:selectIcon'),
|
||||
saveFile: (options) => ipcRenderer.invoke('dialog:saveFile', options)
|
||||
saveFile: (options) => ipcRenderer.invoke('dialog:saveFile', options),
|
||||
showMessage: (options) => ipcRenderer.invoke('dialog:showMessage', options),
|
||||
showConfirm: (options) => ipcRenderer.invoke('dialog:showConfirm', options)
|
||||
},
|
||||
dir: {
|
||||
readTree: (dirPath) => ipcRenderer.invoke('dir:readTree', dirPath)
|
||||
|
||||
Reference in New Issue
Block a user