StartupHideWindow is implemented

This commit is contained in:
병준 박 2019-12-18 17:11:58 +09:00
parent 760b098fc4
commit 22bb4d95f1
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 {
NotificationRequest,
UpdateCheckConfig,
NotificationType
} from '@ucap-webmessenger/native';
import { ElectronAppChannel } from '@ucap-webmessenger/electron-core';
@ -37,6 +36,7 @@ import { autoUpdater, CancellationToken } from 'electron-updater';
import log from 'electron-log';
import { RendererUpdater } from './lib/renderer-updater';
import { Storage } from './lib/storage';
const appIconPath = __LINUX__
? path.join(__dirname, 'static', 'icon-logo.png')
@ -55,6 +55,7 @@ let preventQuit = false;
let notificationService: ElectronNotificationService | null;
let updateWindowService: ElectronUpdateWindowService | null;
const appStorage: Storage = new Storage();
function handleUncaughtException(error: Error) {
preventQuit = true;
@ -159,7 +160,9 @@ function createWindow() {
});
window.onDidLoad(() => {
if (!appStorage.startupHideWindow) {
window.show();
}
const fns = onDidLoadFns;
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(
UpdaterChannel.StartCheckInstant,
(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_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() {
super({
this.store = new ElectronStore({
schema: {
options: {
type: 'object',
properties: {
autoRun: {
type: 'boolean'
},
autoLogin: {
type: 'boolean'
},
startupHideWindow: {
type: 'boolean'
}
},
default: {
autoRun: false,
autoLogin: false,
startupHideWindow: false
}
},
login: {
type: 'object',
properties: {
loginCompany: {
type: 'string'
},
loginId: {
type: 'string'
},
loginPw: {
type: 'string'
}
},
default: {
loginCompany: '',
loginId: '',
loginPw: ''
}
}
},
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 {
return this.get(STORE_KEY_STARTUPHIDEWINDOW, false);
return this.store.get(STORE_KEY_STARTUPHIDEWINDOW, false);
}
set startupHideWindow(startupHideWindow: boolean) {
this.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);
this.store.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow);
}
}

View File

@ -90,6 +90,12 @@ export class MessengerSettingsDialogComponent implements OnInit {
if (this.appUserInfo.settings.general.autoLaunch !== 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 });
}

View File

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

View File

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

View File

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

View File

@ -44,7 +44,7 @@ export const environment: Environment = {
continueRunWhenClose: true,
locale: 'ko',
hrInfoLocale: 'ko',
startBackgroudMode: false,
startupHideWindow: false,
timezone: '+9'
},
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 {
this.notificationService.notify(noti, () => {
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 {
this.ipcRenderer.send(NotificationChannel.Notify, noti);
}

View File

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

View File

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

View File

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

View File

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

View File

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