This commit is contained in:
leejinho 2019-12-17 17:41:58 +09:00
commit 900e9b57ea
15 changed files with 113 additions and 14 deletions

View File

@ -3,6 +3,8 @@ import path from 'path';
import fse from 'fs-extra';
import semver from 'semver';
import AutoLaunch from 'auto-launch';
import { AppWindow } from './app/AppWindow';
import { now } from './util/now';
import { showUncaughtException } from './crash/show-uncaught-exception';
@ -95,6 +97,10 @@ let autoUpdaterCancellationToken: CancellationToken;
autoUpdater.autoDownload = false;
autoUpdater.logger = log;
const ucapMessengerLauncher = new AutoLaunch({
name: app.getName()
});
app.on(ElectronAppChannel.SecondInstance, (event, args, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (appWindow) {
@ -341,6 +347,35 @@ ipcMain.on(UpdaterChannel.Check, (event: IpcMainEvent, ...args: any[]) => {
}
});
ipcMain.on(
MessengerChannel.ChangeAutoLaunch,
(event: IpcMainEvent, ...args: any[]) => {
const isAutoLaunch = args[0] as boolean;
if (isAutoLaunch) {
ucapMessengerLauncher
.enable()
.then(() => {
event.returnValue = true;
console.log('AutoLaunch is enabled');
})
.catch(reason => {
event.returnValue = false;
});
} else {
ucapMessengerLauncher
.disable()
.then(() => {
event.returnValue = true;
console.log('AutoLaunch is disabled');
})
.catch(reason => {
event.returnValue = false;
});
}
}
);
ipcMain.on(
UpdaterChannel.StartCheckInstant,
(event: IpcMainEvent, ...args: any[]) => {

36
package-lock.json generated
View File

@ -2270,6 +2270,12 @@
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==",
"dev": true
},
"@types/auto-launch": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.1.tgz",
"integrity": "sha512-+KQ+/koZ7sJXnf5cnCANofY6yXAdYJNEoVZEuWcwJfuWbUp9u6l09I7KhwD+ivU+cdz7JId4V5ukxscWtHdSuw==",
"dev": true
},
"@types/axios": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz",
@ -2974,6 +2980,11 @@
"default-require-extensions": "^2.0.0"
}
},
"applescript": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
"integrity": "sha1-u4evVoytA0pOSMS9r2Bno6JwExc="
},
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
@ -3156,6 +3167,18 @@
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
"dev": true
},
"auto-launch": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/auto-launch/-/auto-launch-5.0.5.tgz",
"integrity": "sha512-ppdF4mihhYzMYLuCcx9H/c5TUOCev8uM7en53zWVQhyYAJrurd2bFZx3qQVeJKF2jrc7rsPRNN5cD+i23l6PdA==",
"requires": {
"applescript": "^1.0.0",
"mkdirp": "^0.5.1",
"path-is-absolute": "^1.0.0",
"untildify": "^3.0.2",
"winreg": "1.2.4"
}
},
"autolinker": {
"version": "3.11.1",
"resolved": "https://registry.npmjs.org/autolinker/-/autolinker-3.11.1.tgz",
@ -11215,8 +11238,7 @@
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-is-inside": {
"version": "1.0.2",
@ -14408,6 +14430,11 @@
}
}
},
"untildify": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/untildify/-/untildify-3.0.3.tgz",
"integrity": "sha512-iSk/J8efr8uPT/Z4eSUywnqyrQU7DSdMfdqK4iWEaUVVmcP5JcnpRqmVMwcwcnmI1ATFNgC5V90u09tBynNFKA=="
},
"upath": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz",
@ -16425,6 +16452,11 @@
"string-width": "^2.1.1"
}
},
"winreg": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
"integrity": "sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs="
},
"wordwrap": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",

View File

@ -35,6 +35,7 @@
"private": true,
"dependencies": {
"@angular/core": "~8.2.12",
"auto-launch": "^5.0.5",
"electron-log": "^3.0.9",
"electron-updater": "^4.2.0",
"electron-window-state": "^5.0.3",
@ -67,6 +68,7 @@
"@ngrx/store": "^8.4.0",
"@ngrx/store-devtools": "^8.4.0",
"@ngx-translate/core": "^11.0.1",
"@types/auto-launch": "^5.0.1",
"@types/axios": "^0.14.0",
"@types/copy-webpack-plugin": "^5.0.0",
"@types/crypto-js": "^3.1.43",

View File

@ -23,6 +23,7 @@ import {
Settings,
NotificationSetting
} from '@ucap-webmessenger/ui-settings';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
export interface MessengerSettingsDialogData {}
@ -48,6 +49,7 @@ export class MessengerSettingsDialogComponent implements OnInit {
private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService,
private ucapTranslateService: UCapTranslateService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private store: Store<any>,
@Inject(DOCUMENT) private document: Document,
private renderer2: Renderer2
@ -82,6 +84,10 @@ export class MessengerSettingsDialogComponent implements OnInit {
) {
this.ucapTranslateService.use(setting.hrInfoLocale);
}
if (this.appUserInfo.settings.general.autoLaunch !== setting.autoLaunch) {
this.nativeService.changeAutoLaunch(setting.autoLaunch);
}
this.applySettings({ ...this.appUserInfo.settings, general: setting });
}

View File

@ -40,7 +40,7 @@ export const environment: Environment = {
general: {
appTheme: 'theme-default',
autoLogin: false,
autoStart: true,
autoLaunch: true,
continueRunWhenClose: true,
locale: 'ko',
hrInfoLocale: 'ko',

View File

@ -40,7 +40,7 @@ export const environment: Environment = {
general: {
appTheme: 'theme-default',
autoLogin: false,
autoStart: true,
autoLaunch: true,
continueRunWhenClose: true,
locale: 'ko',
hrInfoLocale: 'ko',

View File

@ -40,7 +40,7 @@ export const environment: Environment = {
general: {
appTheme: 'theme-default',
autoLogin: false,
autoStart: true,
autoLaunch: true,
continueRunWhenClose: true,
locale: 'ko',
hrInfoLocale: 'ko',

View File

@ -40,7 +40,7 @@ export const environment: Environment = {
general: {
appTheme: 'theme-default',
autoLogin: false,
autoStart: true,
autoLaunch: true,
continueRunWhenClose: true,
locale: 'ko',
hrInfoLocale: 'ko',

View File

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

View File

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

View File

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

View File

@ -14,6 +14,8 @@ export abstract class NativeService {
abstract changeStatus(): Observable<StatusCode>;
abstract showSetting(): Observable<void>;
abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>;
abstract notify(noti: NotificationRequest): void;
abstract closeAllNotify(): void;

View File

@ -40,25 +40,25 @@
<h1 mat-subheader>응용 프로그램</h1>
<mat-list-item>
<mat-checkbox
[checked]="setting.autoStart"
[checked]="setting.autoLaunch"
(change)="onChangeAutoStart($event)"
>응용 프로그램 자동 시작</mat-checkbox
>Windows 실행 시 자동 실행</mat-checkbox
>
</mat-list-item>
<mat-list-item>
<mat-checkbox
[checked]="setting.startBackgroudMode"
(change)="onChangeStartBackgroudMode($event)"
>백그라운드에서 응용 프로그램 열</mat-checkbox
>실행 시 창 숨기</mat-checkbox
>
</mat-list-item>
<mat-list-item>
<!-- <mat-list-item>
<mat-checkbox
[checked]="setting.continueRunWhenClose"
(change)="onChangeContinueRunWhenClose($event)"
>닫을 시 응용 프로그램을 계속 실행</mat-checkbox
>
</mat-list-item>
</mat-list-item> -->
<mat-divider></mat-divider>

View File

@ -65,7 +65,7 @@ export class GeneralComponent implements OnInit {
}
onChangeAutoStart(event: MatCheckboxChange) {
this.emit({ ...this.setting, autoStart: event.checked });
this.emit({ ...this.setting, autoLaunch: event.checked });
}
onChangeStartBackgroudMode(event: MatCheckboxChange) {
this.emit({ ...this.setting, startBackgroudMode: event.checked });

View File

@ -1,6 +1,6 @@
export interface GeneralSetting {
appTheme: string;
autoStart: boolean;
autoLaunch: boolean;
startBackgroudMode: boolean;
continueRunWhenClose: boolean;
autoLogin: boolean;