diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index 4c0193d1..cb813086 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -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(() => { - window.show(); + 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[]) => { diff --git a/electron-projects/ucap-webmessenger-electron/src/lib/storage.ts b/electron-projects/ucap-webmessenger-electron/src/lib/storage.ts index f39c1095..4c3ce558 100644 --- a/electron-projects/ucap-webmessenger-electron/src/lib/storage.ts +++ b/electron-projects/ucap-webmessenger-electron/src/lib/storage.ts @@ -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 { +export class Storage { + private readonly store: ElectronStore; + 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 { }); } - 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); } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/settings/messenger-settings.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/settings/messenger-settings.dialog.component.ts index 282ed2fa..d23bfb16 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/settings/messenger-settings.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/settings/messenger-settings.dialog.component.ts @@ -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 }); } diff --git a/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts b/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts index 72decdd7..70e768d5 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts @@ -44,7 +44,7 @@ export const environment: Environment = { continueRunWhenClose: true, locale: 'ko', hrInfoLocale: 'ko', - startBackgroudMode: false, + startupHideWindow: false, timezone: '+9' }, notification: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts index 8e6780c3..c97384e6 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts @@ -44,7 +44,7 @@ export const environment: Environment = { continueRunWhenClose: true, locale: 'ko', hrInfoLocale: 'ko', - startBackgroudMode: false, + startupHideWindow: false, timezone: '+9' }, notification: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts index 806d123f..3ec8f174 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts @@ -44,7 +44,7 @@ export const environment: Environment = { continueRunWhenClose: true, locale: 'ko', hrInfoLocale: 'ko', - startBackgroudMode: false, + startupHideWindow: false, timezone: '+9' }, notification: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.prod.ts b/projects/ucap-webmessenger-app/src/environments/environment.prod.ts index c29d2b50..5b202b7f 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.prod.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.prod.ts @@ -44,7 +44,7 @@ export const environment: Environment = { continueRunWhenClose: true, locale: 'ko', hrInfoLocale: 'ko', - startBackgroudMode: false, + startupHideWindow: false, timezone: '+9' }, notification: { diff --git a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts index b1aa4fba..7db1b585 100644 --- a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts +++ b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts @@ -72,6 +72,12 @@ export class BrowserNativeService extends NativeService { }); } + changeStartupHideWindow(startupHideWindow: boolean): Promise { + return new Promise((resolve, reject) => { + resolve(true); + }); + } + notify(noti: NotificationRequest): void { this.notificationService.notify(noti, () => { window.focus(); diff --git a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts index 51cfb636..44e5b733 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts @@ -116,6 +116,21 @@ export class ElectronNativeService implements NativeService { }); } + changeStartupHideWindow(startupHideWindow: boolean): Promise { + return new Promise((resolve, reject) => { + try { + resolve( + this.ipcRenderer.sendSync( + MessengerChannel.ChangeStartupHideWindow, + startupHideWindow + ) + ); + } catch (error) { + reject(error); + } + }); + } + notify(noti: NotificationRequest): void { this.ipcRenderer.send(NotificationChannel.Notify, noti); } diff --git a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts index 4f6ac160..6c4101f4 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts @@ -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 { diff --git a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts index 7cdd675e..bb87b94b 100644 --- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts +++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts @@ -15,6 +15,9 @@ export abstract class NativeService { abstract showSetting(): Observable; abstract changeAutoLaunch(autoLaunch: boolean): Promise; + abstract changeStartupHideWindow( + startupHideWindow: boolean + ): Promise; abstract notify(noti: NotificationRequest): void; abstract closeAllNotify(): void; diff --git a/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.html b/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.html index 4414efa2..b4e1867d 100644 --- a/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.html +++ b/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.html @@ -47,8 +47,8 @@ 실행 시 창 숨기기 diff --git a/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.ts b/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.ts index 0787b678..8c41ddb2 100644 --- a/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.ts +++ b/projects/ucap-webmessenger-ui-settings/src/lib/components/general.component.ts @@ -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 }); diff --git a/projects/ucap-webmessenger-ui-settings/src/lib/models/settings.ts b/projects/ucap-webmessenger-ui-settings/src/lib/models/settings.ts index 6e1cdba7..db57fbe8 100644 --- a/projects/ucap-webmessenger-ui-settings/src/lib/models/settings.ts +++ b/projects/ucap-webmessenger-ui-settings/src/lib/models/settings.ts @@ -1,7 +1,7 @@ export interface GeneralSetting { appTheme: string; autoLaunch: boolean; - startBackgroudMode: boolean; + startupHideWindow: boolean; continueRunWhenClose: boolean; autoLogin: boolean; locale: string;