|
@@ -15,6 +15,7 @@ function createWindow() { |
|
|
mainWindow = new BrowserWindow({ |
|
|
mainWindow = new BrowserWindow({ |
|
|
width: 1080, |
|
|
width: 1080, |
|
|
height: 600, |
|
|
height: 600, |
|
|
|
|
|
minWidth: 400, |
|
|
webPreferences: { |
|
|
webPreferences: { |
|
|
nodeIntegration: true, |
|
|
nodeIntegration: true, |
|
|
// javascript: true, |
|
|
// javascript: true, |
|
@@ -25,6 +26,7 @@ function createWindow() { |
|
|
}) |
|
|
}) |
|
|
// and load the index.html of the app. |
|
|
// and load the index.html of the app. |
|
|
// mainWindow.loadFile('./dist/index.html') |
|
|
// mainWindow.loadFile('./dist/index.html') |
|
|
|
|
|
// mainWindow.loadURL('http://47.104.91.134:9000'); |
|
|
mainWindow.loadURL('http://www.lockingos.org: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://localhost:8081'); |
|
|
// 隐藏菜单栏 |
|
|
// 隐藏菜单栏 |
|
@@ -32,6 +34,39 @@ function createWindow() { |
|
|
// Open the DevTools. |
|
|
// Open the DevTools. |
|
|
// mainWindow.webContents.openDevTools() |
|
|
// mainWindow.webContents.openDevTools() |
|
|
mainWindow.maximize(); |
|
|
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.maximize()}}, |
|
|
|
|
|
{label: '最小化', click: () => {mainWindow.minimize()}}, |
|
|
|
|
|
{label: '还原', click: () => {mainWindow.restore()}}, |
|
|
|
|
|
{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 |
|
|
// This method will be called when Electron has finished |
|
@@ -66,6 +101,23 @@ app.on('second-instance', (event, commandLine, workingDirectory) => { |
|
|
// code. You can also put them in separate files and require them here. |
|
|
// 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(); |
|
|
|
|
|
}); |
|
|
/** |
|
|
/** |
|
|
* 项目中的文件上传 |
|
|
* 项目中的文件上传 |
|
|
*/ |
|
|
*/ |
|
@@ -81,7 +133,7 @@ ipcMain.handle('project-choose-folders', async (event, args) => { |
|
|
}); |
|
|
}); |
|
|
return res; |
|
|
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) => { |
|
|
ipcMain.handle('project-file-dnd', (event, filePath) => { |
|
|
console.log('receive file path: ', filePath) |
|
|
console.log('receive file path: ', filePath) |
|
|