From 0086ce423603a9b95cb313efb17de778cb72a1f1 Mon Sep 17 00:00:00 2001 From: lyc Date: Tue, 23 Jul 2024 14:33:07 +0800 Subject: [PATCH] open win cookie --- src/main/index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 56a0833..2fce314 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -41,7 +41,7 @@ function createMainWindow() { width: 1200, height: 700, show: false, - frame: false,// 无边框 + frame: false, // 无边框 autoHideMenuBar: true, ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { @@ -84,13 +84,16 @@ function createOpenWin(data) { nodeIntegration: true } }) - let cookieDetails = {...data.cookieData} - openWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ - console.log('Cookie set successfully.') - }).catch(err =>{ - console.error('Set cookie failed:', error) + let cookieDetails = { ...data.cookieData } + console.log(cookieDetails) + openWindow.webContents.session.cookies.set(cookieDetails, (error) => { + if (error) { + console.error('设置cookie出错:', error) + } else { + console.log('设置cookie成功') + } }) - + openWindow.loadURL(data.fullPath) openWindow.once('ready-to-show', () => { @@ -149,6 +152,7 @@ app.on('ready', () => { createLoginWindow() } mainWindow.destroy() + mainWindow = null loginWindow.show() loginWindow.focus() })