환겅설정 > 대화 > 다운로드 폴더 설정 기능구현.
This commit is contained in:
parent
2755896755
commit
2ad0cc455c
|
@ -439,6 +439,24 @@ ipcMain.on(
|
|||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
MessengerChannel.ChangeDownloadPath,
|
||||
(event: IpcMainEvent, ...args: any[]) => {
|
||||
const downloadPath = args[0] as string;
|
||||
|
||||
if (!!downloadPath && downloadPath.length > 0) {
|
||||
console.log('in electron', downloadPath);
|
||||
|
||||
appStorage.downloadPath = downloadPath;
|
||||
log.info('downloadPath is changed to ', appStorage.downloadPath);
|
||||
|
||||
event.returnValue = appStorage.downloadPath;
|
||||
} else {
|
||||
event.returnValue = '';
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
UpdaterChannel.StartCheckInstant,
|
||||
(event: IpcMainEvent, ...args: any[]) => {
|
||||
|
@ -496,7 +514,11 @@ ipcMain.on(
|
|||
const fileName: string = args[1];
|
||||
const mimeType: string = args[2];
|
||||
let savePath: string = path.join(
|
||||
!!args[3] ? args[3] : app.getPath('downloads'),
|
||||
!!args[3]
|
||||
? args[3]
|
||||
: !!appStorage.downloadPath
|
||||
? appStorage.downloadPath
|
||||
: app.getPath('downloads'),
|
||||
fileName
|
||||
);
|
||||
savePath = await FileUtil.uniqueFileName(savePath);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import ElectronStore from 'electron-store';
|
||||
import { app } from 'electron';
|
||||
|
||||
const STORE_KEY_STARTUPHIDEWINDOW = 'options.startupHideWindow';
|
||||
const STORE_KEY_DOWNLOADFOLDER = 'options.downloadPath';
|
||||
|
||||
export class Storage {
|
||||
private readonly store: ElectronStore<any>;
|
||||
|
@ -13,10 +15,14 @@ export class Storage {
|
|||
properties: {
|
||||
startupHideWindow: {
|
||||
type: 'boolean'
|
||||
},
|
||||
downloadPath: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
default: {
|
||||
startupHideWindow: false
|
||||
startupHideWindow: false,
|
||||
downloadPath: app.getPath('downloads')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -31,4 +37,11 @@ export class Storage {
|
|||
set startupHideWindow(startupHideWindow: boolean) {
|
||||
this.store.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow);
|
||||
}
|
||||
|
||||
get downloadPath(): string {
|
||||
return this.store.get(STORE_KEY_DOWNLOADFOLDER, false);
|
||||
}
|
||||
set downloadPath(downloadPath: string) {
|
||||
this.store.set(STORE_KEY_DOWNLOADFOLDER, downloadPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,10 @@ export class MessengerSettingsDialogComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
if (oriSettings.chat.downloadPath !== modSettings.chat.downloadPath) {
|
||||
this.nativeService.changeDownloadPath(modSettings.chat.downloadPath);
|
||||
}
|
||||
|
||||
return modSettings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,12 @@ export class BrowserNativeService extends NativeService {
|
|||
});
|
||||
}
|
||||
|
||||
changeDownloadPath(downloadPath: string): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
resolve(downloadPath);
|
||||
});
|
||||
}
|
||||
|
||||
notify(noti: NotificationRequest): void {
|
||||
this.notificationService.notify(noti, () => {
|
||||
window.focus();
|
||||
|
|
|
@ -147,6 +147,21 @@ export class ElectronNativeService implements NativeService {
|
|||
});
|
||||
}
|
||||
|
||||
changeDownloadPath(downloadPath: string): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
try {
|
||||
resolve(
|
||||
this.ipcRenderer.sendSync(
|
||||
MessengerChannel.ChangeDownloadPath,
|
||||
downloadPath
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
notify(noti: NotificationRequest): void {
|
||||
this.ipcRenderer.send(NotificationChannel.Notify, noti);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ export enum MessengerChannel {
|
|||
ShowSetting = 'UCAP::messenger::showSetting',
|
||||
ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch',
|
||||
ChangeStartupHideWindow = 'UCAP::messenger::changeStartupHideWindow',
|
||||
ChangeDownloadPath = 'UCAP::messenger::changeDownloadPath',
|
||||
GetNetworkInfo = 'UCAP::messenger::getNetworkInfo'
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ export abstract class NativeService {
|
|||
abstract changeStartupHideWindow(
|
||||
startupHideWindow: boolean
|
||||
): Promise<boolean>;
|
||||
abstract changeDownloadPath(downloadPath: string): Promise<string>;
|
||||
|
||||
abstract notify(noti: NotificationRequest): void;
|
||||
abstract closeAllNotify(): void;
|
||||
|
|
|
@ -41,7 +41,9 @@ export class ChatComponent implements OnInit {
|
|||
this._isNodeWebkit = this.enviromentsService.nodeWebkit();
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {
|
||||
this.logger.debug('chat setting', this.setting);
|
||||
}
|
||||
|
||||
onSelectionChangeFontFamily(event: MatSelectChange) {
|
||||
this.emit({ ...this.setting, fontFamily: event.value });
|
||||
|
@ -56,7 +58,9 @@ export class ChatComponent implements OnInit {
|
|||
this.nativeService
|
||||
.selectDirectory()
|
||||
.then(path => {
|
||||
this.emit({ ...this.setting, downloadPath: path });
|
||||
if (!!path && path.length > 0) {
|
||||
this.emit({ ...this.setting, downloadPath: path });
|
||||
}
|
||||
})
|
||||
.catch(reason => {});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user