electron-store 로 인한 이슈 보완처리. 2차.

This commit is contained in:
leejinho 2020-03-19 12:50:47 +09:00
parent 5c5ad1a38d
commit 48ece1c325
4 changed files with 33 additions and 16 deletions

View File

@ -132,7 +132,7 @@ export class AppWindow {
this.window.once(ElectronBrowserWindowChannel.ReadyToShow, () => {
this.window.close();
setTimeout(() => {
if (appStorage.startupHideWindow) {
if (!!appStorage && appStorage.startupHideWindow) {
this.window.close();
} else {
this.window.show();

View File

@ -61,7 +61,7 @@ import {
import log from 'electron-log';
import { RendererUpdater } from './lib/renderer-updater';
import { appStorage } from './lib/storage';
import { Storage } from './lib/storage';
require('v8-compile-cache');
@ -108,6 +108,8 @@ let updateWindowService: ElectronUpdateWindowService | null;
tmp.setGracefulCleanup();
let appStorage: Storage;
function handleUncaughtException(error: Error) {
preventQuit = true;
@ -174,6 +176,11 @@ if (isDuplicateInstance) {
}
function createWindow() {
try {
appStorage = new Storage();
} catch (e) {
log.error('[appStorage = new Storage()]]', e);
}
const window = new AppWindow(appIconPath, appStorage);
if (__DEV__) {
@ -212,7 +219,7 @@ function createWindow() {
});
window.onDidLoad(() => {
if (!appStorage.startupHideWindow) {
if (!!appStorage && !appStorage.startupHideWindow) {
// not used?
window.show();
} else {
@ -441,7 +448,9 @@ ipcMain.on(
ipcMain.on(
MessengerChannel.ClearAppStorage,
(event: IpcMainEvent, ...args: any[]) => {
appStorage.reset();
if (!!!!appStorage) {
appStorage.reset();
}
}
);
@ -479,13 +488,15 @@ ipcMain.on(
(event: IpcMainEvent, ...args: any[]) => {
const isStartupHideWindow = args[0] as boolean;
appStorage.startupHideWindow = isStartupHideWindow;
log.info(
'StartupHideWindow is changed from ',
!appStorage.startupHideWindow,
' to ',
appStorage.startupHideWindow
);
if (!!!!appStorage) {
appStorage.startupHideWindow = isStartupHideWindow;
log.info(
'StartupHideWindow is changed from ',
!appStorage.startupHideWindow,
' to ',
appStorage.startupHideWindow
);
}
event.returnValue = true;
}
);
@ -495,7 +506,7 @@ ipcMain.on(
(event: IpcMainEvent, ...args: any[]) => {
const downloadPath = args[0] as string;
if (!!downloadPath && downloadPath.length > 0) {
if (!!appStorage && !!downloadPath && downloadPath.length > 0) {
appStorage.downloadPath = downloadPath;
log.info('downloadPath is changed to ', appStorage.downloadPath);
@ -566,9 +577,9 @@ ipcMain.on(
let basePath = path.join(
app.getPath('documents'),
appStorage.constDefaultDownloadFolder
!!appStorage ? appStorage.constDefaultDownloadFolder : ''
);
if (!!appStorage.downloadPath) {
if (!!appStorage && !!appStorage.downloadPath) {
basePath = appStorage.downloadPath;
}
try {
@ -608,7 +619,7 @@ ipcMain.on(
const make: boolean = args[1];
if (!folderItem) {
let basePath = app.getPath('downloads');
if (!!appStorage.downloadPath) {
if (!!appStorage && !!appStorage.downloadPath) {
try {
basePath = appStorage.downloadPath;
} catch (err) {

View File

@ -45,7 +45,7 @@
"@angular/core": "^8.2.14",
"auto-launch": "^5.0.5",
"electron-log": "^3.0.9",
"electron-store": "^5.1.0",
"electron-store": "^5.1.1",
"electron-updater": "^4.2.0",
"electron-window-state": "^5.0.3",
"file-type": "^14.1.2",

View File

@ -79,6 +79,12 @@ export class AppAuthenticationService {
}
}
};
// if (!!environment.productConfig.defaultSettings.general.autoLaunch) {
// this.nativeService.changeAutoLaunch(
// environment.productConfig.defaultSettings.general.autoLaunch
// );
// }
}
appUserInfo = {