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';
import { resolveHtmlPath } from './util';
const nativeImage = require('electron').nativeImage;
const positioner = require('electron-traywindow-positioner');
class AppUpdater {
constructor() {
log.transports.file.level = 'info';
......@@ -40,10 +39,20 @@ const getAssetPath = (...paths: string[]): string => {
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);
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
}
ipcMain.on('createNewWindow-site', (event, arg) => {
if (siteWindown) {
siteWindown.focus();
......@@ -156,8 +165,11 @@ const createWindow = async () => {
frame: true,
resizable: false,
titleBarStyle: 'hidden',
titleBarOverlay: true,
// autoHideMenuBar: true,
maximizable:false,
titleBarOverlay: {
color: '#ffffff',
height: 30
},
webPreferences: {
sandbox: false,
nodeIntegration: true,
......@@ -167,7 +179,21 @@ const createWindow = async () => {
});
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.setToolTip('北鲲云')
mainWindow.loadURL(resolveHtmlPath('index.html'));
// mainWindow.webContents.openDevTools();
......@@ -209,6 +235,12 @@ const createWindow = async () => {
homeWindown.show();
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