electron config is modified

This commit is contained in:
병준 박 2019-11-18 15:02:24 +09:00
parent ae413a3843
commit cf45005574
4 changed files with 79 additions and 14 deletions

View File

@ -12,19 +12,19 @@
},
"mac": {
"target": ["default"],
"icon": "./resources/installer/woori.icns"
"icon": "./dist/ucap-webmessenger-electron/resources/installer/woori.icns"
},
"dmg": {
"title": "UCapMessenger",
"icon": "./resources/installer/woori.icns"
"icon": "./dist/ucap-webmessenger-electron/resources/installer/woori.icns"
},
"win": {
"target": ["zip", "nsis"],
"icon": "./resources/installer/woori_256x256.ico"
"icon": "./dist/ucap-webmessenger-electron/resources/installer/woori_256x256.ico"
},
"linux": {
"target": ["AppImage", "deb", "rpm", "zip", "tar.gz"],
"icon": "./resources/linuxicon"
"icon": "./dist/ucap-webmessenger-electron/resources/linuxicon"
},
"nsis": {
"oneClick": false,
@ -33,7 +33,7 @@
"differentialPackage": true
},
"directories": {
"buildResources": "./resources/installer/",
"buildResources": "./dist/ucap-webmessenger-electron/resources/installer/",
"output": "./dist/electron/",
"app": "."
}

View File

@ -26,7 +26,7 @@ export class AppWindow {
private minWidth = 960;
private minHeight = 660;
public constructor() {
public constructor(private appIconPath: string) {
const savedWindowState = windowStateKeeper({
defaultWidth: this.minWidth,
defaultHeight: this.minHeight
@ -52,7 +52,7 @@ export class AppWindow {
nodeIntegration: true
},
acceptFirstMouse: true,
icon: path.join(__dirname, 'resources/image', 'ico_64_64.png')
icon: this.appIconPath
};
if (__DARWIN__) {
@ -60,7 +60,6 @@ export class AppWindow {
} else if (__WIN32__) {
windowOptions.frame = false;
} else if (__LINUX__) {
windowOptions.icon = path.join(__dirname, 'static', 'icon-logo.png');
}
this.window = new BrowserWindow(windowOptions);
@ -81,6 +80,8 @@ export class AppWindow {
// renderer.
if (__DARWIN__) {
this.window.on(ElectronBrowserWindowChannel.Close, e => {
this.window.hide();
if (!quitting) {
e.preventDefault();
}
@ -200,6 +201,10 @@ export class AppWindow {
this.window.show();
}
public hide() {
this.window.hide();
}
/**
* Get the time (in milliseconds) spent loading the page.
*

View File

@ -1,4 +1,12 @@
import { app, ipcMain, IpcMainEvent, remote } from 'electron';
import {
app,
ipcMain,
IpcMainEvent,
remote,
Tray,
Menu,
dialog
} from 'electron';
import * as path from 'path';
import * as url from 'url';
import * as fse from 'fs-extra';
@ -13,7 +21,7 @@ import {
FileChannel,
IdleStateChannel,
NotificationChannel,
ChatChannel,
ChatChannel
} from '@ucap-webmessenger/native-electron';
import { ElectronNotificationService } from '@ucap-webmessenger/electron-notification';
@ -25,7 +33,12 @@ import { IdleChecker } from './lib/idle-checker';
import { NotificationRequest } from '@ucap-webmessenger/native';
import { ElectronAppChannel } from '@ucap-webmessenger/electron-core';
const appIconPath = __LINUX__
? path.join(__dirname, 'static', 'icon-logo.png')
: path.join(__dirname, 'resources/image', 'ico_64_64.png');
let appWindow: AppWindow | null = null;
let appTray: Tray | null = null;
const launchTime = now();
let readyTime: number | null = null;
@ -91,7 +104,7 @@ if (isDuplicateInstance) {
}
function createWindow() {
const window = new AppWindow();
const window = new AppWindow(appIconPath);
if (__DEV__) {
// const {
@ -106,7 +119,7 @@ function createWindow() {
import('electron-devtools-installer').then(edi => {
const ChromeLens = {
id: 'idikgljglpfilbhaboonnpnnincjhjkd',
electron: '>=1.2.1',
electron: '>=1.2.1'
};
const extensions = [edi.REDUX_DEVTOOLS, ChromeLens];
@ -155,6 +168,51 @@ app.on(ElectronAppChannel.Ready, () => {
createWindow();
appTray = new Tray(appIconPath);
const contextMenu = Menu.buildFromTemplate([
{
label: '로그아웃',
// accelerator: 'Q',
// selector: 'terminate:',
click: () => {
// 로그아웃 후 로그인화면.
const options = {
type: 'question',
buttons: ['취소', '로그아웃'],
defaultId: 2,
title: 'Question',
message: '로그아웃',
detail: '로그아웃 하시겠습니까?'
// checkboxLabel: 'Remember my answer',
// checkboxChecked: true,
};
const choice = dialog.showMessageBoxSync(null, options);
if (1 === choice) {
// logout
appWindow.browserWindow.webContents.send(ChatChannel.OpenRoom);
}
}
},
{ label: '버전', submenu: [{ label: 'Ver. ' + app.getVersion() }] },
{
label: '종료',
// accelerator: 'Q',
// selector: 'terminate:',
click: () => {
// 메신저에 로그아웃 후 종료
appWindow = null;
app.exit();
}
}
]);
appTray.setToolTip('WooriTalk');
appTray.setContextMenu(contextMenu);
appTray.on('click', () => {
appWindow.isVisible() ? appWindow.hide() : appWindow.show();
});
notificationService = new ElectronNotificationService({
width: 340,
height: 100,
@ -166,7 +224,7 @@ app.on(ElectronAppChannel.Ready, () => {
defaultStyleAppIcon: { display: 'none' },
defaultStyleImage: {},
defaultStyleClose: {},
defaultStyleText: {},
defaultStyleText: {}
});
notificationService.options.defaultWindow.webPreferences.preload = path.join(
@ -298,7 +356,7 @@ ipcMain.on(
);
appWindow.show();
e.close();
},
}
});
}
);

View File

@ -15,6 +15,8 @@
"build:main:development": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts",
"build:main:production": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts",
"electron:windows": "electron-builder build --windows",
"electron:mac": "electron-builder build --mac",
"electron:linux": "electron-builder build --linux",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"