提交
This commit is contained in:
@ -136,9 +136,9 @@ function createWindow(): void {
|
||||
ipcMain.on("open-directory-dialog", (event, option) => {
|
||||
// @ts-ignore
|
||||
dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), {
|
||||
properties: option.properties,
|
||||
filters: option.filters,
|
||||
})
|
||||
properties: option.properties,
|
||||
filters: option.filters,
|
||||
})
|
||||
.then((files) => {
|
||||
let arr = [];
|
||||
if (!files.canceled) {
|
||||
@ -194,6 +194,20 @@ function createWindow(): void {
|
||||
}
|
||||
});
|
||||
});
|
||||
// 监听渲染进程创建新窗口的请求
|
||||
ipcMain.handle('create-new-window', async (event, params, url, option) => {
|
||||
try {
|
||||
const newWindow = await new BrowserWindow(params)
|
||||
if (url) {
|
||||
await newWindow.loadURL(url)
|
||||
await newWindow.webContents.send("data", option)
|
||||
}
|
||||
return newWindow.id
|
||||
} catch (error) {
|
||||
console.error('创建窗口失败:', error);
|
||||
throw error; // 抛出错误以便渲染进程捕获
|
||||
}
|
||||
})
|
||||
// 设置窗口标题和图标
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
|
||||
Reference in New Issue
Block a user