This commit is contained in:
zh
2025-09-18 20:48:30 +08:00
parent a0499b9b35
commit e7c4294d71
100 changed files with 45475 additions and 122 deletions

View File

@ -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)