Commit e5057669 authored by rocosen's avatar rocosen

Update main.ts

parent cb65c10a
...@@ -39,32 +39,31 @@ const getAssetPath = (...paths: string[]): string => { ...@@ -39,32 +39,31 @@ const getAssetPath = (...paths: string[]): string => {
return path.join(RESOURCES_PATH, ...paths); return path.join(RESOURCES_PATH, ...paths);
}; };
const exeName = path.basename(process.execPath) const exeName = path.basename(process.execPath);
let image: any;
let image:any
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
image = nativeImage.createFromPath(getAssetPath('/img/iconTemplate.png')); image = nativeImage.createFromPath(getAssetPath('/img/iconTemplate.png'));
}else{ } else {
image = nativeImage.createFromPath(getAssetPath('/img/iconwinTemplate.png')); image = nativeImage.createFromPath(
getAssetPath('/img/iconwinTemplate.png')
);
} }
Menu.setApplicationMenu(null); Menu.setApplicationMenu(null);
const gotTheLock = app.requestSingleInstanceLock() const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) { if (!gotTheLock) {
app.quit() app.quit();
} }
app.setLoginItemSettings({ app.setLoginItemSettings({
openAtLogin: true, openAtLogin: true,
openAsHidden:false, openAsHidden: false,
path: process.execPath, path: process.execPath,
args: [ args: ['--processStart', `"${exeName}"`],
'--processStart', `"${exeName}"`, });
]
})
ipcMain.on('createNewWindow-site', (event, arg) => { ipcMain.on('createNewWindow-site', (event, arg) => {
if (siteWindown) { if (siteWindown) {
siteWindown.focus(); siteWindown.focus();
...@@ -177,10 +176,10 @@ const createWindow = async () => { ...@@ -177,10 +176,10 @@ const createWindow = async () => {
frame: true, frame: true,
resizable: false, resizable: false,
titleBarStyle: 'hidden', titleBarStyle: 'hidden',
maximizable:false, maximizable: false,
titleBarOverlay: { titleBarOverlay: {
color: '#ffffff', color: '#ffffff',
height: 30 height: 30,
}, },
webPreferences: { webPreferences: {
sandbox: false, sandbox: false,
...@@ -196,13 +195,12 @@ const createWindow = async () => { ...@@ -196,13 +195,12 @@ const createWindow = async () => {
label: '退出', label: '退出',
click: async () => { click: async () => {
app.quit(); app.quit();
} },
}, },
]) ]);
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu);
// tray.setTitle('test'); // tray.setTitle('test');
tray.setToolTip('北鲲云') tray.setToolTip('北鲲云');
mainWindow.loadURL(resolveHtmlPath('index.html')); mainWindow.loadURL(resolveHtmlPath('index.html'));
// mainWindow.webContents.openDevTools(); // mainWindow.webContents.openDevTools();
...@@ -245,11 +243,10 @@ const createWindow = async () => { ...@@ -245,11 +243,10 @@ const createWindow = async () => {
positioner.position(homeWindown, tray.getBounds(), alignment); positioner.position(homeWindown, tray.getBounds(), alignment);
}); });
tray.on('right-click', function (){ tray.on('right-click', function () {
if (!tray) return; if (!tray) return;
tray.popUpContextMenu(); 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