앨범함, 파일함 :: 다운로드 기본 폴도 열기 기능 구현.
This commit is contained in:
parent
baafd13cd6
commit
7b927afb4b
|
@ -5,7 +5,8 @@ import {
|
|||
remote,
|
||||
Tray,
|
||||
Menu,
|
||||
dialog
|
||||
dialog,
|
||||
shell
|
||||
} from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
|
@ -319,6 +320,38 @@ ipcMain.on(
|
|||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
FileChannel.OpenFolderItem,
|
||||
async (event: IpcMainEvent, ...args: any[]) => {
|
||||
try {
|
||||
let folderItem: string = args[0];
|
||||
const make: boolean = args[1];
|
||||
if (!folderItem) {
|
||||
folderItem = DefaultFolder.downloads();
|
||||
}
|
||||
|
||||
let isSuccess = true;
|
||||
if (make) {
|
||||
fse.ensureDirSync(folderItem);
|
||||
}
|
||||
|
||||
if (isSuccess && fse.existsSync(folderItem)) {
|
||||
shell.openItem(folderItem);
|
||||
} else {
|
||||
isSuccess = false;
|
||||
}
|
||||
|
||||
if (isSuccess) {
|
||||
event.returnValue = true;
|
||||
} else {
|
||||
event.returnValue = false;
|
||||
}
|
||||
} catch (error) {
|
||||
event.returnValue = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
IdleStateChannel.StartCheck,
|
||||
(event: IpcMainEvent, ...args: any[]) => {
|
||||
|
|
|
@ -149,7 +149,11 @@
|
|||
>
|
||||
Download All
|
||||
</button>
|
||||
<button mat-flat-button class="mat-primary">
|
||||
<button
|
||||
mat-flat-button
|
||||
class="mat-primary"
|
||||
(click)="onClickOpenDownloadFolder()"
|
||||
>
|
||||
Open Folder
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, OnDestroy, Inject } from '@angular/core';
|
||||
import { MatPaginator, MatTableDataSource } from '@angular/material';
|
||||
import {
|
||||
FileInfo,
|
||||
FileDownloadInfo,
|
||||
FileType,
|
||||
FileType
|
||||
} from '@ucap-webmessenger/protocol-file';
|
||||
import { Subscription, combineLatest } from 'rxjs';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
@ -14,7 +14,7 @@ import { tap, map } from 'rxjs/operators';
|
|||
import {
|
||||
Info,
|
||||
EventJson,
|
||||
FileEventJson,
|
||||
FileEventJson
|
||||
} from '@ucap-webmessenger/protocol-event';
|
||||
import { FileUtil } from '@ucap-webmessenger/core';
|
||||
import { CommonApiService } from '@ucap-webmessenger/api-common';
|
||||
|
@ -24,6 +24,8 @@ import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
|
|||
import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types';
|
||||
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
||||
import { KEY_VER_INFO } from '@app/types/ver-info.type';
|
||||
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
|
||||
export interface FileInfoTotal {
|
||||
info: FileInfo;
|
||||
|
@ -34,7 +36,7 @@ export interface FileInfoTotal {
|
|||
@Component({
|
||||
selector: 'app-layout-chat-right-drawer-album-box',
|
||||
templateUrl: './album-box.component.html',
|
||||
styleUrls: ['./album-box.component.scss'],
|
||||
styleUrls: ['./album-box.component.scss']
|
||||
})
|
||||
export class AlbumBoxComponent implements OnInit, OnDestroy {
|
||||
filteredList: FileInfoTotal[] = [];
|
||||
|
@ -55,7 +57,9 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
|
|||
constructor(
|
||||
private store: Store<any>,
|
||||
private sessionStorageService: SessionStorageService,
|
||||
private commonApiService: CommonApiService
|
||||
private commonApiService: CommonApiService,
|
||||
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
||||
private loggger: NGXLogger
|
||||
) {
|
||||
this.loginRes = this.sessionStorageService.get<LoginResponse>(
|
||||
KEY_LOGIN_RES_INFO
|
||||
|
@ -81,7 +85,7 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
|
|||
),
|
||||
this.store.pipe(
|
||||
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList)
|
||||
),
|
||||
)
|
||||
])
|
||||
.pipe(
|
||||
tap(() => (this.fileInfoTotal = [])),
|
||||
|
@ -109,7 +113,7 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
|
|||
checkInfo => checkInfo.seq === fileInfo.seq
|
||||
),
|
||||
eventInfo:
|
||||
events.length > 0 ? (events[0] as Info<FileEventJson>) : null,
|
||||
events.length > 0 ? (events[0] as Info<FileEventJson>) : null
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -135,7 +139,7 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
|
|||
userSeq: this.loginRes.userSeq,
|
||||
deviceType: this.environmentsInfo.deviceType,
|
||||
token: this.loginRes.tokenString,
|
||||
attachmentsSeq: fileInfo.info.seq,
|
||||
attachmentsSeq: fileInfo.info.seq
|
||||
},
|
||||
this.sessionVerinfo.downloadUrl
|
||||
);
|
||||
|
@ -195,4 +199,18 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
|
|||
onClickDownload(fileInfo: FileInfoTotal) {
|
||||
console.log(fileInfo);
|
||||
}
|
||||
|
||||
onClickOpenDownloadFolder(): void {
|
||||
this.nativeService
|
||||
.openDefaultDownloadFolder()
|
||||
.then(result => {
|
||||
if (!!result) {
|
||||
} else {
|
||||
throw new Error('response Error');
|
||||
}
|
||||
})
|
||||
.catch(reason => {
|
||||
this.loggger.error(reason);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,11 @@
|
|||
>
|
||||
Download All
|
||||
</button>
|
||||
<button mat-flat-button class="mat-primary">
|
||||
<button
|
||||
mat-flat-button
|
||||
class="mat-primary"
|
||||
(click)="onClickOpenDownloadFolder()"
|
||||
>
|
||||
Open Folder
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, OnDestroy, Inject } from '@angular/core';
|
||||
import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material';
|
||||
import {
|
||||
FileInfo,
|
||||
|
@ -15,6 +15,8 @@ import { FileUtil } from '@ucap-webmessenger/core';
|
|||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
|
||||
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
|
||||
export interface FileInfoTotal {
|
||||
info: FileInfo;
|
||||
|
@ -46,7 +48,9 @@ export class FileBoxComponent implements OnInit, OnDestroy {
|
|||
|
||||
constructor(
|
||||
private store: Store<any>,
|
||||
private sessionStorageService: SessionStorageService
|
||||
private sessionStorageService: SessionStorageService,
|
||||
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
||||
private loggger: NGXLogger
|
||||
) {
|
||||
this.loginRes = this.sessionStorageService.get<LoginResponse>(
|
||||
KEY_LOGIN_RES_INFO
|
||||
|
@ -212,4 +216,18 @@ export class FileBoxComponent implements OnInit, OnDestroy {
|
|||
onClickRow(row: FileInfoTotal) {
|
||||
this.selectedFile = row;
|
||||
}
|
||||
|
||||
onClickOpenDownloadFolder(): void {
|
||||
this.nativeService
|
||||
.openDefaultDownloadFolder()
|
||||
.then(result => {
|
||||
if (!!result) {
|
||||
} else {
|
||||
throw new Error('response Error');
|
||||
}
|
||||
})
|
||||
.catch(reason => {
|
||||
this.loggger.error(reason);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,22 @@ export class BrowserNativeService extends NativeService {
|
|||
});
|
||||
}
|
||||
|
||||
openDefaultDownloadFolder(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
openTargetFolder(folderPath?: string, make?: boolean): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
openTargetItem(filePath?: string): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
windowStateChanged(): Observable<WindowState> {
|
||||
return new Observable<WindowState>(subscriber => {
|
||||
try {
|
||||
|
|
|
@ -147,6 +147,44 @@ export class ElectronNativeService implements NativeService {
|
|||
});
|
||||
}
|
||||
|
||||
openDefaultDownloadFolder(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
resolve(
|
||||
this.ipcRenderer.sendSync(FileChannel.OpenFolderItem, undefined, true)
|
||||
);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
openTargetFolder(folderPath?: string, make?: boolean): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
resolve(
|
||||
this.ipcRenderer.sendSync(
|
||||
FileChannel.OpenFolderItem,
|
||||
folderPath,
|
||||
!make ? false : make
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
openTargetItem(filePath?: string): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
resolve(
|
||||
this.ipcRenderer.sendSync(FileChannel.OpenFolderItem, filePath, false)
|
||||
);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
windowStateChanged(): Observable<WindowState> {
|
||||
if (!this.windowStateChangedSubject) {
|
||||
this.windowStateChangedSubject = new Subject<WindowState>();
|
||||
|
|
|
@ -18,6 +18,7 @@ export enum UpdaterChannel {
|
|||
}
|
||||
|
||||
export enum FileChannel {
|
||||
OpenFolderItem = 'UCAP::file::openFolderItem',
|
||||
ShowImageViewer = 'UCAP::file::showImageViewer',
|
||||
SaveFile = 'UCAP::file::saveFile',
|
||||
ReadFile = 'UCAP::file::readFile'
|
||||
|
|
|
@ -27,6 +27,12 @@ export abstract class NativeService {
|
|||
path?: string
|
||||
): Promise<string>;
|
||||
abstract readFile(path: string): Promise<Buffer>;
|
||||
abstract openDefaultDownloadFolder(): Promise<boolean>;
|
||||
abstract openTargetFolder(
|
||||
folderPath?: string,
|
||||
make?: boolean
|
||||
): Promise<boolean>;
|
||||
abstract openTargetItem(filePath?: string): Promise<boolean>;
|
||||
|
||||
abstract windowStateChanged(): Observable<WindowState>;
|
||||
abstract windowClose(): void;
|
||||
|
|
Loading…
Reference in New Issue
Block a user