This commit is contained in:
leejinho 2019-12-19 08:50:28 +09:00
commit 7501275465
14 changed files with 69 additions and 84 deletions

View File

@ -28,7 +28,6 @@ import { FileUtil } from './lib/file-util';
import { IdleChecker } from './lib/idle-checker'; import { IdleChecker } from './lib/idle-checker';
import { import {
NotificationRequest, NotificationRequest,
UpdateCheckConfig,
NotificationType NotificationType
} from '@ucap-webmessenger/native'; } from '@ucap-webmessenger/native';
import { ElectronAppChannel } from '@ucap-webmessenger/electron-core'; import { ElectronAppChannel } from '@ucap-webmessenger/electron-core';
@ -37,6 +36,7 @@ import { autoUpdater, CancellationToken } from 'electron-updater';
import log from 'electron-log'; import log from 'electron-log';
import { RendererUpdater } from './lib/renderer-updater'; import { RendererUpdater } from './lib/renderer-updater';
import { Storage } from './lib/storage';
const appIconPath = __LINUX__ const appIconPath = __LINUX__
? path.join(__dirname, 'static', 'icon-logo.png') ? path.join(__dirname, 'static', 'icon-logo.png')
@ -55,6 +55,7 @@ let preventQuit = false;
let notificationService: ElectronNotificationService | null; let notificationService: ElectronNotificationService | null;
let updateWindowService: ElectronUpdateWindowService | null; let updateWindowService: ElectronUpdateWindowService | null;
const appStorage: Storage = new Storage();
function handleUncaughtException(error: Error) { function handleUncaughtException(error: Error) {
preventQuit = true; preventQuit = true;
@ -159,7 +160,9 @@ function createWindow() {
}); });
window.onDidLoad(() => { window.onDidLoad(() => {
if (!appStorage.startupHideWindow) {
window.show(); window.show();
}
const fns = onDidLoadFns; const fns = onDidLoadFns;
onDidLoadFns = null; onDidLoadFns = null;
@ -376,6 +379,22 @@ ipcMain.on(
} }
); );
ipcMain.on(
MessengerChannel.ChangeStartupHideWindow,
(event: IpcMainEvent, ...args: any[]) => {
const isStartupHideWindow = args[0] as boolean;
appStorage.startupHideWindow = isStartupHideWindow;
log.info(
'StartupHideWindow is changed from ',
!appStorage.startupHideWindow,
' to ',
appStorage.startupHideWindow
);
event.returnValue = true;
}
);
ipcMain.on( ipcMain.on(
UpdaterChannel.StartCheckInstant, UpdaterChannel.StartCheckInstant,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {

View File

@ -1,53 +1,23 @@
import Store from 'electron-store'; import ElectronStore from 'electron-store';
const STORE_KEY_AUTORUN = 'options.autoRun';
const STORE_KEY_AUTOLOGIN = 'options.autoLogin';
const STORE_KEY_STARTUPHIDEWINDOW = 'options.startupHideWindow'; const STORE_KEY_STARTUPHIDEWINDOW = 'options.startupHideWindow';
const STORE_KEY_LOGINCOMPANY = 'login.loginCompany';
const STORE_KEY_LOGINID = 'login.loginId';
const STORE_KEY_LOGINPW = 'login.loginPw';
export class Storage extends Store<any> { export class Storage {
private readonly store: ElectronStore<any>;
constructor() { constructor() {
super({ this.store = new ElectronStore({
schema: { schema: {
options: { options: {
type: 'object', type: 'object',
properties: { properties: {
autoRun: {
type: 'boolean'
},
autoLogin: {
type: 'boolean'
},
startupHideWindow: { startupHideWindow: {
type: 'boolean' type: 'boolean'
} }
}, },
default: { default: {
autoRun: false,
autoLogin: false,
startupHideWindow: false startupHideWindow: false
} }
},
login: {
type: 'object',
properties: {
loginCompany: {
type: 'string'
},
loginId: {
type: 'string'
},
loginPw: {
type: 'string'
}
},
default: {
loginCompany: '',
loginId: '',
loginPw: ''
}
} }
}, },
encryptionKey: 'ucap', encryptionKey: 'ucap',
@ -55,45 +25,10 @@ export class Storage extends Store<any> {
}); });
} }
get autoRun(): boolean {
return this.get(STORE_KEY_AUTORUN, false);
}
set autoRun(autoRun: boolean) {
this.set(STORE_KEY_AUTORUN, autoRun);
}
get autoLogin(): boolean {
return this.get(STORE_KEY_AUTOLOGIN, false);
}
set autoLogin(autoLogin: boolean) {
this.set(STORE_KEY_AUTOLOGIN, autoLogin);
}
get startupHideWindow(): boolean { get startupHideWindow(): boolean {
return this.get(STORE_KEY_STARTUPHIDEWINDOW, false); return this.store.get(STORE_KEY_STARTUPHIDEWINDOW, false);
} }
set startupHideWindow(startupHideWindow: boolean) { set startupHideWindow(startupHideWindow: boolean) {
this.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow); this.store.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow);
}
get loginCompany(): string {
return this.get(STORE_KEY_LOGINCOMPANY, false);
}
set loginCompany(loginCompany: string) {
this.set(STORE_KEY_LOGINCOMPANY, loginCompany);
}
get loginId(): string {
return this.get(STORE_KEY_LOGINID, false);
}
set loginId(loginId: string) {
this.set(STORE_KEY_LOGINID, loginId);
}
get loginPw(): string {
return this.get(STORE_KEY_LOGINPW, false);
}
set loginPw(loginPw: string) {
this.set(STORE_KEY_LOGINPW, loginPw);
} }
} }

View File

@ -90,6 +90,12 @@ export class MessengerSettingsDialogComponent implements OnInit {
if (this.appUserInfo.settings.general.autoLaunch !== setting.autoLaunch) { if (this.appUserInfo.settings.general.autoLaunch !== setting.autoLaunch) {
this.nativeService.changeAutoLaunch(setting.autoLaunch); this.nativeService.changeAutoLaunch(setting.autoLaunch);
} }
if (
this.appUserInfo.settings.general.startupHideWindow !==
setting.startupHideWindow
) {
this.nativeService.changeStartupHideWindow(setting.startupHideWindow);
}
this.applySettings({ ...this.appUserInfo.settings, general: setting }); this.applySettings({ ...this.appUserInfo.settings, general: setting });
} }

View File

@ -44,7 +44,7 @@ export const environment: Environment = {
continueRunWhenClose: true, continueRunWhenClose: true,
locale: 'ko', locale: 'ko',
hrInfoLocale: 'ko', hrInfoLocale: 'ko',
startBackgroudMode: false, startupHideWindow: false,
timezone: '+9' timezone: '+9'
}, },
notification: { notification: {

View File

@ -44,7 +44,7 @@ export const environment: Environment = {
continueRunWhenClose: true, continueRunWhenClose: true,
locale: 'ko', locale: 'ko',
hrInfoLocale: 'ko', hrInfoLocale: 'ko',
startBackgroudMode: false, startupHideWindow: false,
timezone: '+9' timezone: '+9'
}, },
notification: { notification: {

View File

@ -44,7 +44,7 @@ export const environment: Environment = {
continueRunWhenClose: true, continueRunWhenClose: true,
locale: 'ko', locale: 'ko',
hrInfoLocale: 'ko', hrInfoLocale: 'ko',
startBackgroudMode: false, startupHideWindow: false,
timezone: '+9' timezone: '+9'
}, },
notification: { notification: {

View File

@ -44,7 +44,7 @@ export const environment: Environment = {
continueRunWhenClose: true, continueRunWhenClose: true,
locale: 'ko', locale: 'ko',
hrInfoLocale: 'ko', hrInfoLocale: 'ko',
startBackgroudMode: false, startupHideWindow: false,
timezone: '+9' timezone: '+9'
}, },
notification: { notification: {

View File

@ -72,6 +72,12 @@ export class BrowserNativeService extends NativeService {
}); });
} }
changeStartupHideWindow(startupHideWindow: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
resolve(true);
});
}
notify(noti: NotificationRequest): void { notify(noti: NotificationRequest): void {
this.notificationService.notify(noti, () => { this.notificationService.notify(noti, () => {
window.focus(); window.focus();

View File

@ -116,6 +116,21 @@ export class ElectronNativeService implements NativeService {
}); });
} }
changeStartupHideWindow(startupHideWindow: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
try {
resolve(
this.ipcRenderer.sendSync(
MessengerChannel.ChangeStartupHideWindow,
startupHideWindow
)
);
} catch (error) {
reject(error);
}
});
}
notify(noti: NotificationRequest): void { notify(noti: NotificationRequest): void {
this.ipcRenderer.send(NotificationChannel.Notify, noti); this.ipcRenderer.send(NotificationChannel.Notify, noti);
} }

View File

@ -2,7 +2,8 @@ export enum MessengerChannel {
Logout = 'UCAP::messenger::logout', Logout = 'UCAP::messenger::logout',
ChangeStatus = 'UCAP::messenger::changeStatus', ChangeStatus = 'UCAP::messenger::changeStatus',
ShowSetting = 'UCAP::messenger::showSetting', ShowSetting = 'UCAP::messenger::showSetting',
ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch' ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch',
ChangeStartupHideWindow = 'UCAP::messenger::changeStartupHideWindow'
} }
export enum ChatChannel { export enum ChatChannel {

View File

@ -15,6 +15,9 @@ export abstract class NativeService {
abstract showSetting(): Observable<void>; abstract showSetting(): Observable<void>;
abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>; abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>;
abstract changeStartupHideWindow(
startupHideWindow: boolean
): Promise<boolean>;
abstract notify(noti: NotificationRequest): void; abstract notify(noti: NotificationRequest): void;
abstract closeAllNotify(): void; abstract closeAllNotify(): void;

View File

@ -47,8 +47,8 @@
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-checkbox <mat-checkbox
[checked]="setting.startBackgroudMode" [checked]="setting.startupHideWindow"
(change)="onChangeStartBackgroudMode($event)" (change)="onChangeStartupHideWindow($event)"
>실행 시 창 숨기기</mat-checkbox >실행 시 창 숨기기</mat-checkbox
> >
</mat-list-item> </mat-list-item>

View File

@ -67,8 +67,8 @@ export class GeneralComponent implements OnInit {
onChangeAutoStart(event: MatCheckboxChange) { onChangeAutoStart(event: MatCheckboxChange) {
this.emit({ ...this.setting, autoLaunch: event.checked }); this.emit({ ...this.setting, autoLaunch: event.checked });
} }
onChangeStartBackgroudMode(event: MatCheckboxChange) { onChangeStartupHideWindow(event: MatCheckboxChange) {
this.emit({ ...this.setting, startBackgroudMode: event.checked }); this.emit({ ...this.setting, startupHideWindow: event.checked });
} }
onChangeContinueRunWhenClose(event: MatCheckboxChange) { onChangeContinueRunWhenClose(event: MatCheckboxChange) {
this.emit({ ...this.setting, continueRunWhenClose: event.checked }); this.emit({ ...this.setting, continueRunWhenClose: event.checked });

View File

@ -1,7 +1,7 @@
export interface GeneralSetting { export interface GeneralSetting {
appTheme: string; appTheme: string;
autoLaunch: boolean; autoLaunch: boolean;
startBackgroudMode: boolean; startupHideWindow: boolean;
continueRunWhenClose: boolean; continueRunWhenClose: boolean;
autoLogin: boolean; autoLogin: boolean;
locale: string; locale: string;