diff --git a/package.json b/package.json index 99b4789..3abf345 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "electron-app", - "version": "1.0.1", + "name": "aix-win", + "version": "1.0.2", "description": "An Electron application with Vue", "main": "./out/main/index.js", "author": "example.com", diff --git a/src/main/index.js b/src/main/index.js index 1fb5bdd..653c83c 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -103,11 +103,12 @@ function createMainWindow() { remote.enable(mainWindow.webContents) } -// 作业窗口相关-开发中 -let linkWindow +// 打开外部链接窗口 +let linkWin = {} async function createLinkWin(data) { - if (linkWindow) return - linkWindow = new BrowserWindow({ + if (linkWin[data.key]) return + + linkWin[data.key] = new BrowserWindow({ show: false, frame: true, maximizable: true, @@ -120,9 +121,10 @@ async function createLinkWin(data) { contextIsolation: true } }) - linkWindow.type = 'link' // 唯一标识 + linkWin[data.key].type = 'link' // 唯一标识 + let cookieDetails = { ...data.cookieData } - await linkWindow.webContents.session.cookies + await linkWin[data.key].webContents.session.cookies .set(cookieDetails) .then(() => { console.log('Cookie is successful') @@ -131,14 +133,15 @@ async function createLinkWin(data) { console.error('Cookie is error', error) }) data.fullPath = data.fullPath.replaceAll('//', '/') - linkWindow.loadURL(data.fullPath) + linkWin[data.key].loadURL(data.fullPath) - linkWindow.once('ready-to-show', () => { - linkWindow.show() - linkWindow.maximize() + linkWin[data.key].once('ready-to-show', () => { + linkWin[data.key].show() + linkWin[data.key].maximize() }) - linkWindow.on('closed', () => { - linkWindow = null + linkWin[data.key].on('closed', () => { + linkWin[data.key] = null + delete linkWin[data.key] }) } diff --git a/src/renderer/index.html b/src/renderer/index.html index 68cd483..3441296 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -2,7 +2,7 @@ - Electron + AIx智慧教育