From 62a5339d040c2012f5515f338aa916feb336a351 Mon Sep 17 00:00:00 2001 From: zhuhao <979263092@qq.com> Date: Thu, 1 Aug 2024 17:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=9C=9F=EF=BC=9A=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 44 +++--- .../src/layout/components/AppMain.vue | 130 ++++++++++++++--- src/renderer/src/layout/components/Header.vue | 95 ++++++++----- src/renderer/src/store/modules/route.js | 15 ++ src/renderer/src/store/modules/user.js | 134 +++++++++--------- src/renderer/src/utils/linkConfig.js | 93 ++++++------ .../prepare/container/file-list-item.vue | 3 - src/renderer/src/views/prepare/index.vue | 116 +++++++++------ 8 files changed, 403 insertions(+), 227 deletions(-) create mode 100644 src/renderer/src/store/modules/route.js diff --git a/src/main/index.js b/src/main/index.js index ca7c16c..673da1f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -31,17 +31,17 @@ function createLoginWindow() { preload: join(__dirname, '../preload/index.js'), sandbox: false, nodeIntegration: true, - contextIsolation: false, // 沙箱取消 + contextIsolation: false // 沙箱取消 } }) - loginWindow.type = 'login' // 唯一标识 + loginWindow.type = 'login' // 唯一标识 // handleUpdate(loginWindow,ipcMain) // const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/#/login` // loginWindow.loadURL(loginURL) if (is.dev && process.env['ELECTRON_RENDERER_URL']) { loginWindow.loadURL('http://localhost:5173/#/login') } else { - loginWindow.loadFile(join(__dirname, '../renderer/index.html'), {hash: 'login'}) + loginWindow.loadFile(join(__dirname, '../renderer/index.html'), { hash: 'login' }) updateInit(loginWindow) } @@ -70,17 +70,18 @@ function createMainWindow() { preload: join(__dirname, '../preload/index.js'), sandbox: false, // nodeIntegration: true, - nodeIntegration: true, // nodeApi调用 - contextIsolation: false, // 沙箱取消 + nodeIntegration: true, // nodeApi调用 + contextIsolation: false // 沙箱取消 // webSecurity: false // 跨域关闭 } }) - mainWindow.type = 'main' // 唯一标识 + mainWindow.type = 'main' // 唯一标识 mainWindow.on('ready-to-show', () => { mainWindow.show() }) mainWindow.on('closed', () => { - setTimeout(() => { // 延迟销毁 + setTimeout(() => { + // 延迟销毁 mainWindow = null }, 1000) // app.quit() // 主窗口关闭-结束所有进程 @@ -92,7 +93,7 @@ function createMainWindow() { mainWindow.webContents.openDevTools() if (is.dev && process.env['ELECTRON_RENDERER_URL']) { - mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] ) + mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) } else { mainWindow.loadFile(join(__dirname, '../renderer/index.html')) } @@ -102,7 +103,6 @@ function createMainWindow() { remote.enable(mainWindow.webContents) } - // 作业窗口相关-开发中 let linkWindow async function createLinkWin(data) { @@ -120,14 +120,17 @@ async function createLinkWin(data) { contextIsolation: true } }) - linkWindow.type = 'link' // 唯一标识 + linkWindow.type = 'link' // 唯一标识 let cookieDetails = { ...data.cookieData } - await linkWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ - console.log('Cookie is successful'); - }).catch( error =>{ - console.error('Cookie is error', error); - }) - + await linkWindow.webContents.session.cookies + .set(cookieDetails) + .then(() => { + console.log('Cookie is successful') + }) + .catch((error) => { + console.error('Cookie is error', error) + }) + data.fullPath = data.fullPath.replaceAll('//', '/') linkWindow.loadURL(data.fullPath) linkWindow.once('ready-to-show', () => { @@ -169,9 +172,10 @@ app.on('ready', () => { } if (mainWindow) { mainWindow.close() // 先发出这个关闭指令 - setTimeout(() => { // + setTimeout(() => { + // mainWindow.destroy() - }, 200); + }, 200) } }) @@ -199,21 +203,19 @@ app.on('ready', () => { createLinkWin(data) }) // 新窗口创建-监听 - ipcMain.on('new-window', (e,data) => { + ipcMain.on('new-window', (e, data) => { const { id, type } = data const win = BrowserWindow.fromId(id) win.type = type // 绑定独立标识 remote.enable(win.webContents) // 开启远程服务 }) - // 打开-登录窗口 createLoginWindow() app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createLoginWindow() }) - }) // Quit when all windows are closed, except on macOS. There, it's common diff --git a/src/renderer/src/layout/components/AppMain.vue b/src/renderer/src/layout/components/AppMain.vue index 41a2025..a526b2f 100644 --- a/src/renderer/src/layout/components/AppMain.vue +++ b/src/renderer/src/layout/components/AppMain.vue @@ -1,23 +1,11 @@ - +