Commit 2e484c3b authored by rocosen's avatar rocosen

fix:适配win

parent 7d408f0b
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -16,7 +16,6 @@ import MenuBuilder from './menu'; ...@@ -16,7 +16,6 @@ import MenuBuilder from './menu';
import { resolveHtmlPath } from './util'; import { resolveHtmlPath } from './util';
const nativeImage = require('electron').nativeImage; const nativeImage = require('electron').nativeImage;
const positioner = require('electron-traywindow-positioner'); const positioner = require('electron-traywindow-positioner');
class AppUpdater { class AppUpdater {
constructor() { constructor() {
log.transports.file.level = 'info'; log.transports.file.level = 'info';
...@@ -40,10 +39,20 @@ const getAssetPath = (...paths: string[]): string => { ...@@ -40,10 +39,20 @@ const getAssetPath = (...paths: string[]): string => {
return path.join(RESOURCES_PATH, ...paths); return path.join(RESOURCES_PATH, ...paths);
}; };
let image = nativeImage.createFromPath(getAssetPath('/img/iconTemplate.png')); let image:any
if (process.platform === 'darwin') {
image = nativeImage.createFromPath(getAssetPath('/img/iconTemplate.png'));
}else{
image = nativeImage.createFromPath(getAssetPath('/img/iconwinTemplate.png'));
}
Menu.setApplicationMenu(null); Menu.setApplicationMenu(null);
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
}
ipcMain.on('createNewWindow-site', (event, arg) => { ipcMain.on('createNewWindow-site', (event, arg) => {
if (siteWindown) { if (siteWindown) {
siteWindown.focus(); siteWindown.focus();
...@@ -156,8 +165,11 @@ const createWindow = async () => { ...@@ -156,8 +165,11 @@ const createWindow = async () => {
frame: true, frame: true,
resizable: false, resizable: false,
titleBarStyle: 'hidden', titleBarStyle: 'hidden',
titleBarOverlay: true, maximizable:false,
// autoHideMenuBar: true, titleBarOverlay: {
color: '#ffffff',
height: 30
},
webPreferences: { webPreferences: {
sandbox: false, sandbox: false,
nodeIntegration: true, nodeIntegration: true,
...@@ -167,7 +179,21 @@ const createWindow = async () => { ...@@ -167,7 +179,21 @@ const createWindow = async () => {
}); });
tray = new Tray(await image); tray = new Tray(await image);
const contextMenu = Menu.buildFromTemplate([
{
label: '退出',
click: async () => {
app.quit();
}
},
// { label: 'Item2', type: 'radio' },
// { label: 'Item3', type: 'radio', checked: true },
// { label: 'Item4', type: 'radio' }
])
tray.setContextMenu(contextMenu)
// tray.setTitle('test'); // tray.setTitle('test');
tray.setToolTip('北鲲云')
mainWindow.loadURL(resolveHtmlPath('index.html')); mainWindow.loadURL(resolveHtmlPath('index.html'));
// mainWindow.webContents.openDevTools(); // mainWindow.webContents.openDevTools();
...@@ -209,6 +235,12 @@ const createWindow = async () => { ...@@ -209,6 +235,12 @@ const createWindow = async () => {
homeWindown.show(); homeWindown.show();
positioner.position(homeWindown, tray.getBounds(), alignment); positioner.position(homeWindown, tray.getBounds(), alignment);
}); });
tray.on('right-click', function (){
if (!tray) return;
tray.popUpContextMenu();
});
}; };
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment