From 4ff6bb4ecfdaf6874de1f8eb05604d6e32175a5c Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Tue, 22 Dec 2020 16:05:03 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=89=98=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/index.js b/src/main/index.js index 4e5bf80..9b377d2 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -15,6 +15,7 @@ function createWindow() { mainWindow = new BrowserWindow({ width: 1080, height: 600, + minWidth: 400, webPreferences: { nodeIntegration: true, // javascript: true, @@ -34,6 +35,36 @@ function createWindow() { // Open the DevTools. // mainWindow.webContents.openDevTools() mainWindow.maximize(); + + // 当窗口已经关闭的时候触发 + mainWindow.on('closed', (event) => { + mainWindow = null; + }); + // 当窗口要关闭的时候触发 + mainWindow.on('close', (event) => { + mainWindow.hide(); + mainWindow.setSkipTaskbar(true); + event.preventDefault(); + }); + + mainWindow.on('show', () => { + tray.setHighlightMode('always') + }) + mainWindow.on('hide', () => { + tray.setHighlightMode('never') + }) + + // 创建系统通知区菜单 + tray = new Tray(path.join(__dirname, 'file_word.png')); + const contextMenu = Menu.buildFromTemplate([ + {label: '退出', click: () => {mainWindow.destroy()}},//我们需要在这里有一个真正的退出(这里直接强制退出) + ]) + tray.setToolTip('LOCKING探索者') + tray.setContextMenu(contextMenu); + tray.on('click', ()=>{ //我们这里模拟桌面程序点击通知区图标实现打开关闭应用的功能 + mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show() + mainWindow.isVisible() ? mainWindow.setSkipTaskbar(false) : mainWindow.setSkipTaskbar(true); + }) } // This method will be called when Electron has finished From 21acad7757dfe375fdbcdeb0da37850077aecbe8 Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Tue, 22 Dec 2020 16:32:00 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=98=E7=9B=98?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 9b377d2..ba59a10 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -56,7 +56,10 @@ function createWindow() { // 创建系统通知区菜单 tray = new Tray(path.join(__dirname, 'file_word.png')); - const contextMenu = Menu.buildFromTemplate([ + const contextMenu = Menu.buildFromTemplate([ + {label: '最大化', click: () => { mainWindow.maximize()}}, + {label: '最小化', click: () => {mainWindow.minimize()}}, + {label: '还原', click: () => {mainWindow.restore()}}, {label: '退出', click: () => {mainWindow.destroy()}},//我们需要在这里有一个真正的退出(这里直接强制退出) ]) tray.setToolTip('LOCKING探索者') From 4b1d6c1bf6b8958df4bdb8a886133d695b8e8895 Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Fri, 25 Dec 2020 10:29:21 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E9=A1=B6=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=BA=94=E7=94=A8=E6=8C=89=E9=92=AE=20=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/index.js b/src/main/index.js index ba59a10..4ecc832 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -102,6 +102,12 @@ app.on('second-instance', (event, commandLine, workingDirectory) => { // code. You can also put them in separate files and require them here. // 监听必要的自定义事件 +/** + * 点击退出应用 + */ +ipcMain.handle('close-app', async (event, args) => { + mainWindow.destroy(); +}); /** * 项目中的文件上传 */ From c9f16356bcb65ef2502e1e4cac772577f9257c4d Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Fri, 25 Dec 2020 10:35:56 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 4ecc832..8d93c02 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -27,7 +27,7 @@ function createWindow() { // and load the index.html of the app. // mainWindow.loadFile('./dist/index.html') // mainWindow.loadURL('http://47.104.91.134:9000'); - mainWindow.loadURL('http://47.104.91.134:9000', { "extraHeaders": "pragma: no-cache\n" }); + mainWindow.loadURL('http://www.lockingos.org:9000', { "extraHeaders": "pragma: no-cache\n" }); // mainWindow.loadURL('http://localhost:8081'); // mainWindow.loadURL('http://10.240.33.229:8081'); // 隐藏菜单栏 From 68054b74b0a96ff14e1e6f474320b6a21101787a Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Mon, 28 Dec 2020 11:31:19 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=80=80=E5=87=BA=E5=BA=94=E7=94=A8=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 8d93c02..d4193ff 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -102,12 +102,6 @@ app.on('second-instance', (event, commandLine, workingDirectory) => { // code. You can also put them in separate files and require them here. // 监听必要的自定义事件 -/** - * 点击退出应用 - */ -ipcMain.handle('close-app', async (event, args) => { - mainWindow.destroy(); -}); /** * 项目中的文件上传 */ From 64feb3327e4bc3d3cf5802ded54ea8a06b86a92b Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Fri, 8 Jan 2021 14:49:45 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20=E7=BC=A9=E5=B0=8F=E6=94=BE=E5=A4=A7=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/index.js b/src/main/index.js index d4193ff..12e2637 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -102,6 +102,23 @@ app.on('second-instance', (event, commandLine, workingDirectory) => { // code. You can also put them in separate files and require them here. // 监听必要的自定义事件 +// 缩小 放大 暂时关闭窗口 +ipcMain.handle('shrink-browser-window', async (event, args) => { + mainWindow.minimize(); +}); +ipcMain.handle('enlarge-browser-window', async (event, args) => { + mainWindow.maximize(); +}); +ipcMain.handle('unmax-browser-window', async (event, args) => { + mainWindow.unmaximize(); +}); +ipcMain.handle('close-browser-window', async (event, args) => { + mainWindow.close(); +}); +// 判断是否是最大化窗口状态 +ipcMain.handle('is-max-window-now', async (event, args) => { + return mainWindow.isMaximized(); +}); /** * 项目中的文件上传 */ From 34e05bfa63c31b41dea0dc1606dd6eba49b90909 Mon Sep 17 00:00:00 2001 From: kim131 <1035828775@qq.com> Date: Sat, 9 Jan 2021 17:07:32 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 12e2637..a3eebce 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -134,7 +134,7 @@ ipcMain.handle('project-choose-folders', async (event, args) => { }); return res; }); -const testIcon = nativeImage.createFromPath(path.resolve(__dirname, 'file_word.png')); +const testIcon = nativeImage.createFromPath(path.resolve(__dirname, 'file-icon.png')); ipcMain.handle('project-file-dnd', (event, filePath) => { console.log('receive file path: ', filePath)