This commit is contained in:
leejinho 2020-01-31 15:25:40 +09:00
commit 52bd202c6a
4 changed files with 26 additions and 14 deletions

View File

@ -600,12 +600,21 @@ ipcMain.on(
ipcMain.on( ipcMain.on(
FileChannel.SelectSaveFilePath, FileChannel.SelectSaveFilePath,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {
const defaultPath = args[0];
const ext = path.extname(defaultPath);
dialog dialog
.showSaveDialog({ defaultPath: args[0] }) .showSaveDialog({
defaultPath
})
.then(obj => { .then(obj => {
const filePath =
'' !== ext && '' === path.extname(obj.filePath)
? `${obj.filePath}${ext}`
: obj.filePath;
event.returnValue = { event.returnValue = {
canceled: obj.canceled, canceled: obj.canceled,
filePath: obj.filePath filePath
}; };
}) })
.catch(obj => { .catch(obj => {

View File

@ -918,19 +918,20 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.nativeService this.nativeService
.selectSaveFilePath(value.fileInfo.fileName) .selectSaveFilePath(value.fileInfo.fileName)
.then(result => { .then(result => {
if (!!result && result.filePath.length > 0) { if (!result) {
this.saveFile(value, result.filePath); return;
}
if (result.canceled) {
this.snackBarService.open(
this.translateService.instant('common.file.results.canceled'),
this.translateService.instant('common.file.errors.label'),
{
duration: 1000
}
);
} else { } else {
if (!!result && result.canceled) { this.saveFile(value, result.filePath);
// ignore..
} else {
this.snackBarService.open(
this.translateService.instant(
'common.file.errors.failToSpecifyPath'
),
this.translateService.instant('common.file.errors.label')
);
}
} }
}) })
.catch(reason => { .catch(reason => {

View File

@ -408,6 +408,7 @@
"saved": "The file has been saved.", "saved": "The file has been saved.",
"savedAll": "All file(s) have(has) been saved.", "savedAll": "All file(s) have(has) been saved.",
"savedToPath": "The file has been saved to path[{{path}}].", "savedToPath": "The file has been saved to path[{{path}}].",
"canceled": "Canceled",
"downloadInProgress": "Download is in progress." "downloadInProgress": "Download is in progress."
}, },
"errors": { "errors": {

View File

@ -408,6 +408,7 @@
"saved": "파일이 저장되었습니다.", "saved": "파일이 저장되었습니다.",
"savedAll": "모든 파일이 저장되었습니다.", "savedAll": "모든 파일이 저장되었습니다.",
"savedToPath": "파일이 경로[{{path}}]에 저장되었습니다.", "savedToPath": "파일이 경로[{{path}}]에 저장되었습니다.",
"canceled": "취소 되었습니다.",
"downloadInProgress": "다운로드가 진행중입니다." "downloadInProgress": "다운로드가 진행중입니다."
}, },
"errors": { "errors": {